CMakeLists.txt
author Sam Lantinga <slouken@libsdl.org>
Tue, 30 Jul 2013 21:39:38 -0700
changeset 7550 ff3e041c27f3
parent 7525 e5ae3502a25e
child 7666 603fb699946c
permissions -rw-r--r--
Added code signature step to Framework build process
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
     1
if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
     2
  message(FATAL_ERROR "Prevented in-tree built. Please create a build directory outside of the SDL source code and call cmake from there")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
     3
endif()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
     4
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
     5
cmake_minimum_required(VERSION 2.6)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
     6
project(SDL2 C)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
     7
include(CheckFunctionExists)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
     8
include(CheckLibraryExists)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
     9
include(CheckIncludeFiles)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    10
include(CheckIncludeFile)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    11
include(CheckSymbolExists)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    12
include(CheckCSourceRuns)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    13
include(CheckCCompilerFlag)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    14
include(CheckTypeSize)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    15
include(CheckStructHasMember)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    16
include(CMakeDependentOption)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    17
include(FindPkgConfig)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    18
set(CMAKE_MODULE_PATH "${SDL2_SOURCE_DIR}/cmake")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    19
include(${SDL2_SOURCE_DIR}/cmake/macros.cmake)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    20
include(${SDL2_SOURCE_DIR}/cmake/sdlchecks.cmake)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    21
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    22
# General settings
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    23
# Edit include/SDL_version.h and change the version, then:
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    24
#   SDL_MICRO_VERSION += 1;
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    25
#   SDL_INTERFACE_AGE += 1;
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    26
#   SDL_BINARY_AGE += 1;
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    27
# if any functions have been added, set SDL_INTERFACE_AGE to 0.
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    28
# if backwards compatibility has been broken,
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    29
# set SDL_BINARY_AGE and SDL_INTERFACE_AGE to 0.
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    30
set(SDL_MAJOR_VERSION 2)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    31
set(SDL_MINOR_VERSION 0)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    32
set(SDL_MICRO_VERSION 0)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    33
set(SDL_INTERFACE_AGE 0)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    34
set(SDL_BINARY_AGE 0)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    35
set(SDL_VERSION "${SDL_MAJOR_VERSION}.${SDL_MINOR_VERSION}.${SDL_MICRO_VERSION}")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    36
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    37
# Calculate a libtool-like version number
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    38
math(EXPR LT_CURRENT "${SDL_MICRO_VERSION} - ${SDL_INTERFACE_AGE}")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    39
math(EXPR LT_AGE "${SDL_BINARY_AGE} - ${SDL_INTERFACE_AGE}")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    40
set(LT_REVISION "${SDL_INTERFACE_AGE}")
7525
e5ae3502a25e Fixed bug 1743 - CMake produces libraries with wrong filename/SONAME
Sam Lantinga <slouken@libsdl.org>
parents: 7427
diff changeset
    41
set(LT_RELEASE "${SDL_MAJOR_VERSION}.${SDL_MINOR_VERSION}")
e5ae3502a25e Fixed bug 1743 - CMake produces libraries with wrong filename/SONAME
Sam Lantinga <slouken@libsdl.org>
parents: 7427
diff changeset
    42
set(LT_VERSION "${LT_CURRENT}.${LT_REVISION}.${LT_AGE}")
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    43
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    44
# General settings & flags
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    45
set(LIBRARY_OUTPUT_DIRECTORY "build")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    46
# Check for 64 or 32 bit
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    47
set(SIZEOF_VOIDP ${CMAKE_SIZEOF_VOID_P})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    48
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    49
  set(ARCH_64 TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    50
  set(PROCESSOR_ARCH "x64")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    51
else()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    52
  set(ARCH_64 FALSE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    53
  set(PROCESSOR_ARCH "x86")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    54
endif(CMAKE_SIZEOF_VOID_P EQUAL 8)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    55
set(LIBNAME SDL2)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    56
if(NOT LIBTYPE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    57
  set(LIBTYPE SHARED)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    58
endif(NOT LIBTYPE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    59
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    60
# Get the platform
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    61
if(WIN32)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    62
  if(NOT WINDOWS)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    63
    set(WINDOWS TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    64
  endif(NOT WINDOWS)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    65
elseif(UNIX AND NOT APPLE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    66
  if(CMAKE_SYSTEM_NAME MATCHES ".*Linux")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    67
    set(LINUX TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    68
  elseif(CMAKE_SYSTEM_NAME MATCHES "kFreeBSD.*")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    69
    set(FREEBSD TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    70
  elseif(CMAKE_SYSTEM_NAME MATCHES "kNetBSD.*|NetBSD.*")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    71
    set(NETBSD TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    72
  elseif(CMAKE_SYSTEM_NAME MATCHES "kOpenBSD.*|OpenBSD.*")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    73
    set(OPENBSD TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    74
  elseif(CMAKE_SYSTEM_NAME MATCHES ".*GNU.*")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    75
    set(GNU TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    76
  elseif(CMAKE_SYSTEM_NAME MATCHES ".*BSDI.*")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    77
    set(BSDI TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    78
  elseif(CMAKE_SYSTEM_NAME MATCHES "DragonFly.*|FreeBSD")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    79
    set(FREEBSD TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    80
  elseif(CMAKE_SYSTEM_NAME MATCHES "SYSV5.*")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    81
    set(SYSV5 TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    82
  elseif(CMAKE_SYSTEM_NAME MATCHES "Solaris.*")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    83
    set(SOLARIS TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    84
  elseif(CMAKE_SYSTEM_NAME MATCHES "HP-UX.*")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    85
    set(HPUX TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    86
  elseif(CMAKE_SYSTEM_NAME MATCHES "AIX.*")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    87
    set(AIX TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    88
  elseif(CMAKE_SYSTEM_NAME MATCHES "Minix.*")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    89
    set(MINIX TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    90
  endif()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    91
elseif(APPLE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    92
  if(CMAKE_SYSTEM_NAME MATCHES ".*Darwin.*")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    93
    set(DARWIN TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    94
  elseif(CMAKE_SYSTEM_NAME MATCHES ".*MacOS.*")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    95
    set(MACOSX TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    96
  endif()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    97
  # TODO: iOS?
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    98
elseif(CMAKE_SYSTEM_NAME MATCHES "Haiku.*|BeOS.*")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    99
  set(BEOS TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   100
endif()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   101
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   102
# Don't mistake osx for unix
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   103
if(UNIX AND NOT APPLE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   104
  set(UNIX_SYS ON)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   105
else()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   106
  set(UNIX_SYS OFF)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   107
endif(UNIX AND NOT APPLE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   108
7426
e36a759d3bb1 CMake project should enable pthreads for Mac OS X by default.
Ryan C. Gordon <icculus@icculus.org>
parents: 7395
diff changeset
   109
if(UNIX OR APPLE)
e36a759d3bb1 CMake project should enable pthreads for Mac OS X by default.
Ryan C. Gordon <icculus@icculus.org>
parents: 7395
diff changeset
   110
  set(UNIX_OR_MAC_SYS ON)
e36a759d3bb1 CMake project should enable pthreads for Mac OS X by default.
Ryan C. Gordon <icculus@icculus.org>
parents: 7395
diff changeset
   111
else()
e36a759d3bb1 CMake project should enable pthreads for Mac OS X by default.
Ryan C. Gordon <icculus@icculus.org>
parents: 7395
diff changeset
   112
  set(UNIX_OR_MAC_SYS OFF)
e36a759d3bb1 CMake project should enable pthreads for Mac OS X by default.
Ryan C. Gordon <icculus@icculus.org>
parents: 7395
diff changeset
   113
endif(UNIX OR APPLE)
e36a759d3bb1 CMake project should enable pthreads for Mac OS X by default.
Ryan C. Gordon <icculus@icculus.org>
parents: 7395
diff changeset
   114
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   115
# Default option knobs
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   116
if(APPLE OR ARCH_64)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   117
  set(OPT_DEF_SSEMATH ON)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   118
endif()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   119
if(UNIX OR MINGW OR MSYS)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   120
  set(OPT_DEF_LIBC ON)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   121
endif(UNIX OR MINGW OR MSYS)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   122
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   123
# Compiler info
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   124
if(CMAKE_COMPILER_IS_GNUCC)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   125
  set(USE_GCC TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   126
  set(OPT_DEF_ASM TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   127
elseif(CMAKE_C_COMPILER_ID MATCHES "Clang")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   128
  set(USE_CLANG TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   129
  set(OPT_DEF_ASM TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   130
elseif(MSVC_VERSION GREATER 1400) # VisualStudio 8.0+
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   131
  set(OPT_DEF_ASM TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   132
  #set(CMAKE_C_FLAGS "/ZI /WX- /
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   133
else()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   134
  set(OPT_DEF_ASM FALSE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   135
endif(CMAKE_COMPILER_IS_GNUCC)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   136
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   137
# Default flags, if not set otherwise
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   138
if("$ENV{CFLAGS}" STREQUAL "")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   139
  if(USE_GCC OR USE_CLANG)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   140
    set(CMAKE_C_FLAGS "-g -O3")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   141
  endif(USE_GCC OR USE_CLANG)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   142
else("$ENV{CFLAGS}" STREQUAL "")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   143
  set(CMAKE_C_FLAGS "$ENV{CFLAGS}")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   144
  list(APPEND EXTRA_CFLAGS "$ENV{CFLAGS}")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   145
endif("$ENV{CFLAGS}" STREQUAL "")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   146
if(NOT ("$ENV{CFLAGS}" STREQUAL "")) # Hackish, but does the trick on Win32
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   147
  list(APPEND EXTRA_LDFLAGS "$ENV{LDFLAGS}")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   148
endif(NOT ("$ENV{CFLAGS}" STREQUAL ""))
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   149
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   150
# Those are used for pkg-config and friends, so that the SDL2.pc, sdl2-config,
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   151
# etc. are created correctly.
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   152
set(SDL_LIBS "-lSDL2")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   153
set(SDL_CFLAGS "")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   154
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   155
if(CYGWIN)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   156
  # We build SDL on cygwin without the UNIX emulation layer
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   157
  include_directories("-I/usr/include/mingw")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   158
  set(CMAKE_REQUIRED_FLAGS "-mno-cygwin")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   159
  check_c_source_compiles("int main(int argc, char **argv) {}"
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   160
    HAVE_GCC_NO_CYGWIN)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   161
  set(CMAKE_REQUIRED_FLAGS)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   162
  if(HAVE_GCC_NO_CYGWIN)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   163
    list(APPEND EXTRA_LDFLAGS "-mno-cygwin")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   164
    list(APPEND SDL_LIBS "-mno-cygwin")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   165
  endif(HAVE_GCC_NO_CYGWIN)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   166
  set(SDL_CFLAGS "${SDL_CFLAGS} -I/usr/include/mingw")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   167
endif(CYGWIN)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   168
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   169
add_definitions(-DUSING_GENERATED_CONFIG_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   170
# General includes
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   171
include_directories(${SDL2_BINARY_DIR}/include ${SDL2_SOURCE_DIR}/include)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   172
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   173
set(SDL_SUBSYSTEMS
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   174
    Atomic Audio Video Render Events Joystick Haptic Power Threads Timers
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   175
    File Loadso CPUinfo)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   176
foreach(_SUB ${SDL_SUBSYSTEMS})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   177
  string(TOUPPER ${_SUB} _OPT)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   178
  option(SDL_${_OPT} "Enable the ${_SUB} subsystem" ON)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   179
endforeach()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   180
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   181
option_string(ASSERTIONS "Enable internal sanity checks (auto/disabled/release/enabled/paranoid)" "auto")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   182
#set_option(DEPENDENCY_TRACKING "Use gcc -MMD -MT dependency tracking" ON)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   183
set_option(LIBC                "Use the system C library" ${OPT_DEF_LIBC})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   184
set_option(GCC_ATOMICS         "Use gcc builtin atomics" ${USE_GCC})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   185
set_option(ASSEMBLY            "Enable assembly routines" ${OPT_DEF_ASM})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   186
set_option(SSEMATH             "Allow GCC to use SSE floating point math" ${OPT_DEF_SSEMATH})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   187
set_option(MMX                 "Use MMX assembly routines" ${OPT_DEF_ASM})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   188
set_option(3DNOW               "Use 3Dnow! MMX assembly routines" ${OPT_DEF_ASM})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   189
set_option(SSE                 "Use SSE assembly routines" ${OPT_DEF_ASM})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   190
set_option(SSE2                "Use SSE2 assembly routines" ${OPT_DEF_SSEMATH})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   191
set_option(ALTIVEC             "Use Altivec assembly routines" ${OPT_DEF_ASM})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   192
set_option(DISKAUDIO           "Support the disk writer audio driver" ON)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   193
set_option(DUMMYAUDIO          "Support the dummy audio driver" ON)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   194
set_option(VIDEO_DIRECTFB      "Use DirectFB video driver" OFF)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   195
dep_option(DIRECTFB_SHARED     "Dynamically load directfb support" ON "VIDEO_DIRECTFB" OFF)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   196
set_option(FUSIONSOUND         "Use FusionSound audio driver" OFF)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   197
dep_option(FUSIONSOUND_SHARED  "Dynamically load fusionsound audio support" ON "FUSIONSOUND_SHARED" OFF)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   198
set_option(VIDEO_DUMMY         "Use dummy video driver" ON)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   199
set_option(VIDEO_OPENGL        "Include OpenGL support" ON)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   200
set_option(VIDEO_OPENGLES      "Include OpenGL ES support" ON)
7426
e36a759d3bb1 CMake project should enable pthreads for Mac OS X by default.
Ryan C. Gordon <icculus@icculus.org>
parents: 7395
diff changeset
   201
set_option(PTHREADS            "Use POSIX threads for multi-threading" ${UNIX_OR_MAC_SYS})
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   202
dep_option(PTHREADS_SEM        "Use pthread semaphores" ON "PTHREADS" OFF)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   203
set_option(SDL_DLOPEN          "Use dlopen for shared object loading" ON)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   204
set_option(OSS                 "Support the OSS audio API" ${UNIX_SYS})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   205
set_option(ALSA                "Support the ALSA audio API" ${UNIX_SYS})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   206
dep_option(ALSA_SHARED         "Dynamically load ALSA audio support" ON "ALSA" OFF)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   207
set_option(ESD                 "Support the Enlightened Sound Daemon" ${UNIX_SYS})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   208
dep_option(ESD_SHARED          "Dynamically load ESD audio support" ON "ESD" OFF)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   209
set_option(PULSEAUDIO          "Use PulseAudio" ${UNIX_SYS})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   210
dep_option(PULSEAUDIO_SHARED   "Dynamically load PulseAudio support" ON "PULSEAUDIO" OFF)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   211
set_option(ARTS                "Support the Analog Real Time Synthesizer" ${UNIX_SYS})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   212
dep_option(ARTS_SHARED         "Dynamically load aRts audio support" ON "ARTS" OFF)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   213
set_option(NAS                 "Support the NAS audio API" ${UNIX_SYS})
7367
d6eabafa8776 Added an SDL2 OpenBSD sndio(7) audio target.
Ryan C. Gordon <icculus@icculus.org>
parents: 6774
diff changeset
   214
set_option(SNDIO               "Support the sndio audio API" ${UNIX_SYS})
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   215
set_option(RPATH               "Use an rpath when linking SDL" ${UNIX_SYS})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   216
set_option(CLOCK_GETTIME       "Use clock_gettime() instead of gettimeofday()" OFF)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   217
set_option(INPUT_TSLIB         "Use the Touchscreen library for input" ${UNIX_SYS})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   218
set_option(VIDEO_X11           "Use X11 video driver" ${UNIX_SYS})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   219
dep_option(X11_SHARED          "Dynamically load X11 support" ON "VIDEO_X11" OFF)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   220
set(SDL_X11_OPTIONS Xcursor Xinerama XInput Xrandr Xscrnsaver XShape Xvm)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   221
foreach(_SUB ${SDL_X11_OPTIONS})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   222
  string(TOUPPER "VIDEO_X11_${_SUB}" _OPT)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   223
  dep_option(${_OPT}           "Enable ${_SUB} support" ON "VIDEO_X11" OFF)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   224
endforeach()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   225
set_option(VIDEO_COCOA         "Use Cocoa video driver" ${APPLE})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   226
set_option(DIRECTX             "Use DirectX for Windows audio/video" ${WINDOWS})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   227
set_option(RENDER_D3D          "Enable the Direct3D render driver" ${WINDOWS})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   228
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   229
# TODO: We should (should we?) respect cmake's ${BUILD_SHARED_LIBS} flag here
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   230
# The options below are for compatibility to configure's default behaviour.
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   231
set(SDL_SHARED ON CACHE BOOL "Build a shared version of the library")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   232
set(SDL_STATIC ON CACHE BOOL "Build a static version of the library")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   233
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   234
# General source files
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   235
file(GLOB SOURCE_FILES
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   236
  ${SDL2_SOURCE_DIR}/src/*.c
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   237
  ${SDL2_SOURCE_DIR}/src/atomic/*.c
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   238
  ${SDL2_SOURCE_DIR}/src/audio/*.c
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   239
  ${SDL2_SOURCE_DIR}/src/cpuinfo/*.c
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   240
  ${SDL2_SOURCE_DIR}/src/events/*.c
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   241
  ${SDL2_SOURCE_DIR}/src/file/*.c
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   242
  ${SDL2_SOURCE_DIR}/src/libm/*.c
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   243
  ${SDL2_SOURCE_DIR}/src/render/*.c
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   244
  ${SDL2_SOURCE_DIR}/src/render/*/*.c
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   245
  ${SDL2_SOURCE_DIR}/src/stdlib/*.c
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   246
  ${SDL2_SOURCE_DIR}/src/thread/*.c
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   247
  ${SDL2_SOURCE_DIR}/src/timer/*.c
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   248
  ${SDL2_SOURCE_DIR}/src/video/*.c)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   249
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   250
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   251
if(ASSERTIONS STREQUAL "auto")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   252
  # Do nada - use optimization settings to determine the assertion level
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   253
elseif(ASSERTIONS STREQUAL "disabled")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   254
  set(SDL_DEFAULT_ASSERT_LEVEL 0)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   255
elseif(ASSERTIONS STREQUAL "release")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   256
  set(SDL_DEFAULT_ASSERT_LEVEL 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   257
elseif(ASSERTIONS STREQUAL "enabled")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   258
  set(SDL_DEFAULT_ASSERT_LEVEL 2)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   259
elseif(ASSERTIONS STREQUAL "paranoid")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   260
  set(SDL_DEFAULT_ASSERT_LEVEL 3)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   261
else()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   262
  message_error("unknown assertion level")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   263
endif(ASSERTIONS STREQUAL "auto")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   264
set(HAVE_ASSERTIONS ${ASSERTIONS})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   265
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   266
# Compiler option evaluation
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   267
if(USE_GCC)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   268
  if(DEPENDENCY_TRACKING)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   269
    check_c_source_compiles("
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   270
        #if !defined(__GNUC__) || __GNUC__ < 3
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   271
        #error Dependency tracking requires GCC 3.0 or newer
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   272
        #endif
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   273
        int main(int argc, char **argv) { }" HAVE_DEPENDENCY_TRACKING)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   274
  endif(DEPENDENCY_TRACKING)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   275
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   276
  if(GCC_ATOMICS)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   277
    check_c_source_compiles("int main(int argc, char **argv) {
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   278
        int a;
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   279
        void *x, *y, *z;
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   280
        __sync_lock_test_and_set(&a, 4);
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   281
        __sync_lock_test_and_set(&x, y);
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   282
        __sync_fetch_and_add(&a, 1);
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   283
        __sync_bool_compare_and_swap(&a, 5, 10);
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   284
        __sync_bool_compare_and_swap(&x, y, z); }" HAVE_GCC_ATOMICS)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   285
    if(NOT HAVE_GCC_ATOMICS)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   286
      check_c_source_compiles("int main(int argc, char **argv) {
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   287
          int a;
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   288
          __sync_lock_test_and_set(&a, 1);
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   289
          __sync_lock_release(&a); }" HAVE_GCC_SYNC_LOCK_TEST_AND_SET)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   290
    endif(NOT HAVE_GCC_ATOMICS)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   291
  endif(GCC_ATOMICS)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   292
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   293
  set(CMAKE_REQUIRED_FLAGS "-mpreferred-stack-boundary=2")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   294
  check_c_source_compiles("int x = 0; int main(int argc, char **argv) {}"
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   295
    HAVE_GCC_PREFERRED_STACK_BOUNDARY)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   296
  set(CMAKE_REQUIRED_FLAGS)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   297
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   298
  set(CMAKE_REQUIRED_FLAGS "-fvisibility=hidden -Werror")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   299
  check_c_source_compiles("
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   300
      #if !defined(__GNUC__) || __GNUC__ < 4
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   301
      #error SDL only uses visibility attributes in GCC 4 or newer
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   302
      #endif
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   303
      int main(int argc, char **argv) {}" HAVE_GCC_FVISIBILITY)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   304
  if(HAVE_GCC_FVISIBILITY)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   305
    list(APPEND EXTRA_CFLAGS "-fvisibility=hidden")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   306
  endif(HAVE_GCC_FVISIBILITY)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   307
  set(CMAKE_REQUIRED_FLAGS)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   308
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   309
  check_c_compiler_flag(-Wall HAVE_GCC_WALL)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   310
  if(HAVE_GCC_WALL)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   311
    if(CMAKE_SYSTEM_NAME MATCHES "Haiku|BeOS")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   312
      set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-multichar")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   313
    endif(CMAKE_SYSTEM_NAME MATCHES "Haiku|BeOS")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   314
  endif(HAVE_GCC_WALL)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   315
endif(USE_GCC)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   316
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   317
if(ASSEMBLY)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   318
  if(USE_GCC OR USE_CLANG)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   319
    set(SDL_ASSEMBLY_ROUTINES 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   320
    # TODO: Those all seem to be quite GCC specific - needs to be
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   321
    # reworked for better compiler support
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   322
    set(HAVE_ASSEMBLY TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   323
    if(MMX)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   324
      set(CMAKE_REQUIRED_FLAGS "-mmmx")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   325
      check_c_source_compiles("
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   326
          #ifdef __MINGW32__
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   327
          #include <_mingw.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   328
          #ifdef __MINGW64_VERSION_MAJOR
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   329
          #include <intrin.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   330
          #else
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   331
          #include <mmintrin.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   332
          #endif
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   333
          #else
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   334
          #include <mmintrin.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   335
          #endif
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   336
          #ifndef __MMX__
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   337
          #error Assembler CPP flag not enabled
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   338
          #endif
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   339
          int main(int argc, char **argv) { }" HAVE_MMX)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   340
      if(HAVE_MMX)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   341
        list(APPEND EXTRA_CFLAGS "-mmmx")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   342
      endif(HAVE_MMX)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   343
      set(CMAKE_REQUIRED_FLAGS)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   344
    endif(MMX)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   345
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   346
    if(3DNOW)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   347
      set(CMAKE_REQUIRED_FLAGS "-m3dnow")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   348
      check_c_source_compiles("
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   349
          #include <mm3dnow.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   350
          #ifndef __3dNOW__
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   351
          #error Assembler CPP flag not enabled
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   352
          #endif
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   353
          int main(int argc, char **argv) {
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   354
            void *p = 0;
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   355
            _m_prefetch(p);
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   356
          }" HAVE_3DNOW)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   357
      if(HAVE_3DNOW)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   358
        list(APPEND EXTRA_CFLAGS "-m3dnow")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   359
      endif(HAVE_3DNOW)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   360
      set(CMAKE_REQUIRED_FLAGS)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   361
    endif(3DNOW)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   362
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   363
    if(SSE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   364
      set(CMAKE_REQUIRED_FLAGS "-msse")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   365
      check_c_source_compiles("
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   366
          #ifdef __MINGW32__
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   367
          #include <_mingw.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   368
          #ifdef __MINGW64_VERSION_MAJOR
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   369
          #include <intrin.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   370
          #else
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   371
          #include <xmmintrin.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   372
          #endif
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   373
          #else
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   374
          #include <xmmintrin.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   375
          #endif
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   376
          #ifndef __SSE__
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   377
          #error Assembler CPP flag not enabled
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   378
          #endif
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   379
          int main(int argc, char **argv) { }" HAVE_SSE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   380
      if(HAVE_SSE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   381
        list(APPEND EXTRA_CFLAGS "-msse")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   382
      endif(HAVE_SSE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   383
      set(CMAKE_REQUIRED_FLAGS)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   384
    endif(SSE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   385
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   386
    if(SSE2)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   387
      set(CMAKE_REQUIRED_FLAGS "-msse2")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   388
      check_c_source_compiles("
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   389
          #ifdef __MINGW32__
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   390
          #include <_mingw.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   391
          #ifdef __MINGW64_VERSION_MAJOR
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   392
          #include <intrin.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   393
          #else
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   394
          #include <emmintrin.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   395
          #endif
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   396
          #else
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   397
          #include <emmintrin.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   398
          #endif
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   399
          #ifndef __SSE2__
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   400
          #error Assembler CPP flag not enabled
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   401
          #endif
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   402
          int main(int argc, char **argv) { }" HAVE_SSE2)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   403
      if(HAVE_SSE2)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   404
        list(APPEND EXTRA_CFLAGS "-msse2")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   405
      endif(HAVE_SSE2)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   406
      set(CMAKE_REQUIRED_FLAGS)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   407
    endif(SSE2)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   408
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   409
    if(SSEMATH)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   410
      if(SSE OR SSE2)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   411
        if(USE_GCC)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   412
          list(APPEND EXTRA_CFLAGS "-mfpmath=387")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   413
        endif(USE_GCC)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   414
        set(HAVE_SSEMATH TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   415
      endif(SSE OR SSE2)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   416
    endif(SSEMATH)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   417
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   418
    if(ALTIVEC)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   419
      set(CMAKE_REQUIRED_FLAGS "-maltivec")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   420
      check_c_source_compiles("
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   421
          #include <altivec.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   422
          vector unsigned int vzero() {
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   423
              return vec_splat_u32(0);
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   424
          }
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   425
          int main(int argc, char **argv) { }" HAVE_ALTIVEC_H_HDR)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   426
      check_c_source_compiles("
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   427
          vector unsigned int vzero() {
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   428
              return vec_splat_u32(0);
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   429
          }
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   430
          int main(int argc, char **argv) { }" HAVE_ALTIVEC)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   431
      set(CMAKE_REQUIRED_FLAGS)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   432
      if(HAVE_ALTIVEC OR HAVE_ALTIVEC_H_HDR)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   433
        set(HAVE_ALTIVEC TRUE) # if only HAVE_ALTIVEC_H_HDR is set
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   434
        list(APPEND EXTRA_CFLAGS "-maltivec")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   435
        set(SDL_ALTIVEC_BLITTERS 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   436
        if(HAVE_ALTIVEC_H_HDR)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   437
          set(HAVE_ALTIVEC_H 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   438
        endif(HAVE_ALTIVEC_H_HDR)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   439
      endif(HAVE_ALTIVEC OR HAVE_ALTIVEC_H_HDR)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   440
    endif(ALTIVEC)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   441
  elseif(MSVC_VERSION GREATER 1500)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   442
    # TODO: SDL_cpuinfo.h needs to support the user's configuration wish
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   443
    # for MSVC - right now it is always activated
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   444
    if(NOT ARCH_64)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   445
      set(HAVE_MMX TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   446
      set(HAVE_3DNOW TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   447
    endif(NOT ARCH_64)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   448
    set(HAVE_SSE TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   449
    set(HAVE_SSE2 TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   450
    set(SDL_ASSEMBLY_ROUTINES 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   451
  endif(USE_GCC OR USE_CLANG)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   452
# TODO:
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   453
#else(ASSEMBLY)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   454
#  if(USE_GCC OR USE_CLANG)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   455
#    list(APPEND EXTRA_CFLAGS "-mno-sse" "-mno-sse2" "-mno-mmx")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   456
#  endif(USE_GCC OR USE_CLANG)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   457
endif(ASSEMBLY)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   458
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   459
# TODO: Can't deactivate on FreeBSD? w/o LIBC, SDL_stdinc.h can't define
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   460
# anything.
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   461
if(LIBC)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   462
  if(WINDOWS AND NOT MINGW)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   463
    set(HAVE_LIBC TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   464
    foreach(_HEADER stdio.h string.h ctype.h math.h)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   465
      string(TOUPPER "HAVE_${_HEADER}" _UPPER)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   466
      string(REPLACE "." "_" _HAVE_H ${_UPPER})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   467
      set(${_HAVE_H} 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   468
    endforeach()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   469
    set(HAVE_SIGNAL_H 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   470
    foreach(_FN
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   471
            malloc calloc realloc free qsort abs memset memcpy memmove memcmp
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   472
            strlen _strrev _strupr _strlwr strchr strrchr strstr itoa _ltoa
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   473
            _ultoa strtol strtoul strtoll strtod atoi atof strcmp strncmp
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   474
            _stricmp _strnicmp sscanf atan atan2 ceil copysign cos cosf fabs
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   475
            floor log pow scalbn sin sinf sqrt)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   476
      string(TOUPPER ${_FN} _UPPER)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   477
      set(HAVE_${_UPPER} 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   478
    endforeach()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   479
    if(NOT CYGWIN AND NOT MINGW)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   480
      set(HAVE_ALLOCA 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   481
    endif(NOT CYGWIN AND NOT MINGW)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   482
    set(HAVE_M_PI 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   483
    add_definitions(-D_USE_MATH_DEFINES) # needed for M_PI
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   484
    set(STDC_HEADERS 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   485
  else(WINDOWS AND NOT MINGW)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   486
    set(HAVE_LIBC TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   487
    check_include_file(sys/types.h HAVE_SYS_TYPES_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   488
    foreach(_HEADER
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   489
            stdio.h stdlib.h stddef.h stdarg.h malloc.h memory.h string.h
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   490
            strings.h inttypes.h stdint.h ctype.h math.h iconv.h signal.h)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   491
      string(TOUPPER "HAVE_${_HEADER}" _UPPER)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   492
      string(REPLACE "." "_" _HAVE_H ${_UPPER})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   493
      check_include_file("${_HEADER}" ${_HAVE_H})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   494
    endforeach()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   495
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   496
    check_include_files("dlfcn.h;stdint.h;stddef.h;inttypes.h;stdlib.h;strings.h;string.h;float.h" STDC_HEADERS)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   497
    check_type_size("size_t" SIZEOF_SIZE_T)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   498
    check_symbol_exists(M_PI math.h HAVE_M_PI)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   499
    # TODO: refine the mprotect check
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   500
    check_c_source_compiles("#include <sys/types.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   501
                             #include <sys/mman.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   502
                             int main() { }" HAVE_MPROTECT)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   503
    foreach(_FN
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   504
            strtod malloc calloc realloc free getenv setenv putenv unsetenv
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   505
            qsort abs bcopy memset memcpy memmove memcmp strlen strlcpy strlcat
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   506
            strdup _strrev _strupr _strlwr strchr strrchr strstr itoa _ltoa
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   507
            _uitoa _ultoa strtol strtoul _i64toa _ui64toa strtoll strtoull
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   508
            atoi atof strcmp strncmp _stricmp strcasecmp _strnicmp strncasecmp
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   509
            sscanf snprintf vsnprintf fseeko fseeko64 sigaction setjmp
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   510
            nanosleep sysconf sysctlbyname
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   511
            )
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   512
      string(TOUPPER ${_FN} _UPPER)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   513
      set(_HAVEVAR "HAVE_${_UPPER}")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   514
      check_function_exists("${_FN}" ${_HAVEVAR})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   515
    endforeach()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   516
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   517
    check_library_exists(m pow "" HAVE_LIBM)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   518
    if(HAVE_LIBM)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   519
      set(CMAKE_REQUIRED_LIBRARIES m)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   520
      foreach(_FN
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   521
              atan atan2 ceil copysign cos cosf fabs floor log pow scalbn sin
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   522
              sinf sqrt)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   523
        string(TOUPPER ${_FN} _UPPER)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   524
        set(_HAVEVAR "HAVE_${_UPPER}")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   525
        check_function_exists("${_FN}" ${_HAVEVAR})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   526
      endforeach()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   527
      set(CMAKE_REQUIRED_LIBRARIES)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   528
      list(APPEND EXTRA_LIBS m)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   529
    endif(HAVE_LIBM)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   530
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   531
    check_library_exists(iconv iconv_open "" HAVE_LIBICONV)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   532
    if(HAVE_LIBICONV)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   533
      list(APPEND EXTRA_LIBS iconv)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   534
    endif(HAVE_LIBICONV)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   535
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   536
    check_struct_has_member("struct sigaction" "sa_sigaction" "signal.h" HAVE_SA_SIGACTION)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   537
  endif(WINDOWS AND NOT MINGW)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   538
else(LIBC)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   539
  if(WINDOWS)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   540
    set(HAVE_STDARG_H 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   541
    set(HAVE_STDDEF_H 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   542
  endif(WINDOWS)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   543
endif(LIBC)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   544
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   545
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   546
# Enable/disable various subsystems of the SDL library
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   547
foreach(_SUB ${SDL_SUBSYSTEMS})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   548
  string(TOUPPER ${_SUB} _OPT)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   549
  if(NOT SDL_${_OPT})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   550
    set(SDL_${_OPT}_DISABLED 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   551
  endif(NOT SDL_${_OPT})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   552
endforeach()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   553
if(SDL_JOYSTICK)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   554
  file(GLOB JOYSTICK_SOURCES ${SDL2_SOURCE_DIR}/src/joystick/*.c)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   555
  set(SOURCE_FILES ${SOURCE_FILES} ${JOYSTICK_SOURCES})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   556
endif(SDL_JOYSTICK)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   557
if(SDL_HAPTIC)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   558
  if(NOT SDL_JOYSTICK)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   559
    # Haptic requires some private functions from the joystick subsystem.
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   560
    message_error("SDL_HAPTIC requires SDL_JOYSTICK, which is not enabled")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   561
  endif(NOT SDL_JOYSTICK)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   562
  file(GLOB HAPTIC_SOURCES ${SDL2_SOURCE_DIR}/src/haptic/*.c)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   563
  set(SOURCE_FILES ${SOURCE_FILES} ${HAPTIC_SOURCES})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   564
endif(SDL_HAPTIC)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   565
if(SDL_POWER)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   566
  file(GLOB POWER_SOURCES ${SDL2_SOURCE_DIR}/src/power/*.c)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   567
  set(SOURCE_FILES ${SOURCE_FILES} ${POWER_SOURCES})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   568
endif(SDL_POWER)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   569
# TODO: in configure.in, the test for LOADSO and SDL_DLOPEN is a bit weird:
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   570
# if LOADSO is not wanted, SDL_LOADSO_DISABLED is set
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   571
# If however on Unix or APPLE dlopen() is detected via CheckDLOPEN(),
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   572
# SDL_LOADSO_DISABLED will not be set, regardless of the LOADSO settings
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   573
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   574
# General SDL subsystem options, valid for all platforms
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   575
if(SDL_AUDIO)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   576
  # CheckDummyAudio/CheckDiskAudio - valid for all platforms
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   577
  if(DUMMYAUDIO)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   578
    set(SDL_AUDIO_DRIVER_DUMMY 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   579
    file(GLOB DUMMYAUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/dummy/*.c)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   580
    set(SOURCE_FILES ${SOURCE_FILES} ${DUMMYAUDIO_SOURCES})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   581
    set(HAVE_DUMMYAUDIO TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   582
  endif(DUMMYAUDIO)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   583
  if(DISKAUDIO)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   584
    set(SDL_AUDIO_DRIVER_DISK 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   585
    file(GLOB DISKAUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/disk/*.c)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   586
    set(SOURCE_FILES ${SOURCE_FILES} ${DISKAUDIO_SOURCES})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   587
    set(HAVE_DISKAUDIO TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   588
  endif(DISKAUDIO)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   589
endif(SDL_AUDIO)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   590
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   591
if(SDL_DLOPEN)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   592
  # Relevant for Unix/Darwin only
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   593
  if(UNIX OR APPLE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   594
    CheckDLOPEN()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   595
  endif(UNIX OR APPLE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   596
endif(SDL_DLOPEN)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   597
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   598
if(SDL_VIDEO)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   599
  if(VIDEO_DUMMY)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   600
    set(SDL_VIDEO_DRIVER_DUMMY 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   601
    file(GLOB VIDEO_DUMMY_SOURCES ${SDL2_SOURCE_DIR}/src/video/dummy/*.c)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   602
    set(SOURCE_FILES ${SOURCE_FILES} ${VIDEO_DUMMY_SOURCES})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   603
    set(HAVE_VIDEO_DUMMY TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   604
    set(HAVE_SDL_VIDEO TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   605
  endif(VIDEO_DUMMY)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   606
endif(SDL_VIDEO)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   607
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   608
# Platform-specific options and settings
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   609
if(UNIX AND NOT APPLE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   610
  if(SDL_AUDIO)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   611
    if(SYSV5 OR SOLARIS OR HPUX)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   612
        set(SDL_AUDIO_DRIVER_SUNAUDIO 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   613
        file(GLOB SUN_AUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/sun/*.c)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   614
        set(SOURCE_FILES ${SOURCE_FILES} ${SUN_AUDIO_SOURCES})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   615
        set(HAVE_SDL_AUDIO TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   616
    elseif(NETBSD OR OPENBSD)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   617
        set(SDL_AUDIO_DRIVER_BSD 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   618
        file(GLOB BSD_AUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/bsd/*.c)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   619
        set(SOURCE_FILES ${SOURCE_FILES} ${BSD_AUDIO_SOURCES})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   620
        set(HAVE_SDL_AUDIO TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   621
    elseif(AIX)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   622
        set(SDL_AUDIO_DRIVER_PAUDIO 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   623
        file(GLOB AIX_AUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/paudio/*.c)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   624
        set(SOURCE_FILES ${SOURCE_FILES} ${AIX_AUDIO_SOURCES})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   625
        set(HAVE_SDL_AUDIO TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   626
    endif()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   627
    CheckOSS()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   628
    CheckALSA()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   629
    CheckPulseAudio()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   630
    CheckESD()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   631
    CheckARTS()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   632
    CheckNAS()
7367
d6eabafa8776 Added an SDL2 OpenBSD sndio(7) audio target.
Ryan C. Gordon <icculus@icculus.org>
parents: 6774
diff changeset
   633
    CheckSNDIO()
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   634
    CheckFusionSound()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   635
  endif(SDL_AUDIO)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   636
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   637
  if(SDL_VIDEO)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   638
    CheckX11()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   639
    CheckDirectFB()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   640
    CheckOpenGLX11()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   641
    CheckOpenGLESX11()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   642
  endif(SDL_VIDEO)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   643
6729
fdaeea9e7567 Removed old Linux joystick API (/dev/js*).
Ryan C. Gordon <icculus@icculus.org>
parents: 6674
diff changeset
   644
  if(LINUX)
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   645
    check_c_source_compiles("
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   646
        #include <linux/input.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   647
        #ifndef EVIOCGNAME
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   648
        #error EVIOCGNAME() ioctl not available
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   649
        #endif
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   650
        int main(int argc, char** argv) {}" HAVE_INPUT_EVENTS)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   651
    if(HAVE_INPUT_EVENTS)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   652
      set(SDL_INPUT_LINUXEV 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   653
    endif(HAVE_INPUT_EVENTS)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   654
6729
fdaeea9e7567 Removed old Linux joystick API (/dev/js*).
Ryan C. Gordon <icculus@icculus.org>
parents: 6674
diff changeset
   655
    if(SDL_HAPTIC AND HAVE_INPUT_EVENTS)
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   656
      set(SDL_HAPTIC_LINUX 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   657
      file(GLOB HAPTIC_SOURCES ${SDL2_SOURCE_DIR}/src/haptic/linux/*.c)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   658
      set(SOURCE_FILES ${SOURCE_FILES} ${HAPTIC_SOURCES})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   659
      set(HAVE_SDL_HAPTIC TRUE)
6729
fdaeea9e7567 Removed old Linux joystick API (/dev/js*).
Ryan C. Gordon <icculus@icculus.org>
parents: 6674
diff changeset
   660
    endif(SDL_HAPTIC AND HAVE_INPUT_EVENTS)
6734
7fdaee2be782 Updated Linux joystick code to support hotplug, GUIDs, etc.
Ryan C. Gordon <icculus@icculus.org>
parents: 6729
diff changeset
   661
7fdaee2be782 Updated Linux joystick code to support hotplug, GUIDs, etc.
Ryan C. Gordon <icculus@icculus.org>
parents: 6729
diff changeset
   662
    check_include_file("libudev.h" HAVE_LIBUDEV_H)
6774
ad8522052ce6 Replaced Gnome screensaver hack with D-Bus messages to org.gnome.ScreenSaver.
Ryan C. Gordon <icculus@icculus.org>
parents: 6734
diff changeset
   663
ad8522052ce6 Replaced Gnome screensaver hack with D-Bus messages to org.gnome.ScreenSaver.
Ryan C. Gordon <icculus@icculus.org>
parents: 6734
diff changeset
   664
    # !!! FIXME: this needs pkg-config to find the include path, I think.
ad8522052ce6 Replaced Gnome screensaver hack with D-Bus messages to org.gnome.ScreenSaver.
Ryan C. Gordon <icculus@icculus.org>
parents: 6734
diff changeset
   665
    check_include_file("dbus/dbus.h" HAVE_DBUS_DBUS_H)
6734
7fdaee2be782 Updated Linux joystick code to support hotplug, GUIDs, etc.
Ryan C. Gordon <icculus@icculus.org>
parents: 6729
diff changeset
   666
  endif(LINUX)
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   667
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   668
  if(INPUT_TSLIB)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   669
    check_c_source_compiles("
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   670
        #include \"tslib.h\"
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   671
        int main(int argc, char** argv) { }" HAVE_INPUT_TSLIB)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   672
    if(HAVE_INPUT_TSLIB)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   673
      set(SDL_INPUT_TSLIB 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   674
      list(APPEND EXTRA_LIBS ts)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   675
    endif(HAVE_INPUT_TSLIB)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   676
  endif(INPUT_TSLIB)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   677
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   678
  if(SDL_JOYSTICK)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   679
    CheckUSBHID()   # seems to be BSD specific - limit the test to BSD only?
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   680
    if(LINUX)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   681
      set(SDL_JOYSTICK_LINUX 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   682
      file(GLOB JOYSTICK_SOURCES ${SDL2_SOURCE_DIR}/src/joystick/linux/*.c)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   683
      set(SOURCE_FILES ${SOURCE_FILES} ${JOYSTICK_SOURCES})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   684
      set(HAVE_SDL_JOYSTICK TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   685
    endif(LINUX)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   686
  endif(SDL_JOYSTICK)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   687
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   688
  CheckPTHREAD()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   689
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   690
  if(CLOCK_GETTIME)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   691
    check_library_exists(rt clock_gettime "" FOUND_CLOCK_GETTIME)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   692
    if(FOUND_CLOCK_GETTIME)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   693
      list(APPEND EXTRA_LIBS rt)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   694
      set(HAVE_CLOCK_GETTIME 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   695
    else(FOUND_CLOCK_GETTIME)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   696
      check_library_exists(c clock_gettime "" FOUND_CLOCK_GETTIME)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   697
      if(FOUND_CLOCK_GETTIME)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   698
        set(HAVE_CLOCK_GETTIME 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   699
      endif(FOUND_CLOCK_GETTIME)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   700
    endif(HAVE_CLOCK_GETTIME)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   701
  endif(CLOCK_GETTIME)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   702
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   703
  check_include_file(linux/version.h HAVE_LINUX_VERSION_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   704
  if(HAVE_LINUX_VERSION_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   705
    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DHAVE_LINUX_VERSION_H")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   706
  endif(HAVE_LINUX_VERSION_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   707
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   708
  if(SDL_POWER)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   709
    if(LINUX)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   710
      set(SDL_POWER_LINUX 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   711
      file(GLOB POWER_SOURCES ${SDL2_SOURCE_DIR}/src/power/linux/*.c)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   712
      set(SOURCE_FILES ${SOURCE_FILES} ${POWER_SOURCES})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   713
      set(HAVE_SDL_POWER TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   714
    endif(LINUX)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   715
  endif(SDL_POWER)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   716
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   717
  if(SDL_TIMERS)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   718
    set(SDL_TIMER_UNIX 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   719
    file(GLOB TIMER_SOURCES ${SDL2_SOURCE_DIR}/src/timer/unix/*.c)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   720
    set(SOURCE_FILES ${SOURCE_FILES} ${TIMER_SOURCES})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   721
    set(HAVE_SDL_TIMERS TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   722
  endif(SDL_TIMERS)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   723
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   724
  if(RPATH)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   725
    set(SDL_RLD_FLAGS "")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   726
    if(BSDI OR FREEBSD OR LINUX OR NETBSD)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   727
      set(SDL_RLD_FLAGS "-Wl,-rpath,\${libdir}")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   728
    elseif(SOLARIS)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   729
      set(SDL_RLD_FLAGS "-R\${libdir}")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   730
    endif()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   731
    set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   732
    set(HAVE_RPATH TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   733
  endif(RPATH)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   734
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   735
elseif(WINDOWS)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   736
  find_program(WINDRES windres)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   737
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   738
  check_c_source_compiles("
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   739
    #include <windows.h>
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   740
    int main(int argc, char **argv) { }" HAVE_WIN32_CC)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   741
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   742
  file(GLOB WIN_SOURCES ${SDL2_SOURCE_DIR}/src/core/windows/*.c)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   743
  set(SOURCE_FILES ${SOURCE_FILES} ${WIN_SOURCES})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   744
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   745
  # Check for DirectX
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   746
  if(DIRECTX)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   747
    if("$ENV{DXSDK_DIR}" STREQUAL "")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   748
      message_error("DIRECTX requires the \$DXSDK_DIR environment variable to be set")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   749
    endif("$ENV{DXSDK_DIR}" STREQUAL "")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   750
    set(CMAKE_REQUIRED_FLAGS "/I\"$ENV{DXSDK_DIR}\\Include\"")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   751
    check_include_file(d3d9.h HAVE_D3D_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   752
    check_include_file(ddraw.h HAVE_DDRAW_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   753
    check_include_file(dsound.h HAVE_DSOUND_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   754
    check_include_file(dinput.h HAVE_DINPUT_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   755
    check_include_file(xaudio2.h HAVE_XAUDIO2_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   756
    if(HAVE_D3D_H OR HAVE_DDRAW_H OR HAVE_DSOUND_H OR HAVE_DINPUT_H OR HAVE_XAUDIO2_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   757
      set(HAVE_DIRECTX TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   758
      # TODO: change $ENV{DXSDL_DIR} to get the path from the include checks
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   759
      link_directories($ENV{DXSDK_DIR}\\lib\\${PROCESSOR_ARCH})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   760
      include_directories($ENV{DXSDK_DIR}\\Include)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   761
    endif()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   762
    set(CMAKE_REQUIRED_FLAGS)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   763
  endif(DIRECTX)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   764
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   765
  if(SDL_AUDIO)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   766
    set(SDL_AUDIO_DRIVER_WINMM 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   767
    file(GLOB WINMM_AUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/winmm/*.c)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   768
    set(SOURCE_FILES ${SOURCE_FILES} ${WINMM_AUDIO_SOURCES})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   769
    set(HAVE_SDL_AUDIO TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   770
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   771
    if(HAVE_DSOUND_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   772
      set(SDL_AUDIO_DRIVER_DSOUND 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   773
      file(GLOB DSOUND_AUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/directsound/*.c)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   774
      set(SOURCE_FILES ${SOURCE_FILES} ${DSOUND_AUDIO_SOURCES})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   775
    endif(HAVE_DSOUND_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   776
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   777
    if(HAVE_XAUDIO2_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   778
      set(SDL_AUDIO_DRIVER_XAUDIO2 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   779
      file(GLOB XAUDIO2_AUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/xaudio2/*.c)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   780
      set(SOURCE_FILES ${SOURCE_FILES} ${XAUDIO2_AUDIO_SOURCES})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   781
    endif(HAVE_XAUDIO2_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   782
  endif(SDL_AUDIO)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   783
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   784
  if(SDL_VIDEO)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   785
    # requires SDL_LOADSO on Windows (IME, DX, etc.)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   786
    if(NOT SDL_LOADSO)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   787
      message_error("SDL_VIDEO requires SDL_LOADSO, which is not enabled")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   788
    endif(NOT SDL_LOADSO)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   789
    set(SDL_VIDEO_DRIVER_WINDOWS 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   790
    file(GLOB WIN_VIDEO_SOURCES ${SDL2_SOURCE_DIR}/src/video/windows/*.c)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   791
    set(SOURCE_FILES ${SOURCE_FILES} ${WIN_VIDEO_SOURCES})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   792
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   793
    if(RENDER_D3D AND HAVE_D3D_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   794
      set(SDL_VIDEO_RENDER_D3D 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   795
      set(HAVE_RENDER_D3D TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   796
    endif(RENDER_D3D AND HAVE_D3D_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   797
    set(HAVE_SDL_VIDEO TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   798
  endif(SDL_VIDEO)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   799
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   800
  if(SDL_THREADS)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   801
    set(SDL_THREAD_WINDOWS 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   802
    set(SOURCE_FILES ${SOURCE_FILES}
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   803
      ${SDL2_SOURCE_DIR}/src/thread/windows/SDL_sysmutex.c
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   804
      ${SDL2_SOURCE_DIR}/src/thread/windows/SDL_syssem.c
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   805
      ${SDL2_SOURCE_DIR}/src/thread/windows/SDL_systhread.c
7395
c1b80390a820 Added src/thread/windows/SDL_systls.c to CMakeLists.txt (thanks, Charles!).
Ryan C. Gordon <icculus@icculus.org>
parents: 7367
diff changeset
   806
      ${SDL2_SOURCE_DIR}/src/thread/windows/SDL_systls.c
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   807
      ${SDL2_SOURCE_DIR}/src/thread/generic/SDL_syscond.c)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   808
    set(HAVE_SDL_THREADS TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   809
  endif(SDL_THREADS)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   810
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   811
  if(SDL_POWER)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   812
    set(SDL_POWER_WINDOWS 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   813
    set(SOURCE_FILES ${SOURCE_FILES} ${SDL2_SOURCE_DIR}/src/power/windows/SDL_syspower.c)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   814
    set(HAVE_SDL_POWER TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   815
  endif(SDL_POWER)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   816
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   817
  # Libraries for Win32 native and MinGW
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   818
  list(APPEND EXTRA_LIBS user32 gdi32 winmm imm32 ole32 oleaut32 version uuid)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   819
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   820
  # TODO: in configure.in the check for timers is set on
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   821
  # cygwin | mingw32* - does this include mingw32CE?
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   822
  if(SDL_TIMERS)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   823
    set(SDL_TIMER_WINDOWS 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   824
    file(GLOB TIMER_SOURCES ${SDL2_SOURCE_DIR}/src/timer/windows/*.c)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   825
    set(SOURCE_FILES ${SOURCE_FILES} ${TIMER_SOURCES})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   826
    set(HAVE_SDL_TIMERS TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   827
  endif(SDL_TIMERS)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   828
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   829
  if(SDL_LOADSO)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   830
    set(SDL_LOADSO_WINDOWS 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   831
    file(GLOB LOADSO_SOURCES ${SDL2_SOURCE_DIR}/src/loadso/windows/*.c)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   832
    set(SOURCE_FILES ${SOURCE_FILES} ${LOADSO_SOURCES})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   833
    set(HAVE_SDL_LOADSO TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   834
  endif(SDL_LOADSO)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   835
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   836
  file(GLOB CORE_SOURCES ${SDL2_SOURCE_DIR}/src/core/windows/*.c)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   837
  set(SOURCE_FILES ${SOURCE_FILES} ${CORE_SOURCES})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   838
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   839
  if(SDL_VIDEO)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   840
    if(VIDEO_OPENGL)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   841
      set(SDL_VIDEO_OPENGL 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   842
      set(SDL_VIDEO_OPENGL_WGL 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   843
      set(SDL_VIDEO_RENDER_OGL 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   844
      set(HAVE_VIDEO_OPENGL TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   845
    endif(VIDEO_OPENGL)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   846
  endif(SDL_VIDEO)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   847
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   848
  if(SDL_JOYSTICK)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   849
    if(HAVE_DINPUT_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   850
      set(SDL_JOYSTICK_DINPUT 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   851
      set(SOURCE_FILES ${SOURCE_FILES} ${SDL2_SOURCE_DIR}/src/joystick/windows/SDL_dxjoystick.c)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   852
      list(APPEND EXTRA_LIBS dinput8 dxguid dxerr)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   853
    else()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   854
      set(SDL_JOYSTICK_WINMM 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   855
      set(SOURCE_FILES ${SOURCE_FILES} ${SDL2_SOURCE_DIR}/src/joystick/windows/SDL_mmjoystick.c)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   856
    endif(HAVE_DINPUT_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   857
    set(HAVE_SDL_JOYSTICK TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   858
  endif(SDL_JOYSTICK)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   859
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   860
  if(SDL_HAPTIC AND HAVE_DINPUT_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   861
    set(SDL_HAPTIC_DINPUT 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   862
    set(SOURCE_FILES ${SOURCE_FILES} ${SDL2_SOURCE_DIR}/src/haptic/windows/SDL_syshaptic.c)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   863
    set(HAVE_SDL_HAPTIC TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   864
  endif(SDL_HAPTIC AND HAVE_DINPUT_H)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   865
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   866
  file(GLOB VERSION_SOURCES ${SDL2_SOURCE_DIR}/src/main/windows/*.rc)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   867
  file(GLOB SDLMAIN_SOURCES ${SDL2_SOURCE_DIR}/src/main/windows/*.c)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   868
  if(MINGW OR CYGWIN)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   869
    list(APPEND EXTRA_LIBS mingw32)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   870
    list(APPEND EXTRA_LDFLAGS "-mwindows")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   871
    set(SDL_CFLAGS "${SDL_CFLAGS} -Dmain=SDL_main")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   872
    list(APPEND SDL_LIBS "-lmingw32" "-lSDL2main" "-mwindows")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   873
  endif(MINGW OR CYGWIN)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   874
elseif(APPLE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   875
  # TODO: rework this for proper MacOS X, iOS and Darwin support
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   876
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   877
  # Requires the darwin file implementation
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   878
  if(SDL_FILE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   879
    file(GLOB EXTRA_SOURCES ${PROJECT_SOURCE_DIR}/src/file/cocoa/*.m)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   880
    set(SOURCE_FILES ${EXTRA_SOURCES} ${SOURCE_FILES})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   881
    set_source_files_properties(${EXTRA_SOURCES} PROPERTIES LANGUAGE C)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   882
    set(HAVE_SDL_FILE TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   883
    set(SDL_FRAMEWORK_COCOA 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   884
  else()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   885
    message_error("SDL_FILE must be enabled to build on MacOS X")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   886
  endif()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   887
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   888
  if(SDL_AUDIO)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   889
    set(MACOSX_COREAUDIO 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   890
    file(GLOB AUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/coreaudio/*.c)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   891
    set(SOURCE_FILES ${SOURCE_FILES} ${AUDIO_SOURCES})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   892
    set(HAVE_SDL_AUDIO TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   893
    set(SDL_FRAMEWORK_COREAUDIO 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   894
    set(SDL_FRAMEWORK_AUDIOUNIT 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   895
  endif()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   896
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   897
  if(SDL_JOYSTICK)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   898
    set(SDL_JOYSTICK_IOKIT 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   899
    file(GLOB JOYSTICK_SOURCES ${SDL2_SOURCE_DIR}/src/joystick/darwin/*.c)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   900
    set(SOURCE_FILES ${SOURCE_FILES} ${JOYSTICK_SOURCES})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   901
    set(HAVE_SDL_JOYSTICK TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   902
    set(SDL_FRAMEWORK_IOKIT 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   903
    set(SDL_FRAMEWORK_FF 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   904
  endif()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   905
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   906
  if(SDL_HAPTIC)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   907
    set(SDL_HAPTIC_IOKIT 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   908
    file(GLOB HAPTIC_SOURCES ${SDL2_SOURCE_DIR}/src/haptic/darwin/*.c)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   909
    set(SOURCE_FILES ${SOURCE_FILES} ${HAPTIC_SOURCES})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   910
    set(HAVE_SDL_HAPTIC TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   911
    set(SDL_FRAMEWORK_IOKIT 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   912
    set(SDL_FRAMEWORK_FF 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   913
    if(NOT SDL_JOYSTICK)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   914
      message(FATAL_ERROR "SDL_HAPTIC requires SDL_JOYSTICK to be enabled")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   915
    endif()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   916
  endif()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   917
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   918
  if(SDL_POWER)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   919
    set(SDL_POWER_MACOSX 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   920
    file(GLOB POWER_SOURCES ${SDL2_SOURCE_DIR}/src/power/macosx/*.c)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   921
    set(SOURCE_FILES ${SOURCE_FILES} ${POWER_SOURCES})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   922
    set(HAVE_SDL_POWER TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   923
    set(SDL_FRAMEWORK_CARBON 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   924
    set(SDL_FRAMEWORK_IOKIT 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   925
  endif()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   926
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   927
  # Actually load the frameworks at the end so we don't duplicate include.
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   928
  if(SDL_FRAMEWORK_COCOA)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   929
    find_library(COCOA_LIBRARY Cocoa)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   930
    list(APPEND EXTRA_LIBS ${COCOA_LIBRARY})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   931
  endif()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   932
  if(SDL_FRAMEWORK_IOKIT)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   933
    find_library(IOKIT IOKit)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   934
    list(APPEND EXTRA_LIBS ${IOKIT})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   935
  endif()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   936
  if(SDL_FRAMEWORK_FF)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   937
    find_library(FORCEFEEDBACK ForceFeedback)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   938
    list(APPEND EXTRA_LIBS ${FORCEFEEDBACK})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   939
  endif()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   940
  if(SDL_FRAMEWORK_CARBON)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   941
    find_library(CARBON_LIBRARY Carbon)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   942
    list(APPEND EXTRA_LIBS ${CARBON_LIBRARY})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   943
  endif()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   944
  if(SDL_FRAMEWORK_COREAUDIO)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   945
    find_library(COREAUDIO CoreAudio)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   946
    list(APPEND EXTRA_LIBS ${COREAUDIO})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   947
  endif()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   948
  if(SDL_FRAMEWORK_AUDIOUNIT)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   949
    find_library(AUDIOUNIT AudioUnit)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   950
    list(APPEND EXTRA_LIBS ${AUDIOUNIT})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   951
  endif()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   952
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   953
  # iOS hack needed - http://code.google.com/p/ios-cmake/ ?
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   954
  if(SDL_VIDEO)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   955
    CheckCOCOA()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   956
    if(VIDEO_OPENGL)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   957
      set(SDL_VIDEO_OPENGL 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   958
      set(SDL_VIDEO_OPENGL_CGL 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   959
      set(SDL_VIDEO_RENDER_OGL 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   960
      if(DARWIN)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   961
        find_library(OpenGL_LIBRARY OpenGL)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   962
        list(APPEND EXTRA_LIBRARIES ${OpenGL_LIBRARY})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   963
      endif(DARWIN)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   964
      set(HAVE_VIDEO_OPENGL TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   965
    endif(VIDEO_OPENGL)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   966
  endif(SDL_VIDEO)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   967
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   968
  CheckPTHREAD()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   969
elseif(BEOS)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   970
  if(SDL_VIDEO)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   971
    set(SDL_VIDEO_DRIVER_BWINDOW 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   972
    file(GLOB BWINDOW_SOURCES ${SDL2_SOURCE_DIR}/src/video/bwindow/*.c)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   973
    set(SOURCE_FILES ${SOURCE_FILES} ${BWINDOW_SOURCES})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   974
    set(HAVE_SDL_VIDEO TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   975
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   976
    if(VIDEO_OPENGL)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   977
      # TODO: Use FIND_PACKAGE(OpenGL) instead
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   978
      set(SDL_VIDEO_OPENGL 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   979
      set(SDL_VIDEO_OPENGL_BGL 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   980
      set(SDL_VIDEO_RENDER_OGL 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   981
      list(APPEND EXTRA_LIBS GL)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   982
      set(HAVE_VIDEO_OPENGL TRUE)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   983
    endif(VIDEO_OPENGL)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   984
  endif(SDL_VIDEO)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   985
endif()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   986
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   987
# Dummies
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   988
# configure.in does it differently:
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   989
# if not have X
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   990
#   if enable_X {  SDL_X_DISABLED = 1 }
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   991
#   [add dummy sources]
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   992
# so it always adds a dummy, without checking, if it was actually requested.
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   993
# This leads to missing internal references on building, since the
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   994
# src/X/*.c does not get included.
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   995
if(NOT HAVE_SDL_JOYSTICK)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   996
  set(SDL_JOYSTICK_DISABLED 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   997
  if(SDL_JOYSTICK AND NOT APPLE) # results in unresolved symbols on OSX
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   998
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   999
    file(GLOB JOYSTICK_SOURCES ${SDL2_SOURCE_DIR}/src/joystick/dummy/*.c)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1000
    set(SOURCE_FILES ${SOURCE_FILES} ${JOYSTICK_SOURCES})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1001
  endif()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1002
endif(NOT HAVE_SDL_JOYSTICK)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1003
if(NOT HAVE_SDL_HAPTIC)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1004
  set(SDL_HAPTIC_DISABLED 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1005
  file(GLOB HAPTIC_SOURCES ${SDL2_SOURCE_DIR}/src/haptic/dummy/*.c)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1006
  set(SOURCE_FILES ${SOURCE_FILES} ${HAPTIC_SOURCES})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1007
endif(NOT HAVE_SDL_HAPTIC)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1008
if(NOT HAVE_SDL_LOADSO)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1009
  set(SDL_LOADSO_DISABLED 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1010
  file(GLOB LOADSO_SOURCES ${SDL2_SOURCE_DIR}/src/loadso/dummy/*.c)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1011
  set(SOURCE_FILES ${SOURCE_FILES} ${JOYSTICK_SOURCES})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1012
endif(NOT HAVE_SDL_LOADSO)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1013
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1014
# We always need to have threads and timers around
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1015
if(NOT HAVE_SDL_THREADS)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1016
  set(SDL_THREADS_DISABLED 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1017
  file(GLOB THREADS_SOURCES ${SDL2_SOURCE_DIR}/src/thread/generic/*.c)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1018
  set(SOURCE_FILES ${SOURCE_FILES} ${THREADS_SOURCES})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1019
endif(NOT HAVE_SDL_THREADS)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1020
if(NOT HAVE_SDL_TIMERS)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1021
  set(SDL_TIMERS_DISABLED 1)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1022
  file(GLOB TIMER_SOURCES ${SDL2_SOURCE_DIR}/src/timer/dummy/*.c)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1023
  set(SOURCE_FILES ${SOURCE_FILES} ${TIMER_SOURCES})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1024
endif(NOT HAVE_SDL_TIMERS)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1025
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1026
if(NOT SDLMAIN_SOURCES)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1027
  file(GLOB SDLMAIN_SOURCES ${SDL2_SOURCE_DIR}/src/main/dummy/*.c)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1028
endif(NOT SDLMAIN_SOURCES)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1029
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1030
# Append the -MMD -MT flags
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1031
# if(DEPENDENCY_TRACKING)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1032
#   if(COMPILER_IS_GNUCC)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1033
#     set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -MMD -MT \$@")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1034
#   endif(COMPILER_IS_GNUCC)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1035
# endif(DEPENDENCY_TRACKING)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1036
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1037
configure_file("${SDL2_SOURCE_DIR}/include/SDL_config.h.cmake"
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1038
  "${SDL2_BINARY_DIR}/include/SDL_config.h")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1039
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1040
# Prepare the flags and remove duplicates
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1041
if(EXTRA_LDFLAGS)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1042
  list(REMOVE_DUPLICATES EXTRA_LDFLAGS)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1043
endif(EXTRA_LDFLAGS)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1044
if(EXTRA_LIBS)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1045
  list(REMOVE_DUPLICATES EXTRA_LIBS)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1046
endif(EXTRA_LIBS)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1047
if(EXTRA_CFLAGS)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1048
  list(REMOVE_DUPLICATES EXTRA_CFLAGS)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1049
endif(EXTRA_CFLAGS)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1050
listtostr(EXTRA_CFLAGS _EXTRA_CFLAGS)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1051
set(EXTRA_CFLAGS ${_EXTRA_CFLAGS})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1052
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1053
# Compat helpers for the configuration files
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1054
if(NOT WINDOWS OR CYGWIN)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1055
  # TODO: we need a Windows script, too
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1056
  execute_process(COMMAND sh ${SDL2_SOURCE_DIR}/build-scripts/updaterev.sh)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1057
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1058
  set(prefix ${CMAKE_INSTALL_PREFIX})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1059
  set(exec_prefix "\${prefix}")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1060
  set(libdir "\${exec_prefix}/lib${LIB_SUFFIX}")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1061
  set(bindir "\${exec_prefix}/bin")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1062
  set(includedir "\${prefix}/include")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1063
  if(SDL_STATIC)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1064
    set(ENABLE_STATIC_TRUE "")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1065
    set(ENABLE_STATIC_FALSE "#")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1066
  else(SDL_STATIC)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1067
    set(ENABLE_STATIC_TRUE "#")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1068
    set(ENABLE_STATIC_FALSE "")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1069
  endif(SDL_STATIC)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1070
  if(SDL_SHARED)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1071
    set(ENABLE_SHARED_TRUE "")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1072
    set(ENABLE_SHARED_FALSE "#")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1073
  else(SDL_SHARED)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1074
    set(ENABLE_SHARED_TRUE "#")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1075
    set(ENABLE_SHARED_FALSE "")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1076
  endif(SDL_SHARED)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1077
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1078
  # Clean up the different lists
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1079
  listtostr(EXTRA_LIBS _EXTRA_LIBS "-l")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1080
  set(SDL_STATIC_LIBS ${SDL_LIBS} ${EXTRA_LDFLAGS} ${_EXTRA_LIBS})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1081
  list(REMOVE_DUPLICATES SDL_STATIC_LIBS)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1082
  listtostr(SDL_STATIC_LIBS _SDL_STATIC_LIBS)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1083
  set(SDL_STATIC_LIBS ${_SDL_STATIC_LIBS})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1084
  listtostr(SDL_LIBS _SDL_LIBS)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1085
  set(SDL_LIBS ${_SDL_LIBS})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1086
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1087
  # MESSAGE(STATUS "SDL_LIBS: ${SDL_LIBS}")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1088
  # MESSAGE(STATUS "SDL_STATIC_LIBS: ${SDL_STATIC_LIBS}")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1089
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1090
  configure_file("${SDL2_SOURCE_DIR}/sdl2.pc.in"
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1091
    "${SDL2_BINARY_DIR}/sdl2.pc" @ONLY)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1092
  configure_file("${SDL2_SOURCE_DIR}/sdl2-config.in"
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1093
    "${SDL2_BINARY_DIR}/sdl2-config")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1094
  configure_file("${SDL2_SOURCE_DIR}/sdl2-config.in"
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1095
    "${SDL2_BINARY_DIR}/sdl2-config" @ONLY)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1096
  configure_file("${SDL2_SOURCE_DIR}/SDL2.spec.in"
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1097
    "${SDL2_BINARY_DIR}/SDL2.spec" @ONLY)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1098
endif(NOT WINDOWS OR CYGWIN)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1099
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1100
##### Info output #####
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1101
message(STATUS "")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1102
message(STATUS "SDL2 was configured with the following options:")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1103
message(STATUS "")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1104
message(STATUS "Platform: ${CMAKE_SYSTEM}")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1105
message(STATUS "64-bit:   ${ARCH_64}")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1106
message(STATUS "Compiler: ${CMAKE_C_COMPILER}")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1107
message(STATUS "")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1108
message(STATUS "Subsystems:")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1109
foreach(_SUB ${SDL_SUBSYSTEMS})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1110
  string(TOUPPER ${_SUB} _OPT)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1111
  message_bool_option(${_SUB} SDL_${_OPT})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1112
endforeach()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1113
message(STATUS "")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1114
message(STATUS "Options:")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1115
list(SORT ALLOPTIONS)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1116
foreach(_OPT ${ALLOPTIONS})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1117
  # Longest option is VIDEO_X11_XSCREENSAVER = 22 characters
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1118
  # Get the padding
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1119
  string(LENGTH ${_OPT} _OPTLEN)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1120
  math(EXPR _PADLEN "23 - ${_OPTLEN}")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1121
  string(RANDOM LENGTH ${_PADLEN} ALPHABET " " _PADDING)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1122
  message_tested_option(${_OPT} ${_PADDING})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1123
endforeach()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1124
message(STATUS "")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1125
message(STATUS " CFLAGS:        ${CMAKE_C_FLAGS}")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1126
message(STATUS " EXTRA_CFLAGS:  ${EXTRA_CFLAGS}")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1127
message(STATUS " EXTRA_LDFLAGS: ${EXTRA_LDFLAGS}")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1128
message(STATUS " EXTRA_LIBS:    ${EXTRA_LIBS}")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1129
message(STATUS "")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1130
message(STATUS " Build Shared Library: ${SDL_SHARED}")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1131
message(STATUS " Build Static Library: ${SDL_STATIC}")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1132
message(STATUS "")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1133
if(UNIX)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1134
  message(STATUS "Something was not detected, although your are sure that it")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1135
  message(STATUS "has been properly installed? Then make sure, you have set")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1136
  message(STATUS "the CFLAGS and LDFLAGS environment variables correctly.")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1137
  message(STATUS "")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1138
endif(UNIX)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1139
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1140
# Ensure that the extra cflags are used at compile time
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1141
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1142
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1143
# Always build SDLmain
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1144
add_library(SDL2main STATIC ${SDLMAIN_SOURCES})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1145
set(_INSTALL_LIBS "SDL2main")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1146
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1147
if(SDL_SHARED)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1148
  add_library(SDL2 SHARED ${SOURCE_FILES})
7525
e5ae3502a25e Fixed bug 1743 - CMake produces libraries with wrong filename/SONAME
Sam Lantinga <slouken@libsdl.org>
parents: 7427
diff changeset
  1149
  if(UNIX)
e5ae3502a25e Fixed bug 1743 - CMake produces libraries with wrong filename/SONAME
Sam Lantinga <slouken@libsdl.org>
parents: 7427
diff changeset
  1150
    set_target_properties(SDL2 PROPERTIES
e5ae3502a25e Fixed bug 1743 - CMake produces libraries with wrong filename/SONAME
Sam Lantinga <slouken@libsdl.org>
parents: 7427
diff changeset
  1151
      VERSION ${LT_VERSION}
e5ae3502a25e Fixed bug 1743 - CMake produces libraries with wrong filename/SONAME
Sam Lantinga <slouken@libsdl.org>
parents: 7427
diff changeset
  1152
      SOVERSION ${LT_CURRENT}
e5ae3502a25e Fixed bug 1743 - CMake produces libraries with wrong filename/SONAME
Sam Lantinga <slouken@libsdl.org>
parents: 7427
diff changeset
  1153
      OUTPUT_NAME "SDL2-${LT_RELEASE}")
e5ae3502a25e Fixed bug 1743 - CMake produces libraries with wrong filename/SONAME
Sam Lantinga <slouken@libsdl.org>
parents: 7427
diff changeset
  1154
  else(UNIX)
e5ae3502a25e Fixed bug 1743 - CMake produces libraries with wrong filename/SONAME
Sam Lantinga <slouken@libsdl.org>
parents: 7427
diff changeset
  1155
    set_target_properties(SDL2 PROPERTIES
e5ae3502a25e Fixed bug 1743 - CMake produces libraries with wrong filename/SONAME
Sam Lantinga <slouken@libsdl.org>
parents: 7427
diff changeset
  1156
      VERSION ${SDL_VERSION}
e5ae3502a25e Fixed bug 1743 - CMake produces libraries with wrong filename/SONAME
Sam Lantinga <slouken@libsdl.org>
parents: 7427
diff changeset
  1157
      SOVERSION ${LT_CURRENT}
e5ae3502a25e Fixed bug 1743 - CMake produces libraries with wrong filename/SONAME
Sam Lantinga <slouken@libsdl.org>
parents: 7427
diff changeset
  1158
      OUTPUT_NAME "SDL2")
e5ae3502a25e Fixed bug 1743 - CMake produces libraries with wrong filename/SONAME
Sam Lantinga <slouken@libsdl.org>
parents: 7427
diff changeset
  1159
  endif(UNIX)
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1160
 set(_INSTALL_LIBS "SDL2" ${_INSTALL_LIBS})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1161
 target_link_libraries(SDL2 ${EXTRA_LIBS} ${EXTRA_LDFLAGS})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1162
endif(SDL_SHARED)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1163
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1164
if(SDL_STATIC)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1165
  add_library(SDL2-static STATIC ${SOURCE_FILES})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1166
  set_target_properties(SDL2-static PROPERTIES OUTPUT_NAME "SDL2")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1167
  # TODO: Win32 platforms keep the same suffix .lib for import and static
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1168
  # libraries - do we need to consider this?
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1169
  set(_INSTALL_LIBS "SDL2-static" ${_INSTALL_LIBS})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1170
  target_link_libraries(SDL2-static ${EXTRA_LIBS} ${EXTRA_LDFLAGS})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1171
endif(SDL_STATIC)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1172
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1173
##### Installation targets #####
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1174
install(TARGETS ${_INSTALL_LIBS}
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1175
  LIBRARY DESTINATION "lib${LIB_SUFFIX}"
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1176
  ARCHIVE DESTINATION "lib${LIB_SUFFIX}")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1177
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1178
file(GLOB INCLUDE_FILES ${SDL2_SOURCE_DIR}/include/*.h)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1179
file(GLOB BIN_INCLUDE_FILES ${SDL2_BINARY_DIR}/include/*.h)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1180
foreach(_FNAME ${BIN_INCLUDE_FILES})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1181
  get_filename_component(_INCNAME ${_FNAME} NAME)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1182
  list(REMOVE_ITEM INCLUDE_FILES ${SDL2_SOURCE_DIR}/include/${_INCNAME})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1183
endforeach()
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1184
list(APPEND INCLUDE_FILES ${BIN_INCLUDE_FILES})
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1185
install(FILES ${INCLUDE_FILES} DESTINATION include/SDL2)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1186
7525
e5ae3502a25e Fixed bug 1743 - CMake produces libraries with wrong filename/SONAME
Sam Lantinga <slouken@libsdl.org>
parents: 7427
diff changeset
  1187
if(SDL_SHARED)
e5ae3502a25e Fixed bug 1743 - CMake produces libraries with wrong filename/SONAME
Sam Lantinga <slouken@libsdl.org>
parents: 7427
diff changeset
  1188
  install(CODE "
e5ae3502a25e Fixed bug 1743 - CMake produces libraries with wrong filename/SONAME
Sam Lantinga <slouken@libsdl.org>
parents: 7427
diff changeset
  1189
    execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink
e5ae3502a25e Fixed bug 1743 - CMake produces libraries with wrong filename/SONAME
Sam Lantinga <slouken@libsdl.org>
parents: 7427
diff changeset
  1190
    \"libSDL2-2.0.so\" \"libSDL2.so\")")
e5ae3502a25e Fixed bug 1743 - CMake produces libraries with wrong filename/SONAME
Sam Lantinga <slouken@libsdl.org>
parents: 7427
diff changeset
  1191
  install(FILES ${SDL2_BINARY_DIR}/libSDL2.so DESTINATION "lib${LIB_SUFFIX}")
e5ae3502a25e Fixed bug 1743 - CMake produces libraries with wrong filename/SONAME
Sam Lantinga <slouken@libsdl.org>
parents: 7427
diff changeset
  1192
endif(SDL_SHARED)
e5ae3502a25e Fixed bug 1743 - CMake produces libraries with wrong filename/SONAME
Sam Lantinga <slouken@libsdl.org>
parents: 7427
diff changeset
  1193
6674
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1194
if(NOT WINDOWS OR CYGWIN)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1195
  if(FREEBSD)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1196
    # FreeBSD uses ${PREFIX}/libdata/pkgconfig
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1197
    install(FILES ${SDL2_BINARY_DIR}/sdl2.pc DESTINATION "libdata/pkgconfig")
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
  1198
  else(FREEBSD)
45a21e50ba5e Adds CMake build system by Marcus Von Appen (bug #1597)
Gabriel Jacobo <gabomdq@gmai