Adds CMake build system by Marcus Von Appen (bug #1597)
authorGabriel Jacobo <gabomdq@gmail.com>
Fri, 16 Nov 2012 09:23:18 -0300
changeset 667445a21e50ba5e
parent 6673 78f18a929123
child 6675 20f3cdea0fd2
Adds CMake build system by Marcus Von Appen (bug #1597)
CMakeLists.txt
README.cmake
cmake/macros.cmake
cmake/sdlchecks.cmake
include/SDL_config.h.cmake
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/CMakeLists.txt	Fri Nov 16 09:23:18 2012 -0300
     1.3 @@ -0,0 +1,1176 @@
     1.4 +if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
     1.5 +  message(FATAL_ERROR "Prevented in-tree built. Please create a build directory outside of the SDL source code and call cmake from there")
     1.6 +endif()
     1.7 +
     1.8 +cmake_minimum_required(VERSION 2.6)
     1.9 +project(SDL2 C)
    1.10 +include(CheckFunctionExists)
    1.11 +include(CheckLibraryExists)
    1.12 +include(CheckIncludeFiles)
    1.13 +include(CheckIncludeFile)
    1.14 +include(CheckSymbolExists)
    1.15 +include(CheckCSourceRuns)
    1.16 +include(CheckCCompilerFlag)
    1.17 +include(CheckTypeSize)
    1.18 +include(CheckStructHasMember)
    1.19 +include(CMakeDependentOption)
    1.20 +include(FindPkgConfig)
    1.21 +set(CMAKE_MODULE_PATH "${SDL2_SOURCE_DIR}/cmake")
    1.22 +include(${SDL2_SOURCE_DIR}/cmake/macros.cmake)
    1.23 +include(${SDL2_SOURCE_DIR}/cmake/sdlchecks.cmake)
    1.24 +
    1.25 +# General settings
    1.26 +# Edit include/SDL_version.h and change the version, then:
    1.27 +#   SDL_MICRO_VERSION += 1;
    1.28 +#   SDL_INTERFACE_AGE += 1;
    1.29 +#   SDL_BINARY_AGE += 1;
    1.30 +# if any functions have been added, set SDL_INTERFACE_AGE to 0.
    1.31 +# if backwards compatibility has been broken,
    1.32 +# set SDL_BINARY_AGE and SDL_INTERFACE_AGE to 0.
    1.33 +set(SDL_MAJOR_VERSION 2)
    1.34 +set(SDL_MINOR_VERSION 0)
    1.35 +set(SDL_MICRO_VERSION 0)
    1.36 +set(SDL_INTERFACE_AGE 0)
    1.37 +set(SDL_BINARY_AGE 0)
    1.38 +set(SDL_VERSION "${SDL_MAJOR_VERSION}.${SDL_MINOR_VERSION}.${SDL_MICRO_VERSION}")
    1.39 +
    1.40 +# Calculate a libtool-like version number
    1.41 +math(EXPR LT_CURRENT "${SDL_MICRO_VERSION} - ${SDL_INTERFACE_AGE}")
    1.42 +math(EXPR LT_AGE "${SDL_BINARY_AGE} - ${SDL_INTERFACE_AGE}")
    1.43 +set(LT_REVISION "${SDL_INTERFACE_AGE}")
    1.44 +
    1.45 +# General settings & flags
    1.46 +set(LIBRARY_OUTPUT_DIRECTORY "build")
    1.47 +# Check for 64 or 32 bit
    1.48 +set(SIZEOF_VOIDP ${CMAKE_SIZEOF_VOID_P})
    1.49 +if(CMAKE_SIZEOF_VOID_P EQUAL 8)
    1.50 +  set(ARCH_64 TRUE)
    1.51 +  set(PROCESSOR_ARCH "x64")
    1.52 +else()
    1.53 +  set(ARCH_64 FALSE)
    1.54 +  set(PROCESSOR_ARCH "x86")
    1.55 +endif(CMAKE_SIZEOF_VOID_P EQUAL 8)
    1.56 +set(LIBNAME SDL2)
    1.57 +if(NOT LIBTYPE)
    1.58 +  set(LIBTYPE SHARED)
    1.59 +endif(NOT LIBTYPE)
    1.60 +
    1.61 +# Get the platform
    1.62 +if(WIN32)
    1.63 +  if(NOT WINDOWS)
    1.64 +    set(WINDOWS TRUE)
    1.65 +  endif(NOT WINDOWS)
    1.66 +elseif(UNIX AND NOT APPLE)
    1.67 +  if(CMAKE_SYSTEM_NAME MATCHES ".*Linux")
    1.68 +    set(LINUX TRUE)
    1.69 +  elseif(CMAKE_SYSTEM_NAME MATCHES "kFreeBSD.*")
    1.70 +    set(FREEBSD TRUE)
    1.71 +  elseif(CMAKE_SYSTEM_NAME MATCHES "kNetBSD.*|NetBSD.*")
    1.72 +    set(NETBSD TRUE)
    1.73 +  elseif(CMAKE_SYSTEM_NAME MATCHES "kOpenBSD.*|OpenBSD.*")
    1.74 +    set(OPENBSD TRUE)
    1.75 +  elseif(CMAKE_SYSTEM_NAME MATCHES ".*GNU.*")
    1.76 +    set(GNU TRUE)
    1.77 +  elseif(CMAKE_SYSTEM_NAME MATCHES ".*BSDI.*")
    1.78 +    set(BSDI TRUE)
    1.79 +  elseif(CMAKE_SYSTEM_NAME MATCHES "DragonFly.*|FreeBSD")
    1.80 +    set(FREEBSD TRUE)
    1.81 +  elseif(CMAKE_SYSTEM_NAME MATCHES "SYSV5.*")
    1.82 +    set(SYSV5 TRUE)
    1.83 +  elseif(CMAKE_SYSTEM_NAME MATCHES "Solaris.*")
    1.84 +    set(SOLARIS TRUE)
    1.85 +  elseif(CMAKE_SYSTEM_NAME MATCHES "HP-UX.*")
    1.86 +    set(HPUX TRUE)
    1.87 +  elseif(CMAKE_SYSTEM_NAME MATCHES "AIX.*")
    1.88 +    set(AIX TRUE)
    1.89 +  elseif(CMAKE_SYSTEM_NAME MATCHES "Minix.*")
    1.90 +    set(MINIX TRUE)
    1.91 +  endif()
    1.92 +elseif(APPLE)
    1.93 +  if(CMAKE_SYSTEM_NAME MATCHES ".*Darwin.*")
    1.94 +    set(DARWIN TRUE)
    1.95 +  elseif(CMAKE_SYSTEM_NAME MATCHES ".*MacOS.*")
    1.96 +    set(MACOSX TRUE)
    1.97 +  endif()
    1.98 +  # TODO: iOS?
    1.99 +elseif(CMAKE_SYSTEM_NAME MATCHES "Haiku.*|BeOS.*")
   1.100 +  set(BEOS TRUE)
   1.101 +endif()
   1.102 +
   1.103 +# Don't mistake osx for unix
   1.104 +if(UNIX AND NOT APPLE)
   1.105 +  set(UNIX_SYS ON)
   1.106 +else()
   1.107 +  set(UNIX_SYS OFF)
   1.108 +endif(UNIX AND NOT APPLE)
   1.109 +
   1.110 +# Default option knobs
   1.111 +if(APPLE OR ARCH_64)
   1.112 +  set(OPT_DEF_SSEMATH ON)
   1.113 +endif()
   1.114 +if(UNIX OR MINGW OR MSYS)
   1.115 +  set(OPT_DEF_LIBC ON)
   1.116 +endif(UNIX OR MINGW OR MSYS)
   1.117 +
   1.118 +# Compiler info
   1.119 +if(CMAKE_COMPILER_IS_GNUCC)
   1.120 +  set(USE_GCC TRUE)
   1.121 +  set(OPT_DEF_ASM TRUE)
   1.122 +elseif(CMAKE_C_COMPILER_ID MATCHES "Clang")
   1.123 +  set(USE_CLANG TRUE)
   1.124 +  set(OPT_DEF_ASM TRUE)
   1.125 +elseif(MSVC_VERSION GREATER 1400) # VisualStudio 8.0+
   1.126 +  set(OPT_DEF_ASM TRUE)
   1.127 +  #set(CMAKE_C_FLAGS "/ZI /WX- /
   1.128 +else()
   1.129 +  set(OPT_DEF_ASM FALSE)
   1.130 +endif(CMAKE_COMPILER_IS_GNUCC)
   1.131 +
   1.132 +# Default flags, if not set otherwise
   1.133 +if("$ENV{CFLAGS}" STREQUAL "")
   1.134 +  if(USE_GCC OR USE_CLANG)
   1.135 +    set(CMAKE_C_FLAGS "-g -O3")
   1.136 +  endif(USE_GCC OR USE_CLANG)
   1.137 +else("$ENV{CFLAGS}" STREQUAL "")
   1.138 +  set(CMAKE_C_FLAGS "$ENV{CFLAGS}")
   1.139 +  list(APPEND EXTRA_CFLAGS "$ENV{CFLAGS}")
   1.140 +endif("$ENV{CFLAGS}" STREQUAL "")
   1.141 +if(NOT ("$ENV{CFLAGS}" STREQUAL "")) # Hackish, but does the trick on Win32
   1.142 +  list(APPEND EXTRA_LDFLAGS "$ENV{LDFLAGS}")
   1.143 +endif(NOT ("$ENV{CFLAGS}" STREQUAL ""))
   1.144 +
   1.145 +# Those are used for pkg-config and friends, so that the SDL2.pc, sdl2-config,
   1.146 +# etc. are created correctly.
   1.147 +set(SDL_LIBS "-lSDL2")
   1.148 +set(SDL_CFLAGS "")
   1.149 +
   1.150 +if(CYGWIN)
   1.151 +  # We build SDL on cygwin without the UNIX emulation layer
   1.152 +  include_directories("-I/usr/include/mingw")
   1.153 +  set(CMAKE_REQUIRED_FLAGS "-mno-cygwin")
   1.154 +  check_c_source_compiles("int main(int argc, char **argv) {}"
   1.155 +    HAVE_GCC_NO_CYGWIN)
   1.156 +  set(CMAKE_REQUIRED_FLAGS)
   1.157 +  if(HAVE_GCC_NO_CYGWIN)
   1.158 +    list(APPEND EXTRA_LDFLAGS "-mno-cygwin")
   1.159 +    list(APPEND SDL_LIBS "-mno-cygwin")
   1.160 +  endif(HAVE_GCC_NO_CYGWIN)
   1.161 +  set(SDL_CFLAGS "${SDL_CFLAGS} -I/usr/include/mingw")
   1.162 +endif(CYGWIN)
   1.163 +
   1.164 +add_definitions(-DUSING_GENERATED_CONFIG_H)
   1.165 +# General includes
   1.166 +include_directories(${SDL2_BINARY_DIR}/include ${SDL2_SOURCE_DIR}/include)
   1.167 +
   1.168 +set(SDL_SUBSYSTEMS
   1.169 +    Atomic Audio Video Render Events Joystick Haptic Power Threads Timers
   1.170 +    File Loadso CPUinfo)
   1.171 +foreach(_SUB ${SDL_SUBSYSTEMS})
   1.172 +  string(TOUPPER ${_SUB} _OPT)
   1.173 +  option(SDL_${_OPT} "Enable the ${_SUB} subsystem" ON)
   1.174 +endforeach()
   1.175 +
   1.176 +option_string(ASSERTIONS "Enable internal sanity checks (auto/disabled/release/enabled/paranoid)" "auto")
   1.177 +#set_option(DEPENDENCY_TRACKING "Use gcc -MMD -MT dependency tracking" ON)
   1.178 +set_option(LIBC                "Use the system C library" ${OPT_DEF_LIBC})
   1.179 +set_option(GCC_ATOMICS         "Use gcc builtin atomics" ${USE_GCC})
   1.180 +set_option(ASSEMBLY            "Enable assembly routines" ${OPT_DEF_ASM})
   1.181 +set_option(SSEMATH             "Allow GCC to use SSE floating point math" ${OPT_DEF_SSEMATH})
   1.182 +set_option(MMX                 "Use MMX assembly routines" ${OPT_DEF_ASM})
   1.183 +set_option(3DNOW               "Use 3Dnow! MMX assembly routines" ${OPT_DEF_ASM})
   1.184 +set_option(SSE                 "Use SSE assembly routines" ${OPT_DEF_ASM})
   1.185 +set_option(SSE2                "Use SSE2 assembly routines" ${OPT_DEF_SSEMATH})
   1.186 +set_option(ALTIVEC             "Use Altivec assembly routines" ${OPT_DEF_ASM})
   1.187 +set_option(DISKAUDIO           "Support the disk writer audio driver" ON)
   1.188 +set_option(DUMMYAUDIO          "Support the dummy audio driver" ON)
   1.189 +set_option(VIDEO_DIRECTFB      "Use DirectFB video driver" OFF)
   1.190 +dep_option(DIRECTFB_SHARED     "Dynamically load directfb support" ON "VIDEO_DIRECTFB" OFF)
   1.191 +set_option(FUSIONSOUND         "Use FusionSound audio driver" OFF)
   1.192 +dep_option(FUSIONSOUND_SHARED  "Dynamically load fusionsound audio support" ON "FUSIONSOUND_SHARED" OFF)
   1.193 +set_option(VIDEO_DUMMY         "Use dummy video driver" ON)
   1.194 +set_option(VIDEO_OPENGL        "Include OpenGL support" ON)
   1.195 +set_option(VIDEO_OPENGLES      "Include OpenGL ES support" ON)
   1.196 +set_option(PTHREADS            "Use POSIX threads for multi-threading" ${UNIX_SYS})
   1.197 +dep_option(PTHREADS_SEM        "Use pthread semaphores" ON "PTHREADS" OFF)
   1.198 +set_option(SDL_DLOPEN          "Use dlopen for shared object loading" ON)
   1.199 +set_option(OSS                 "Support the OSS audio API" ${UNIX_SYS})
   1.200 +set_option(ALSA                "Support the ALSA audio API" ${UNIX_SYS})
   1.201 +dep_option(ALSA_SHARED         "Dynamically load ALSA audio support" ON "ALSA" OFF)
   1.202 +set_option(ESD                 "Support the Enlightened Sound Daemon" ${UNIX_SYS})
   1.203 +dep_option(ESD_SHARED          "Dynamically load ESD audio support" ON "ESD" OFF)
   1.204 +set_option(PULSEAUDIO          "Use PulseAudio" ${UNIX_SYS})
   1.205 +dep_option(PULSEAUDIO_SHARED   "Dynamically load PulseAudio support" ON "PULSEAUDIO" OFF)
   1.206 +set_option(ARTS                "Support the Analog Real Time Synthesizer" ${UNIX_SYS})
   1.207 +dep_option(ARTS_SHARED         "Dynamically load aRts audio support" ON "ARTS" OFF)
   1.208 +set_option(NAS                 "Support the NAS audio API" ${UNIX_SYS})
   1.209 +set_option(RPATH               "Use an rpath when linking SDL" ${UNIX_SYS})
   1.210 +set_option(CLOCK_GETTIME       "Use clock_gettime() instead of gettimeofday()" OFF)
   1.211 +set_option(INPUT_EVENTS        "Use Linux 2.4 unified input interface" ${LINUX})
   1.212 +set_option(INPUT_TSLIB         "Use the Touchscreen library for input" ${UNIX_SYS})
   1.213 +set_option(VIDEO_X11           "Use X11 video driver" ${UNIX_SYS})
   1.214 +dep_option(X11_SHARED          "Dynamically load X11 support" ON "VIDEO_X11" OFF)
   1.215 +set(SDL_X11_OPTIONS Xcursor Xinerama XInput Xrandr Xscrnsaver XShape Xvm)
   1.216 +foreach(_SUB ${SDL_X11_OPTIONS})
   1.217 +  string(TOUPPER "VIDEO_X11_${_SUB}" _OPT)
   1.218 +  dep_option(${_OPT}           "Enable ${_SUB} support" ON "VIDEO_X11" OFF)
   1.219 +endforeach()
   1.220 +set_option(VIDEO_COCOA         "Use Cocoa video driver" ${APPLE})
   1.221 +set_option(DIRECTX             "Use DirectX for Windows audio/video" ${WINDOWS})
   1.222 +set_option(RENDER_D3D          "Enable the Direct3D render driver" ${WINDOWS})
   1.223 +
   1.224 +# TODO: We should (should we?) respect cmake's ${BUILD_SHARED_LIBS} flag here
   1.225 +# The options below are for compatibility to configure's default behaviour.
   1.226 +set(SDL_SHARED ON CACHE BOOL "Build a shared version of the library")
   1.227 +set(SDL_STATIC ON CACHE BOOL "Build a static version of the library")
   1.228 +
   1.229 +# General source files
   1.230 +file(GLOB SOURCE_FILES
   1.231 +  ${SDL2_SOURCE_DIR}/src/*.c
   1.232 +  ${SDL2_SOURCE_DIR}/src/atomic/*.c
   1.233 +  ${SDL2_SOURCE_DIR}/src/audio/*.c
   1.234 +  ${SDL2_SOURCE_DIR}/src/cpuinfo/*.c
   1.235 +  ${SDL2_SOURCE_DIR}/src/events/*.c
   1.236 +  ${SDL2_SOURCE_DIR}/src/file/*.c
   1.237 +  ${SDL2_SOURCE_DIR}/src/libm/*.c
   1.238 +  ${SDL2_SOURCE_DIR}/src/render/*.c
   1.239 +  ${SDL2_SOURCE_DIR}/src/render/*/*.c
   1.240 +  ${SDL2_SOURCE_DIR}/src/stdlib/*.c
   1.241 +  ${SDL2_SOURCE_DIR}/src/thread/*.c
   1.242 +  ${SDL2_SOURCE_DIR}/src/timer/*.c
   1.243 +  ${SDL2_SOURCE_DIR}/src/video/*.c)
   1.244 +
   1.245 +
   1.246 +if(ASSERTIONS STREQUAL "auto")
   1.247 +  # Do nada - use optimization settings to determine the assertion level
   1.248 +elseif(ASSERTIONS STREQUAL "disabled")
   1.249 +  set(SDL_DEFAULT_ASSERT_LEVEL 0)
   1.250 +elseif(ASSERTIONS STREQUAL "release")
   1.251 +  set(SDL_DEFAULT_ASSERT_LEVEL 1)
   1.252 +elseif(ASSERTIONS STREQUAL "enabled")
   1.253 +  set(SDL_DEFAULT_ASSERT_LEVEL 2)
   1.254 +elseif(ASSERTIONS STREQUAL "paranoid")
   1.255 +  set(SDL_DEFAULT_ASSERT_LEVEL 3)
   1.256 +else()
   1.257 +  message_error("unknown assertion level")
   1.258 +endif(ASSERTIONS STREQUAL "auto")
   1.259 +set(HAVE_ASSERTIONS ${ASSERTIONS})
   1.260 +
   1.261 +# Compiler option evaluation
   1.262 +if(USE_GCC)
   1.263 +  if(DEPENDENCY_TRACKING)
   1.264 +    check_c_source_compiles("
   1.265 +        #if !defined(__GNUC__) || __GNUC__ < 3
   1.266 +        #error Dependency tracking requires GCC 3.0 or newer
   1.267 +        #endif
   1.268 +        int main(int argc, char **argv) { }" HAVE_DEPENDENCY_TRACKING)
   1.269 +  endif(DEPENDENCY_TRACKING)
   1.270 +
   1.271 +  if(GCC_ATOMICS)
   1.272 +    check_c_source_compiles("int main(int argc, char **argv) {
   1.273 +        int a;
   1.274 +        void *x, *y, *z;
   1.275 +        __sync_lock_test_and_set(&a, 4);
   1.276 +        __sync_lock_test_and_set(&x, y);
   1.277 +        __sync_fetch_and_add(&a, 1);
   1.278 +        __sync_bool_compare_and_swap(&a, 5, 10);
   1.279 +        __sync_bool_compare_and_swap(&x, y, z); }" HAVE_GCC_ATOMICS)
   1.280 +    if(NOT HAVE_GCC_ATOMICS)
   1.281 +      check_c_source_compiles("int main(int argc, char **argv) {
   1.282 +          int a;
   1.283 +          __sync_lock_test_and_set(&a, 1);
   1.284 +          __sync_lock_release(&a); }" HAVE_GCC_SYNC_LOCK_TEST_AND_SET)
   1.285 +    endif(NOT HAVE_GCC_ATOMICS)
   1.286 +  endif(GCC_ATOMICS)
   1.287 +
   1.288 +  set(CMAKE_REQUIRED_FLAGS "-mpreferred-stack-boundary=2")
   1.289 +  check_c_source_compiles("int x = 0; int main(int argc, char **argv) {}"
   1.290 +    HAVE_GCC_PREFERRED_STACK_BOUNDARY)
   1.291 +  set(CMAKE_REQUIRED_FLAGS)
   1.292 +
   1.293 +  set(CMAKE_REQUIRED_FLAGS "-fvisibility=hidden -Werror")
   1.294 +  check_c_source_compiles("
   1.295 +      #if !defined(__GNUC__) || __GNUC__ < 4
   1.296 +      #error SDL only uses visibility attributes in GCC 4 or newer
   1.297 +      #endif
   1.298 +      int main(int argc, char **argv) {}" HAVE_GCC_FVISIBILITY)
   1.299 +  if(HAVE_GCC_FVISIBILITY)
   1.300 +    list(APPEND EXTRA_CFLAGS "-fvisibility=hidden")
   1.301 +  endif(HAVE_GCC_FVISIBILITY)
   1.302 +  set(CMAKE_REQUIRED_FLAGS)
   1.303 +
   1.304 +  check_c_compiler_flag(-Wall HAVE_GCC_WALL)
   1.305 +  if(HAVE_GCC_WALL)
   1.306 +    if(CMAKE_SYSTEM_NAME MATCHES "Haiku|BeOS")
   1.307 +      set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-multichar")
   1.308 +    endif(CMAKE_SYSTEM_NAME MATCHES "Haiku|BeOS")
   1.309 +  endif(HAVE_GCC_WALL)
   1.310 +endif(USE_GCC)
   1.311 +
   1.312 +if(ASSEMBLY)
   1.313 +  if(USE_GCC OR USE_CLANG)
   1.314 +    set(SDL_ASSEMBLY_ROUTINES 1)
   1.315 +    # TODO: Those all seem to be quite GCC specific - needs to be
   1.316 +    # reworked for better compiler support
   1.317 +    set(HAVE_ASSEMBLY TRUE)
   1.318 +    if(MMX)
   1.319 +      set(CMAKE_REQUIRED_FLAGS "-mmmx")
   1.320 +      check_c_source_compiles("
   1.321 +          #ifdef __MINGW32__
   1.322 +          #include <_mingw.h>
   1.323 +          #ifdef __MINGW64_VERSION_MAJOR
   1.324 +          #include <intrin.h>
   1.325 +          #else
   1.326 +          #include <mmintrin.h>
   1.327 +          #endif
   1.328 +          #else
   1.329 +          #include <mmintrin.h>
   1.330 +          #endif
   1.331 +          #ifndef __MMX__
   1.332 +          #error Assembler CPP flag not enabled
   1.333 +          #endif
   1.334 +          int main(int argc, char **argv) { }" HAVE_MMX)
   1.335 +      if(HAVE_MMX)
   1.336 +        list(APPEND EXTRA_CFLAGS "-mmmx")
   1.337 +      endif(HAVE_MMX)
   1.338 +      set(CMAKE_REQUIRED_FLAGS)
   1.339 +    endif(MMX)
   1.340 +
   1.341 +    if(3DNOW)
   1.342 +      set(CMAKE_REQUIRED_FLAGS "-m3dnow")
   1.343 +      check_c_source_compiles("
   1.344 +          #include <mm3dnow.h>
   1.345 +          #ifndef __3dNOW__
   1.346 +          #error Assembler CPP flag not enabled
   1.347 +          #endif
   1.348 +          int main(int argc, char **argv) {
   1.349 +            void *p = 0;
   1.350 +            _m_prefetch(p);
   1.351 +          }" HAVE_3DNOW)
   1.352 +      if(HAVE_3DNOW)
   1.353 +        list(APPEND EXTRA_CFLAGS "-m3dnow")
   1.354 +      endif(HAVE_3DNOW)
   1.355 +      set(CMAKE_REQUIRED_FLAGS)
   1.356 +    endif(3DNOW)
   1.357 +
   1.358 +    if(SSE)
   1.359 +      set(CMAKE_REQUIRED_FLAGS "-msse")
   1.360 +      check_c_source_compiles("
   1.361 +          #ifdef __MINGW32__
   1.362 +          #include <_mingw.h>
   1.363 +          #ifdef __MINGW64_VERSION_MAJOR
   1.364 +          #include <intrin.h>
   1.365 +          #else
   1.366 +          #include <xmmintrin.h>
   1.367 +          #endif
   1.368 +          #else
   1.369 +          #include <xmmintrin.h>
   1.370 +          #endif
   1.371 +          #ifndef __SSE__
   1.372 +          #error Assembler CPP flag not enabled
   1.373 +          #endif
   1.374 +          int main(int argc, char **argv) { }" HAVE_SSE)
   1.375 +      if(HAVE_SSE)
   1.376 +        list(APPEND EXTRA_CFLAGS "-msse")
   1.377 +      endif(HAVE_SSE)
   1.378 +      set(CMAKE_REQUIRED_FLAGS)
   1.379 +    endif(SSE)
   1.380 +
   1.381 +    if(SSE2)
   1.382 +      set(CMAKE_REQUIRED_FLAGS "-msse2")
   1.383 +      check_c_source_compiles("
   1.384 +          #ifdef __MINGW32__
   1.385 +          #include <_mingw.h>
   1.386 +          #ifdef __MINGW64_VERSION_MAJOR
   1.387 +          #include <intrin.h>
   1.388 +          #else
   1.389 +          #include <emmintrin.h>
   1.390 +          #endif
   1.391 +          #else
   1.392 +          #include <emmintrin.h>
   1.393 +          #endif
   1.394 +          #ifndef __SSE2__
   1.395 +          #error Assembler CPP flag not enabled
   1.396 +          #endif
   1.397 +          int main(int argc, char **argv) { }" HAVE_SSE2)
   1.398 +      if(HAVE_SSE2)
   1.399 +        list(APPEND EXTRA_CFLAGS "-msse2")
   1.400 +      endif(HAVE_SSE2)
   1.401 +      set(CMAKE_REQUIRED_FLAGS)
   1.402 +    endif(SSE2)
   1.403 +
   1.404 +    if(SSEMATH)
   1.405 +      if(SSE OR SSE2)
   1.406 +        if(USE_GCC)
   1.407 +          list(APPEND EXTRA_CFLAGS "-mfpmath=387")
   1.408 +        endif(USE_GCC)
   1.409 +        set(HAVE_SSEMATH TRUE)
   1.410 +      endif(SSE OR SSE2)
   1.411 +    endif(SSEMATH)
   1.412 +
   1.413 +    if(ALTIVEC)
   1.414 +      set(CMAKE_REQUIRED_FLAGS "-maltivec")
   1.415 +      check_c_source_compiles("
   1.416 +          #include <altivec.h>
   1.417 +          vector unsigned int vzero() {
   1.418 +              return vec_splat_u32(0);
   1.419 +          }
   1.420 +          int main(int argc, char **argv) { }" HAVE_ALTIVEC_H_HDR)
   1.421 +      check_c_source_compiles("
   1.422 +          vector unsigned int vzero() {
   1.423 +              return vec_splat_u32(0);
   1.424 +          }
   1.425 +          int main(int argc, char **argv) { }" HAVE_ALTIVEC)
   1.426 +      set(CMAKE_REQUIRED_FLAGS)
   1.427 +      if(HAVE_ALTIVEC OR HAVE_ALTIVEC_H_HDR)
   1.428 +        set(HAVE_ALTIVEC TRUE) # if only HAVE_ALTIVEC_H_HDR is set
   1.429 +        list(APPEND EXTRA_CFLAGS "-maltivec")
   1.430 +        set(SDL_ALTIVEC_BLITTERS 1)
   1.431 +        if(HAVE_ALTIVEC_H_HDR)
   1.432 +          set(HAVE_ALTIVEC_H 1)
   1.433 +        endif(HAVE_ALTIVEC_H_HDR)
   1.434 +      endif(HAVE_ALTIVEC OR HAVE_ALTIVEC_H_HDR)
   1.435 +    endif(ALTIVEC)
   1.436 +  elseif(MSVC_VERSION GREATER 1500)
   1.437 +    # TODO: SDL_cpuinfo.h needs to support the user's configuration wish
   1.438 +    # for MSVC - right now it is always activated
   1.439 +    if(NOT ARCH_64)
   1.440 +      set(HAVE_MMX TRUE)
   1.441 +      set(HAVE_3DNOW TRUE)
   1.442 +    endif(NOT ARCH_64)
   1.443 +    set(HAVE_SSE TRUE)
   1.444 +    set(HAVE_SSE2 TRUE)
   1.445 +    set(SDL_ASSEMBLY_ROUTINES 1)
   1.446 +  endif(USE_GCC OR USE_CLANG)
   1.447 +# TODO:
   1.448 +#else(ASSEMBLY)
   1.449 +#  if(USE_GCC OR USE_CLANG)
   1.450 +#    list(APPEND EXTRA_CFLAGS "-mno-sse" "-mno-sse2" "-mno-mmx")
   1.451 +#  endif(USE_GCC OR USE_CLANG)
   1.452 +endif(ASSEMBLY)
   1.453 +
   1.454 +# TODO: Can't deactivate on FreeBSD? w/o LIBC, SDL_stdinc.h can't define
   1.455 +# anything.
   1.456 +if(LIBC)
   1.457 +  if(WINDOWS AND NOT MINGW)
   1.458 +    set(HAVE_LIBC TRUE)
   1.459 +    foreach(_HEADER stdio.h string.h ctype.h math.h)
   1.460 +      string(TOUPPER "HAVE_${_HEADER}" _UPPER)
   1.461 +      string(REPLACE "." "_" _HAVE_H ${_UPPER})
   1.462 +      set(${_HAVE_H} 1)
   1.463 +    endforeach()
   1.464 +    set(HAVE_SIGNAL_H 1)
   1.465 +    foreach(_FN
   1.466 +            malloc calloc realloc free qsort abs memset memcpy memmove memcmp
   1.467 +            strlen _strrev _strupr _strlwr strchr strrchr strstr itoa _ltoa
   1.468 +            _ultoa strtol strtoul strtoll strtod atoi atof strcmp strncmp
   1.469 +            _stricmp _strnicmp sscanf atan atan2 ceil copysign cos cosf fabs
   1.470 +            floor log pow scalbn sin sinf sqrt)
   1.471 +      string(TOUPPER ${_FN} _UPPER)
   1.472 +      set(HAVE_${_UPPER} 1)
   1.473 +    endforeach()
   1.474 +    if(NOT CYGWIN AND NOT MINGW)
   1.475 +      set(HAVE_ALLOCA 1)
   1.476 +    endif(NOT CYGWIN AND NOT MINGW)
   1.477 +    set(HAVE_M_PI 1)
   1.478 +    add_definitions(-D_USE_MATH_DEFINES) # needed for M_PI
   1.479 +    set(STDC_HEADERS 1)
   1.480 +  else(WINDOWS AND NOT MINGW)
   1.481 +    set(HAVE_LIBC TRUE)
   1.482 +    check_include_file(sys/types.h HAVE_SYS_TYPES_H)
   1.483 +    foreach(_HEADER
   1.484 +            stdio.h stdlib.h stddef.h stdarg.h malloc.h memory.h string.h
   1.485 +            strings.h inttypes.h stdint.h ctype.h math.h iconv.h signal.h)
   1.486 +      string(TOUPPER "HAVE_${_HEADER}" _UPPER)
   1.487 +      string(REPLACE "." "_" _HAVE_H ${_UPPER})
   1.488 +      check_include_file("${_HEADER}" ${_HAVE_H})
   1.489 +    endforeach()
   1.490 +
   1.491 +    check_include_files("dlfcn.h;stdint.h;stddef.h;inttypes.h;stdlib.h;strings.h;string.h;float.h" STDC_HEADERS)
   1.492 +    check_type_size("size_t" SIZEOF_SIZE_T)
   1.493 +    check_symbol_exists(M_PI math.h HAVE_M_PI)
   1.494 +    # TODO: refine the mprotect check
   1.495 +    check_c_source_compiles("#include <sys/types.h>
   1.496 +                             #include <sys/mman.h>
   1.497 +                             int main() { }" HAVE_MPROTECT)
   1.498 +    foreach(_FN
   1.499 +            strtod malloc calloc realloc free getenv setenv putenv unsetenv
   1.500 +            qsort abs bcopy memset memcpy memmove memcmp strlen strlcpy strlcat
   1.501 +            strdup _strrev _strupr _strlwr strchr strrchr strstr itoa _ltoa
   1.502 +            _uitoa _ultoa strtol strtoul _i64toa _ui64toa strtoll strtoull
   1.503 +            atoi atof strcmp strncmp _stricmp strcasecmp _strnicmp strncasecmp
   1.504 +            sscanf snprintf vsnprintf fseeko fseeko64 sigaction setjmp
   1.505 +            nanosleep sysconf sysctlbyname
   1.506 +            )
   1.507 +      string(TOUPPER ${_FN} _UPPER)
   1.508 +      set(_HAVEVAR "HAVE_${_UPPER}")
   1.509 +      check_function_exists("${_FN}" ${_HAVEVAR})
   1.510 +    endforeach()
   1.511 +
   1.512 +    check_library_exists(m pow "" HAVE_LIBM)
   1.513 +    if(HAVE_LIBM)
   1.514 +      set(CMAKE_REQUIRED_LIBRARIES m)
   1.515 +      foreach(_FN
   1.516 +              atan atan2 ceil copysign cos cosf fabs floor log pow scalbn sin
   1.517 +              sinf sqrt)
   1.518 +        string(TOUPPER ${_FN} _UPPER)
   1.519 +        set(_HAVEVAR "HAVE_${_UPPER}")
   1.520 +        check_function_exists("${_FN}" ${_HAVEVAR})
   1.521 +      endforeach()
   1.522 +      set(CMAKE_REQUIRED_LIBRARIES)
   1.523 +      list(APPEND EXTRA_LIBS m)
   1.524 +    endif(HAVE_LIBM)
   1.525 +
   1.526 +    check_library_exists(iconv iconv_open "" HAVE_LIBICONV)
   1.527 +    if(HAVE_LIBICONV)
   1.528 +      list(APPEND EXTRA_LIBS iconv)
   1.529 +    endif(HAVE_LIBICONV)
   1.530 +
   1.531 +    check_struct_has_member("struct sigaction" "sa_sigaction" "signal.h" HAVE_SA_SIGACTION)
   1.532 +  endif(WINDOWS AND NOT MINGW)
   1.533 +else(LIBC)
   1.534 +  if(WINDOWS)
   1.535 +    set(HAVE_STDARG_H 1)
   1.536 +    set(HAVE_STDDEF_H 1)
   1.537 +  endif(WINDOWS)
   1.538 +endif(LIBC)
   1.539 +
   1.540 +
   1.541 +# Enable/disable various subsystems of the SDL library
   1.542 +foreach(_SUB ${SDL_SUBSYSTEMS})
   1.543 +  string(TOUPPER ${_SUB} _OPT)
   1.544 +  if(NOT SDL_${_OPT})
   1.545 +    set(SDL_${_OPT}_DISABLED 1)
   1.546 +  endif(NOT SDL_${_OPT})
   1.547 +endforeach()
   1.548 +if(SDL_JOYSTICK)
   1.549 +  file(GLOB JOYSTICK_SOURCES ${SDL2_SOURCE_DIR}/src/joystick/*.c)
   1.550 +  set(SOURCE_FILES ${SOURCE_FILES} ${JOYSTICK_SOURCES})
   1.551 +endif(SDL_JOYSTICK)
   1.552 +if(SDL_HAPTIC)
   1.553 +  if(NOT SDL_JOYSTICK)
   1.554 +    # Haptic requires some private functions from the joystick subsystem.
   1.555 +    message_error("SDL_HAPTIC requires SDL_JOYSTICK, which is not enabled")
   1.556 +  endif(NOT SDL_JOYSTICK)
   1.557 +  file(GLOB HAPTIC_SOURCES ${SDL2_SOURCE_DIR}/src/haptic/*.c)
   1.558 +  set(SOURCE_FILES ${SOURCE_FILES} ${HAPTIC_SOURCES})
   1.559 +endif(SDL_HAPTIC)
   1.560 +if(SDL_POWER)
   1.561 +  file(GLOB POWER_SOURCES ${SDL2_SOURCE_DIR}/src/power/*.c)
   1.562 +  set(SOURCE_FILES ${SOURCE_FILES} ${POWER_SOURCES})
   1.563 +endif(SDL_POWER)
   1.564 +# TODO: in configure.in, the test for LOADSO and SDL_DLOPEN is a bit weird:
   1.565 +# if LOADSO is not wanted, SDL_LOADSO_DISABLED is set
   1.566 +# If however on Unix or APPLE dlopen() is detected via CheckDLOPEN(),
   1.567 +# SDL_LOADSO_DISABLED will not be set, regardless of the LOADSO settings
   1.568 +
   1.569 +# General SDL subsystem options, valid for all platforms
   1.570 +if(SDL_AUDIO)
   1.571 +  # CheckDummyAudio/CheckDiskAudio - valid for all platforms
   1.572 +  if(DUMMYAUDIO)
   1.573 +    set(SDL_AUDIO_DRIVER_DUMMY 1)
   1.574 +    file(GLOB DUMMYAUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/dummy/*.c)
   1.575 +    set(SOURCE_FILES ${SOURCE_FILES} ${DUMMYAUDIO_SOURCES})
   1.576 +    set(HAVE_DUMMYAUDIO TRUE)
   1.577 +  endif(DUMMYAUDIO)
   1.578 +  if(DISKAUDIO)
   1.579 +    set(SDL_AUDIO_DRIVER_DISK 1)
   1.580 +    file(GLOB DISKAUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/disk/*.c)
   1.581 +    set(SOURCE_FILES ${SOURCE_FILES} ${DISKAUDIO_SOURCES})
   1.582 +    set(HAVE_DISKAUDIO TRUE)
   1.583 +  endif(DISKAUDIO)
   1.584 +endif(SDL_AUDIO)
   1.585 +
   1.586 +if(SDL_DLOPEN)
   1.587 +  # Relevant for Unix/Darwin only
   1.588 +  if(UNIX OR APPLE)
   1.589 +    CheckDLOPEN()
   1.590 +  endif(UNIX OR APPLE)
   1.591 +endif(SDL_DLOPEN)
   1.592 +
   1.593 +if(SDL_VIDEO)
   1.594 +  if(VIDEO_DUMMY)
   1.595 +    set(SDL_VIDEO_DRIVER_DUMMY 1)
   1.596 +    file(GLOB VIDEO_DUMMY_SOURCES ${SDL2_SOURCE_DIR}/src/video/dummy/*.c)
   1.597 +    set(SOURCE_FILES ${SOURCE_FILES} ${VIDEO_DUMMY_SOURCES})
   1.598 +    set(HAVE_VIDEO_DUMMY TRUE)
   1.599 +    set(HAVE_SDL_VIDEO TRUE)
   1.600 +  endif(VIDEO_DUMMY)
   1.601 +endif(SDL_VIDEO)
   1.602 +
   1.603 +# Platform-specific options and settings
   1.604 +if(UNIX AND NOT APPLE)
   1.605 +  if(SDL_AUDIO)
   1.606 +    if(SYSV5 OR SOLARIS OR HPUX)
   1.607 +        set(SDL_AUDIO_DRIVER_SUNAUDIO 1)
   1.608 +        file(GLOB SUN_AUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/sun/*.c)
   1.609 +        set(SOURCE_FILES ${SOURCE_FILES} ${SUN_AUDIO_SOURCES})
   1.610 +        set(HAVE_SDL_AUDIO TRUE)
   1.611 +    elseif(NETBSD OR OPENBSD)
   1.612 +        set(SDL_AUDIO_DRIVER_BSD 1)
   1.613 +        file(GLOB BSD_AUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/bsd/*.c)
   1.614 +        set(SOURCE_FILES ${SOURCE_FILES} ${BSD_AUDIO_SOURCES})
   1.615 +        set(HAVE_SDL_AUDIO TRUE)
   1.616 +    elseif(AIX)
   1.617 +        set(SDL_AUDIO_DRIVER_PAUDIO 1)
   1.618 +        file(GLOB AIX_AUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/paudio/*.c)
   1.619 +        set(SOURCE_FILES ${SOURCE_FILES} ${AIX_AUDIO_SOURCES})
   1.620 +        set(HAVE_SDL_AUDIO TRUE)
   1.621 +    endif()
   1.622 +    CheckOSS()
   1.623 +    CheckALSA()
   1.624 +    CheckPulseAudio()
   1.625 +    CheckESD()
   1.626 +    CheckARTS()
   1.627 +    CheckNAS()
   1.628 +    CheckFusionSound()
   1.629 +  endif(SDL_AUDIO)
   1.630 +
   1.631 +  if(SDL_VIDEO)
   1.632 +    CheckX11()
   1.633 +    CheckDirectFB()
   1.634 +    CheckOpenGLX11()
   1.635 +    CheckOpenGLESX11()
   1.636 +  endif(SDL_VIDEO)
   1.637 +
   1.638 +  if(INPUT_EVENTS)
   1.639 +    check_c_source_compiles("
   1.640 +        #include <linux/input.h>
   1.641 +        #ifndef EVIOCGNAME
   1.642 +        #error EVIOCGNAME() ioctl not available
   1.643 +        #endif
   1.644 +        int main(int argc, char** argv) {}" HAVE_INPUT_EVENTS)
   1.645 +    if(HAVE_INPUT_EVENTS)
   1.646 +      set(SDL_INPUT_LINUXEV 1)
   1.647 +    endif(HAVE_INPUT_EVENTS)
   1.648 +  endif(INPUT_EVENTS)
   1.649 +
   1.650 +  if(SDL_HAPTIC AND HAVE_INPUT_EVENTS)
   1.651 +    if(LINUX)
   1.652 +      set(SDL_HAPTIC_LINUX 1)
   1.653 +      file(GLOB HAPTIC_SOURCES ${SDL2_SOURCE_DIR}/src/haptic/linux/*.c)
   1.654 +      set(SOURCE_FILES ${SOURCE_FILES} ${HAPTIC_SOURCES})
   1.655 +      set(HAVE_SDL_HAPTIC TRUE)
   1.656 +    endif(LINUX)
   1.657 +  endif(SDL_HAPTIC AND HAVE_INPUT_EVENTS)
   1.658 +
   1.659 +  if(INPUT_TSLIB)
   1.660 +    check_c_source_compiles("
   1.661 +        #include \"tslib.h\"
   1.662 +        int main(int argc, char** argv) { }" HAVE_INPUT_TSLIB)
   1.663 +    if(HAVE_INPUT_TSLIB)
   1.664 +      set(SDL_INPUT_TSLIB 1)
   1.665 +      list(APPEND EXTRA_LIBS ts)
   1.666 +    endif(HAVE_INPUT_TSLIB)
   1.667 +  endif(INPUT_TSLIB)
   1.668 +
   1.669 +  if(SDL_JOYSTICK)
   1.670 +    CheckUSBHID()   # seems to be BSD specific - limit the test to BSD only?
   1.671 +    if(LINUX)
   1.672 +      set(SDL_JOYSTICK_LINUX 1)
   1.673 +      file(GLOB JOYSTICK_SOURCES ${SDL2_SOURCE_DIR}/src/joystick/linux/*.c)
   1.674 +      set(SOURCE_FILES ${SOURCE_FILES} ${JOYSTICK_SOURCES})
   1.675 +      set(HAVE_SDL_JOYSTICK TRUE)
   1.676 +    endif(LINUX)
   1.677 +  endif(SDL_JOYSTICK)
   1.678 +
   1.679 +  CheckPTHREAD()
   1.680 +
   1.681 +  if(CLOCK_GETTIME)
   1.682 +    check_library_exists(rt clock_gettime "" FOUND_CLOCK_GETTIME)
   1.683 +    if(FOUND_CLOCK_GETTIME)
   1.684 +      list(APPEND EXTRA_LIBS rt)
   1.685 +      set(HAVE_CLOCK_GETTIME 1)
   1.686 +    else(FOUND_CLOCK_GETTIME)
   1.687 +      check_library_exists(c clock_gettime "" FOUND_CLOCK_GETTIME)
   1.688 +      if(FOUND_CLOCK_GETTIME)
   1.689 +        set(HAVE_CLOCK_GETTIME 1)
   1.690 +      endif(FOUND_CLOCK_GETTIME)
   1.691 +    endif(HAVE_CLOCK_GETTIME)
   1.692 +  endif(CLOCK_GETTIME)
   1.693 +
   1.694 +  check_include_file(linux/version.h HAVE_LINUX_VERSION_H)
   1.695 +  if(HAVE_LINUX_VERSION_H)
   1.696 +    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DHAVE_LINUX_VERSION_H")
   1.697 +  endif(HAVE_LINUX_VERSION_H)
   1.698 +
   1.699 +  if(SDL_POWER)
   1.700 +    if(LINUX)
   1.701 +      set(SDL_POWER_LINUX 1)
   1.702 +      file(GLOB POWER_SOURCES ${SDL2_SOURCE_DIR}/src/power/linux/*.c)
   1.703 +      set(SOURCE_FILES ${SOURCE_FILES} ${POWER_SOURCES})
   1.704 +      set(HAVE_SDL_POWER TRUE)
   1.705 +    endif(LINUX)
   1.706 +  endif(SDL_POWER)
   1.707 +
   1.708 +  if(SDL_TIMERS)
   1.709 +    set(SDL_TIMER_UNIX 1)
   1.710 +    file(GLOB TIMER_SOURCES ${SDL2_SOURCE_DIR}/src/timer/unix/*.c)
   1.711 +    set(SOURCE_FILES ${SOURCE_FILES} ${TIMER_SOURCES})
   1.712 +    set(HAVE_SDL_TIMERS TRUE)
   1.713 +  endif(SDL_TIMERS)
   1.714 +
   1.715 +  if(RPATH)
   1.716 +    set(SDL_RLD_FLAGS "")
   1.717 +    if(BSDI OR FREEBSD OR LINUX OR NETBSD)
   1.718 +      set(SDL_RLD_FLAGS "-Wl,-rpath,\${libdir}")
   1.719 +    elseif(SOLARIS)
   1.720 +      set(SDL_RLD_FLAGS "-R\${libdir}")
   1.721 +    endif()
   1.722 +    set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
   1.723 +    set(HAVE_RPATH TRUE)
   1.724 +  endif(RPATH)
   1.725 +
   1.726 +elseif(WINDOWS)
   1.727 +  find_program(WINDRES windres)
   1.728 +
   1.729 +  check_c_source_compiles("
   1.730 +    #include <windows.h>
   1.731 +    int main(int argc, char **argv) { }" HAVE_WIN32_CC)
   1.732 +
   1.733 +  file(GLOB WIN_SOURCES ${SDL2_SOURCE_DIR}/src/core/windows/*.c)
   1.734 +  set(SOURCE_FILES ${SOURCE_FILES} ${WIN_SOURCES})
   1.735 +
   1.736 +  # Check for DirectX
   1.737 +  if(DIRECTX)
   1.738 +    if("$ENV{DXSDK_DIR}" STREQUAL "")
   1.739 +      message_error("DIRECTX requires the \$DXSDK_DIR environment variable to be set")
   1.740 +    endif("$ENV{DXSDK_DIR}" STREQUAL "")
   1.741 +    set(CMAKE_REQUIRED_FLAGS "/I\"$ENV{DXSDK_DIR}\\Include\"")
   1.742 +    check_include_file(d3d9.h HAVE_D3D_H)
   1.743 +    check_include_file(ddraw.h HAVE_DDRAW_H)
   1.744 +    check_include_file(dsound.h HAVE_DSOUND_H)
   1.745 +    check_include_file(dinput.h HAVE_DINPUT_H)
   1.746 +    check_include_file(xaudio2.h HAVE_XAUDIO2_H)
   1.747 +    if(HAVE_D3D_H OR HAVE_DDRAW_H OR HAVE_DSOUND_H OR HAVE_DINPUT_H OR HAVE_XAUDIO2_H)
   1.748 +      set(HAVE_DIRECTX TRUE)
   1.749 +      # TODO: change $ENV{DXSDL_DIR} to get the path from the include checks
   1.750 +      link_directories($ENV{DXSDK_DIR}\\lib\\${PROCESSOR_ARCH})
   1.751 +      include_directories($ENV{DXSDK_DIR}\\Include)
   1.752 +    endif()
   1.753 +    set(CMAKE_REQUIRED_FLAGS)
   1.754 +  endif(DIRECTX)
   1.755 +
   1.756 +  if(SDL_AUDIO)
   1.757 +    set(SDL_AUDIO_DRIVER_WINMM 1)
   1.758 +    file(GLOB WINMM_AUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/winmm/*.c)
   1.759 +    set(SOURCE_FILES ${SOURCE_FILES} ${WINMM_AUDIO_SOURCES})
   1.760 +    set(HAVE_SDL_AUDIO TRUE)
   1.761 +
   1.762 +    if(HAVE_DSOUND_H)
   1.763 +      set(SDL_AUDIO_DRIVER_DSOUND 1)
   1.764 +      file(GLOB DSOUND_AUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/directsound/*.c)
   1.765 +      set(SOURCE_FILES ${SOURCE_FILES} ${DSOUND_AUDIO_SOURCES})
   1.766 +    endif(HAVE_DSOUND_H)
   1.767 +
   1.768 +    if(HAVE_XAUDIO2_H)
   1.769 +      set(SDL_AUDIO_DRIVER_XAUDIO2 1)
   1.770 +      file(GLOB XAUDIO2_AUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/xaudio2/*.c)
   1.771 +      set(SOURCE_FILES ${SOURCE_FILES} ${XAUDIO2_AUDIO_SOURCES})
   1.772 +    endif(HAVE_XAUDIO2_H)
   1.773 +  endif(SDL_AUDIO)
   1.774 +
   1.775 +  if(SDL_VIDEO)
   1.776 +    # requires SDL_LOADSO on Windows (IME, DX, etc.)
   1.777 +    if(NOT SDL_LOADSO)
   1.778 +      message_error("SDL_VIDEO requires SDL_LOADSO, which is not enabled")
   1.779 +    endif(NOT SDL_LOADSO)
   1.780 +    set(SDL_VIDEO_DRIVER_WINDOWS 1)
   1.781 +    file(GLOB WIN_VIDEO_SOURCES ${SDL2_SOURCE_DIR}/src/video/windows/*.c)
   1.782 +    set(SOURCE_FILES ${SOURCE_FILES} ${WIN_VIDEO_SOURCES})
   1.783 +
   1.784 +    if(RENDER_D3D AND HAVE_D3D_H)
   1.785 +      set(SDL_VIDEO_RENDER_D3D 1)
   1.786 +      set(HAVE_RENDER_D3D TRUE)
   1.787 +    endif(RENDER_D3D AND HAVE_D3D_H)
   1.788 +    set(HAVE_SDL_VIDEO TRUE)
   1.789 +  endif(SDL_VIDEO)
   1.790 +
   1.791 +  if(SDL_THREADS)
   1.792 +    set(SDL_THREAD_WINDOWS 1)
   1.793 +    set(SOURCE_FILES ${SOURCE_FILES}
   1.794 +      ${SDL2_SOURCE_DIR}/src/thread/windows/SDL_sysmutex.c
   1.795 +      ${SDL2_SOURCE_DIR}/src/thread/windows/SDL_syssem.c
   1.796 +      ${SDL2_SOURCE_DIR}/src/thread/windows/SDL_systhread.c
   1.797 +      ${SDL2_SOURCE_DIR}/src/thread/generic/SDL_syscond.c)
   1.798 +    set(HAVE_SDL_THREADS TRUE)
   1.799 +  endif(SDL_THREADS)
   1.800 +
   1.801 +  if(SDL_POWER)
   1.802 +    set(SDL_POWER_WINDOWS 1)
   1.803 +    set(SOURCE_FILES ${SOURCE_FILES} ${SDL2_SOURCE_DIR}/src/power/windows/SDL_syspower.c)
   1.804 +    set(HAVE_SDL_POWER TRUE)
   1.805 +  endif(SDL_POWER)
   1.806 +
   1.807 +  # Libraries for Win32 native and MinGW
   1.808 +  list(APPEND EXTRA_LIBS user32 gdi32 winmm imm32 ole32 oleaut32 version uuid)
   1.809 +
   1.810 +  # TODO: in configure.in the check for timers is set on
   1.811 +  # cygwin | mingw32* - does this include mingw32CE?
   1.812 +  if(SDL_TIMERS)
   1.813 +    set(SDL_TIMER_WINDOWS 1)
   1.814 +    file(GLOB TIMER_SOURCES ${SDL2_SOURCE_DIR}/src/timer/windows/*.c)
   1.815 +    set(SOURCE_FILES ${SOURCE_FILES} ${TIMER_SOURCES})
   1.816 +    set(HAVE_SDL_TIMERS TRUE)
   1.817 +  endif(SDL_TIMERS)
   1.818 +
   1.819 +  if(SDL_LOADSO)
   1.820 +    set(SDL_LOADSO_WINDOWS 1)
   1.821 +    file(GLOB LOADSO_SOURCES ${SDL2_SOURCE_DIR}/src/loadso/windows/*.c)
   1.822 +    set(SOURCE_FILES ${SOURCE_FILES} ${LOADSO_SOURCES})
   1.823 +    set(HAVE_SDL_LOADSO TRUE)
   1.824 +  endif(SDL_LOADSO)
   1.825 +
   1.826 +  file(GLOB CORE_SOURCES ${SDL2_SOURCE_DIR}/src/core/windows/*.c)
   1.827 +  set(SOURCE_FILES ${SOURCE_FILES} ${CORE_SOURCES})
   1.828 +
   1.829 +  if(SDL_VIDEO)
   1.830 +    if(VIDEO_OPENGL)
   1.831 +      set(SDL_VIDEO_OPENGL 1)
   1.832 +      set(SDL_VIDEO_OPENGL_WGL 1)
   1.833 +      set(SDL_VIDEO_RENDER_OGL 1)
   1.834 +      set(HAVE_VIDEO_OPENGL TRUE)
   1.835 +    endif(VIDEO_OPENGL)
   1.836 +  endif(SDL_VIDEO)
   1.837 +
   1.838 +  if(SDL_JOYSTICK)
   1.839 +    if(HAVE_DINPUT_H)
   1.840 +      set(SDL_JOYSTICK_DINPUT 1)
   1.841 +      set(SOURCE_FILES ${SOURCE_FILES} ${SDL2_SOURCE_DIR}/src/joystick/windows/SDL_dxjoystick.c)
   1.842 +      list(APPEND EXTRA_LIBS dinput8 dxguid dxerr)
   1.843 +    else()
   1.844 +      set(SDL_JOYSTICK_WINMM 1)
   1.845 +      set(SOURCE_FILES ${SOURCE_FILES} ${SDL2_SOURCE_DIR}/src/joystick/windows/SDL_mmjoystick.c)
   1.846 +    endif(HAVE_DINPUT_H)
   1.847 +    set(HAVE_SDL_JOYSTICK TRUE)
   1.848 +  endif(SDL_JOYSTICK)
   1.849 +
   1.850 +  if(SDL_HAPTIC AND HAVE_DINPUT_H)
   1.851 +    set(SDL_HAPTIC_DINPUT 1)
   1.852 +    set(SOURCE_FILES ${SOURCE_FILES} ${SDL2_SOURCE_DIR}/src/haptic/windows/SDL_syshaptic.c)
   1.853 +    set(HAVE_SDL_HAPTIC TRUE)
   1.854 +  endif(SDL_HAPTIC AND HAVE_DINPUT_H)
   1.855 +
   1.856 +  file(GLOB VERSION_SOURCES ${SDL2_SOURCE_DIR}/src/main/windows/*.rc)
   1.857 +  file(GLOB SDLMAIN_SOURCES ${SDL2_SOURCE_DIR}/src/main/windows/*.c)
   1.858 +  if(MINGW OR CYGWIN)
   1.859 +    list(APPEND EXTRA_LIBS mingw32)
   1.860 +    list(APPEND EXTRA_LDFLAGS "-mwindows")
   1.861 +    set(SDL_CFLAGS "${SDL_CFLAGS} -Dmain=SDL_main")
   1.862 +    list(APPEND SDL_LIBS "-lmingw32" "-lSDL2main" "-mwindows")
   1.863 +  endif(MINGW OR CYGWIN)
   1.864 +elseif(APPLE)
   1.865 +  # TODO: rework this for proper MacOS X, iOS and Darwin support
   1.866 +
   1.867 +  # Requires the darwin file implementation
   1.868 +  if(SDL_FILE)
   1.869 +    file(GLOB EXTRA_SOURCES ${PROJECT_SOURCE_DIR}/src/file/cocoa/*.m)
   1.870 +    set(SOURCE_FILES ${EXTRA_SOURCES} ${SOURCE_FILES})
   1.871 +    set_source_files_properties(${EXTRA_SOURCES} PROPERTIES LANGUAGE C)
   1.872 +    set(HAVE_SDL_FILE TRUE)
   1.873 +    set(SDL_FRAMEWORK_COCOA 1)
   1.874 +  else()
   1.875 +    message_error("SDL_FILE must be enabled to build on MacOS X")
   1.876 +  endif()
   1.877 +
   1.878 +  if(SDL_AUDIO)
   1.879 +    set(MACOSX_COREAUDIO 1)
   1.880 +    file(GLOB AUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/coreaudio/*.c)
   1.881 +    set(SOURCE_FILES ${SOURCE_FILES} ${AUDIO_SOURCES})
   1.882 +    set(HAVE_SDL_AUDIO TRUE)
   1.883 +    set(SDL_FRAMEWORK_COREAUDIO 1)
   1.884 +    set(SDL_FRAMEWORK_AUDIOUNIT 1)
   1.885 +  endif()
   1.886 +
   1.887 +  if(SDL_JOYSTICK)
   1.888 +    set(SDL_JOYSTICK_IOKIT 1)
   1.889 +    file(GLOB JOYSTICK_SOURCES ${SDL2_SOURCE_DIR}/src/joystick/darwin/*.c)
   1.890 +    set(SOURCE_FILES ${SOURCE_FILES} ${JOYSTICK_SOURCES})
   1.891 +    set(HAVE_SDL_JOYSTICK TRUE)
   1.892 +    set(SDL_FRAMEWORK_IOKIT 1)
   1.893 +    set(SDL_FRAMEWORK_FF 1)
   1.894 +  endif()
   1.895 +
   1.896 +  if(SDL_HAPTIC)
   1.897 +    set(SDL_HAPTIC_IOKIT 1)
   1.898 +    file(GLOB HAPTIC_SOURCES ${SDL2_SOURCE_DIR}/src/haptic/darwin/*.c)
   1.899 +    set(SOURCE_FILES ${SOURCE_FILES} ${HAPTIC_SOURCES})
   1.900 +    set(HAVE_SDL_HAPTIC TRUE)
   1.901 +    set(SDL_FRAMEWORK_IOKIT 1)
   1.902 +    set(SDL_FRAMEWORK_FF 1)
   1.903 +    if(NOT SDL_JOYSTICK)
   1.904 +      message(FATAL_ERROR "SDL_HAPTIC requires SDL_JOYSTICK to be enabled")
   1.905 +    endif()
   1.906 +  endif()
   1.907 +
   1.908 +  if(SDL_POWER)
   1.909 +    set(SDL_POWER_MACOSX 1)
   1.910 +    file(GLOB POWER_SOURCES ${SDL2_SOURCE_DIR}/src/power/macosx/*.c)
   1.911 +    set(SOURCE_FILES ${SOURCE_FILES} ${POWER_SOURCES})
   1.912 +    set(HAVE_SDL_POWER TRUE)
   1.913 +    set(SDL_FRAMEWORK_CARBON 1)
   1.914 +    set(SDL_FRAMEWORK_IOKIT 1)
   1.915 +  endif()
   1.916 +
   1.917 +  # Actually load the frameworks at the end so we don't duplicate include.
   1.918 +  if(SDL_FRAMEWORK_COCOA)
   1.919 +    find_library(COCOA_LIBRARY Cocoa)
   1.920 +    list(APPEND EXTRA_LIBS ${COCOA_LIBRARY})
   1.921 +  endif()
   1.922 +  if(SDL_FRAMEWORK_IOKIT)
   1.923 +    find_library(IOKIT IOKit)
   1.924 +    list(APPEND EXTRA_LIBS ${IOKIT})
   1.925 +  endif()
   1.926 +  if(SDL_FRAMEWORK_FF)
   1.927 +    find_library(FORCEFEEDBACK ForceFeedback)
   1.928 +    list(APPEND EXTRA_LIBS ${FORCEFEEDBACK})
   1.929 +  endif()
   1.930 +  if(SDL_FRAMEWORK_CARBON)
   1.931 +    find_library(CARBON_LIBRARY Carbon)
   1.932 +    list(APPEND EXTRA_LIBS ${CARBON_LIBRARY})
   1.933 +  endif()
   1.934 +  if(SDL_FRAMEWORK_COREAUDIO)
   1.935 +    find_library(COREAUDIO CoreAudio)
   1.936 +    list(APPEND EXTRA_LIBS ${COREAUDIO})
   1.937 +  endif()
   1.938 +  if(SDL_FRAMEWORK_AUDIOUNIT)
   1.939 +    find_library(AUDIOUNIT AudioUnit)
   1.940 +    list(APPEND EXTRA_LIBS ${AUDIOUNIT})
   1.941 +  endif()
   1.942 +
   1.943 +  # iOS hack needed - http://code.google.com/p/ios-cmake/ ?
   1.944 +  if(SDL_VIDEO)
   1.945 +    CheckCOCOA()
   1.946 +    if(VIDEO_OPENGL)
   1.947 +      set(SDL_VIDEO_OPENGL 1)
   1.948 +      set(SDL_VIDEO_OPENGL_CGL 1)
   1.949 +      set(SDL_VIDEO_RENDER_OGL 1)
   1.950 +      if(DARWIN)
   1.951 +        find_library(OpenGL_LIBRARY OpenGL)
   1.952 +        list(APPEND EXTRA_LIBRARIES ${OpenGL_LIBRARY})
   1.953 +      endif(DARWIN)
   1.954 +      set(HAVE_VIDEO_OPENGL TRUE)
   1.955 +    endif(VIDEO_OPENGL)
   1.956 +  endif(SDL_VIDEO)
   1.957 +
   1.958 +  CheckPTHREAD()
   1.959 +elseif(BEOS)
   1.960 +  if(SDL_VIDEO)
   1.961 +    set(SDL_VIDEO_DRIVER_BWINDOW 1)
   1.962 +    file(GLOB BWINDOW_SOURCES ${SDL2_SOURCE_DIR}/src/video/bwindow/*.c)
   1.963 +    set(SOURCE_FILES ${SOURCE_FILES} ${BWINDOW_SOURCES})
   1.964 +    set(HAVE_SDL_VIDEO TRUE)
   1.965 +
   1.966 +    if(VIDEO_OPENGL)
   1.967 +      # TODO: Use FIND_PACKAGE(OpenGL) instead
   1.968 +      set(SDL_VIDEO_OPENGL 1)
   1.969 +      set(SDL_VIDEO_OPENGL_BGL 1)
   1.970 +      set(SDL_VIDEO_RENDER_OGL 1)
   1.971 +      list(APPEND EXTRA_LIBS GL)
   1.972 +      set(HAVE_VIDEO_OPENGL TRUE)
   1.973 +    endif(VIDEO_OPENGL)
   1.974 +  endif(SDL_VIDEO)
   1.975 +endif()
   1.976 +
   1.977 +# Dummies
   1.978 +# configure.in does it differently:
   1.979 +# if not have X
   1.980 +#   if enable_X {  SDL_X_DISABLED = 1 }
   1.981 +#   [add dummy sources]
   1.982 +# so it always adds a dummy, without checking, if it was actually requested.
   1.983 +# This leads to missing internal references on building, since the
   1.984 +# src/X/*.c does not get included.
   1.985 +if(NOT HAVE_SDL_JOYSTICK)
   1.986 +  set(SDL_JOYSTICK_DISABLED 1)
   1.987 +  if(SDL_JOYSTICK AND NOT APPLE) # results in unresolved symbols on OSX
   1.988 +
   1.989 +    file(GLOB JOYSTICK_SOURCES ${SDL2_SOURCE_DIR}/src/joystick/dummy/*.c)
   1.990 +    set(SOURCE_FILES ${SOURCE_FILES} ${JOYSTICK_SOURCES})
   1.991 +  endif()
   1.992 +endif(NOT HAVE_SDL_JOYSTICK)
   1.993 +if(NOT HAVE_SDL_HAPTIC)
   1.994 +  set(SDL_HAPTIC_DISABLED 1)
   1.995 +  file(GLOB HAPTIC_SOURCES ${SDL2_SOURCE_DIR}/src/haptic/dummy/*.c)
   1.996 +  set(SOURCE_FILES ${SOURCE_FILES} ${HAPTIC_SOURCES})
   1.997 +endif(NOT HAVE_SDL_HAPTIC)
   1.998 +if(NOT HAVE_SDL_LOADSO)
   1.999 +  set(SDL_LOADSO_DISABLED 1)
  1.1000 +  file(GLOB LOADSO_SOURCES ${SDL2_SOURCE_DIR}/src/loadso/dummy/*.c)
  1.1001 +  set(SOURCE_FILES ${SOURCE_FILES} ${JOYSTICK_SOURCES})
  1.1002 +endif(NOT HAVE_SDL_LOADSO)
  1.1003 +
  1.1004 +# We always need to have threads and timers around
  1.1005 +if(NOT HAVE_SDL_THREADS)
  1.1006 +  set(SDL_THREADS_DISABLED 1)
  1.1007 +  file(GLOB THREADS_SOURCES ${SDL2_SOURCE_DIR}/src/thread/generic/*.c)
  1.1008 +  set(SOURCE_FILES ${SOURCE_FILES} ${THREADS_SOURCES})
  1.1009 +endif(NOT HAVE_SDL_THREADS)
  1.1010 +if(NOT HAVE_SDL_TIMERS)
  1.1011 +  set(SDL_TIMERS_DISABLED 1)
  1.1012 +  file(GLOB TIMER_SOURCES ${SDL2_SOURCE_DIR}/src/timer/dummy/*.c)
  1.1013 +  set(SOURCE_FILES ${SOURCE_FILES} ${TIMER_SOURCES})
  1.1014 +endif(NOT HAVE_SDL_TIMERS)
  1.1015 +
  1.1016 +if(NOT SDLMAIN_SOURCES)
  1.1017 +  file(GLOB SDLMAIN_SOURCES ${SDL2_SOURCE_DIR}/src/main/dummy/*.c)
  1.1018 +endif(NOT SDLMAIN_SOURCES)
  1.1019 +
  1.1020 +# Append the -MMD -MT flags
  1.1021 +# if(DEPENDENCY_TRACKING)
  1.1022 +#   if(COMPILER_IS_GNUCC)
  1.1023 +#     set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -MMD -MT \$@")
  1.1024 +#   endif(COMPILER_IS_GNUCC)
  1.1025 +# endif(DEPENDENCY_TRACKING)
  1.1026 +
  1.1027 +configure_file("${SDL2_SOURCE_DIR}/include/SDL_config.h.cmake"
  1.1028 +  "${SDL2_BINARY_DIR}/include/SDL_config.h")
  1.1029 +
  1.1030 +# Prepare the flags and remove duplicates
  1.1031 +if(EXTRA_LDFLAGS)
  1.1032 +  list(REMOVE_DUPLICATES EXTRA_LDFLAGS)
  1.1033 +endif(EXTRA_LDFLAGS)
  1.1034 +if(EXTRA_LIBS)
  1.1035 +  list(REMOVE_DUPLICATES EXTRA_LIBS)
  1.1036 +endif(EXTRA_LIBS)
  1.1037 +if(EXTRA_CFLAGS)
  1.1038 +  list(REMOVE_DUPLICATES EXTRA_CFLAGS)
  1.1039 +endif(EXTRA_CFLAGS)
  1.1040 +listtostr(EXTRA_CFLAGS _EXTRA_CFLAGS)
  1.1041 +set(EXTRA_CFLAGS ${_EXTRA_CFLAGS})
  1.1042 +
  1.1043 +# Compat helpers for the configuration files
  1.1044 +if(NOT WINDOWS OR CYGWIN)
  1.1045 +  # TODO: we need a Windows script, too
  1.1046 +  execute_process(COMMAND sh ${SDL2_SOURCE_DIR}/build-scripts/updaterev.sh)
  1.1047 +
  1.1048 +  set(prefix ${CMAKE_INSTALL_PREFIX})
  1.1049 +  set(exec_prefix "\${prefix}")
  1.1050 +  set(libdir "\${exec_prefix}/lib${LIB_SUFFIX}")
  1.1051 +  set(bindir "\${exec_prefix}/bin")
  1.1052 +  set(includedir "\${prefix}/include")
  1.1053 +  if(SDL_STATIC)
  1.1054 +    set(ENABLE_STATIC_TRUE "")
  1.1055 +    set(ENABLE_STATIC_FALSE "#")
  1.1056 +  else(SDL_STATIC)
  1.1057 +    set(ENABLE_STATIC_TRUE "#")
  1.1058 +    set(ENABLE_STATIC_FALSE "")
  1.1059 +  endif(SDL_STATIC)
  1.1060 +  if(SDL_SHARED)
  1.1061 +    set(ENABLE_SHARED_TRUE "")
  1.1062 +    set(ENABLE_SHARED_FALSE "#")
  1.1063 +  else(SDL_SHARED)
  1.1064 +    set(ENABLE_SHARED_TRUE "#")
  1.1065 +    set(ENABLE_SHARED_FALSE "")
  1.1066 +  endif(SDL_SHARED)
  1.1067 +
  1.1068 +  # Clean up the different lists
  1.1069 +  listtostr(EXTRA_LIBS _EXTRA_LIBS "-l")
  1.1070 +  set(SDL_STATIC_LIBS ${SDL_LIBS} ${EXTRA_LDFLAGS} ${_EXTRA_LIBS})
  1.1071 +  list(REMOVE_DUPLICATES SDL_STATIC_LIBS)
  1.1072 +  listtostr(SDL_STATIC_LIBS _SDL_STATIC_LIBS)
  1.1073 +  set(SDL_STATIC_LIBS ${_SDL_STATIC_LIBS})
  1.1074 +  listtostr(SDL_LIBS _SDL_LIBS)
  1.1075 +  set(SDL_LIBS ${_SDL_LIBS})
  1.1076 +
  1.1077 +  # MESSAGE(STATUS "SDL_LIBS: ${SDL_LIBS}")
  1.1078 +  # MESSAGE(STATUS "SDL_STATIC_LIBS: ${SDL_STATIC_LIBS}")
  1.1079 +
  1.1080 +  configure_file("${SDL2_SOURCE_DIR}/sdl2.pc.in"
  1.1081 +    "${SDL2_BINARY_DIR}/sdl2.pc" @ONLY)
  1.1082 +  configure_file("${SDL2_SOURCE_DIR}/sdl2-config.in"
  1.1083 +    "${SDL2_BINARY_DIR}/sdl2-config")
  1.1084 +  configure_file("${SDL2_SOURCE_DIR}/sdl2-config.in"
  1.1085 +    "${SDL2_BINARY_DIR}/sdl2-config" @ONLY)
  1.1086 +  configure_file("${SDL2_SOURCE_DIR}/SDL2.spec.in"
  1.1087 +    "${SDL2_BINARY_DIR}/SDL2.spec" @ONLY)
  1.1088 +endif(NOT WINDOWS OR CYGWIN)
  1.1089 +
  1.1090 +##### Info output #####
  1.1091 +message(STATUS "")
  1.1092 +message(STATUS "SDL2 was configured with the following options:")
  1.1093 +message(STATUS "")
  1.1094 +message(STATUS "Platform: ${CMAKE_SYSTEM}")
  1.1095 +message(STATUS "64-bit:   ${ARCH_64}")
  1.1096 +message(STATUS "Compiler: ${CMAKE_C_COMPILER}")
  1.1097 +message(STATUS "")
  1.1098 +message(STATUS "Subsystems:")
  1.1099 +foreach(_SUB ${SDL_SUBSYSTEMS})
  1.1100 +  string(TOUPPER ${_SUB} _OPT)
  1.1101 +  message_bool_option(${_SUB} SDL_${_OPT})
  1.1102 +endforeach()
  1.1103 +message(STATUS "")
  1.1104 +message(STATUS "Options:")
  1.1105 +list(SORT ALLOPTIONS)
  1.1106 +foreach(_OPT ${ALLOPTIONS})
  1.1107 +  # Longest option is VIDEO_X11_XSCREENSAVER = 22 characters
  1.1108 +  # Get the padding
  1.1109 +  string(LENGTH ${_OPT} _OPTLEN)
  1.1110 +  math(EXPR _PADLEN "23 - ${_OPTLEN}")
  1.1111 +  string(RANDOM LENGTH ${_PADLEN} ALPHABET " " _PADDING)
  1.1112 +  message_tested_option(${_OPT} ${_PADDING})
  1.1113 +endforeach()
  1.1114 +message(STATUS "")
  1.1115 +message(STATUS " CFLAGS:        ${CMAKE_C_FLAGS}")
  1.1116 +message(STATUS " EXTRA_CFLAGS:  ${EXTRA_CFLAGS}")
  1.1117 +message(STATUS " EXTRA_LDFLAGS: ${EXTRA_LDFLAGS}")
  1.1118 +message(STATUS " EXTRA_LIBS:    ${EXTRA_LIBS}")
  1.1119 +message(STATUS "")
  1.1120 +message(STATUS " Build Shared Library: ${SDL_SHARED}")
  1.1121 +message(STATUS " Build Static Library: ${SDL_STATIC}")
  1.1122 +message(STATUS "")
  1.1123 +if(UNIX)
  1.1124 +  message(STATUS "Something was not detected, although your are sure that it")
  1.1125 +  message(STATUS "has been properly installed? Then make sure, you have set")
  1.1126 +  message(STATUS "the CFLAGS and LDFLAGS environment variables correctly.")
  1.1127 +  message(STATUS "")
  1.1128 +endif(UNIX)
  1.1129 +
  1.1130 +# Ensure that the extra cflags are used at compile time
  1.1131 +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
  1.1132 +
  1.1133 +# Always build SDLmain
  1.1134 +add_library(SDL2main STATIC ${SDLMAIN_SOURCES})
  1.1135 +set(_INSTALL_LIBS "SDL2main")
  1.1136 +
  1.1137 +if(SDL_SHARED)
  1.1138 +  add_library(SDL2 SHARED ${SOURCE_FILES})
  1.1139 +  set_target_properties(SDL2 PROPERTIES
  1.1140 +    VERSION ${SDL_VERSION}
  1.1141 +    SOVERSION ${LT_CURRENT})
  1.1142 + set(_INSTALL_LIBS "SDL2" ${_INSTALL_LIBS})
  1.1143 + target_link_libraries(SDL2 ${EXTRA_LIBS} ${EXTRA_LDFLAGS})
  1.1144 +endif(SDL_SHARED)
  1.1145 +
  1.1146 +if(SDL_STATIC)
  1.1147 +  add_library(SDL2-static STATIC ${SOURCE_FILES})
  1.1148 +  set_target_properties(SDL2-static PROPERTIES OUTPUT_NAME "SDL2")
  1.1149 +  # TODO: Win32 platforms keep the same suffix .lib for import and static
  1.1150 +  # libraries - do we need to consider this?
  1.1151 +  set(_INSTALL_LIBS "SDL2-static" ${_INSTALL_LIBS})
  1.1152 +  target_link_libraries(SDL2-static ${EXTRA_LIBS} ${EXTRA_LDFLAGS})
  1.1153 +endif(SDL_STATIC)
  1.1154 +
  1.1155 +##### Installation targets #####
  1.1156 +install(TARGETS ${_INSTALL_LIBS}
  1.1157 +  LIBRARY DESTINATION "lib${LIB_SUFFIX}"
  1.1158 +  ARCHIVE DESTINATION "lib${LIB_SUFFIX}")
  1.1159 +
  1.1160 +file(GLOB INCLUDE_FILES ${SDL2_SOURCE_DIR}/include/*.h)
  1.1161 +file(GLOB BIN_INCLUDE_FILES ${SDL2_BINARY_DIR}/include/*.h)
  1.1162 +foreach(_FNAME ${BIN_INCLUDE_FILES})
  1.1163 +  get_filename_component(_INCNAME ${_FNAME} NAME)
  1.1164 +  list(REMOVE_ITEM INCLUDE_FILES ${SDL2_SOURCE_DIR}/include/${_INCNAME})
  1.1165 +endforeach()
  1.1166 +list(APPEND INCLUDE_FILES ${BIN_INCLUDE_FILES})
  1.1167 +install(FILES ${INCLUDE_FILES} DESTINATION include/SDL2)
  1.1168 +
  1.1169 +if(NOT WINDOWS OR CYGWIN)
  1.1170 +  if(FREEBSD)
  1.1171 +    # FreeBSD uses ${PREFIX}/libdata/pkgconfig
  1.1172 +    install(FILES ${SDL2_BINARY_DIR}/sdl2.pc DESTINATION "libdata/pkgconfig")
  1.1173 +  else(FREEBSD)
  1.1174 +    install(FILES ${SDL2_BINARY_DIR}/sdl2.pc
  1.1175 +      DESTINATION "lib${LIB_SUFFIX}/pkgconfig")
  1.1176 +  endif(FREEBSD)
  1.1177 +  install(PROGRAMS ${SDL2_BINARY_DIR}/sdl2-config DESTINATION bin)
  1.1178 +  # TODO: what about the .spec file? Is it only needed for RPM creation?
  1.1179 +endif(NOT WINDOWS OR CYGWIN)
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/README.cmake	Fri Nov 16 09:23:18 2012 -0300
     2.3 @@ -0,0 +1,31 @@
     2.4 +================================================================================
     2.5 +CMake build system for SDL (www.cmake.org)
     2.6 +================================================================================
     2.7 +
     2.8 +SDL's build system was traditionally based on autotools. Over time, this
     2.9 +approach has suffered from several issues across the different supported 
    2.10 +platforms.
    2.11 +To solve these problems, a new build system based on CMake is under development.
    2.12 +It works in parallel to the legacy system, so users can experiment with it
    2.13 +without complication.
    2.14 +While still experimental, the build system should be usable on the following
    2.15 +platforms:
    2.16 +    
    2.17 +    * FreeBSD
    2.18 +    * Linux
    2.19 +    * VS.NET 2010
    2.20 +    * MinGW and Msys
    2.21 +    * OS X with support for XCode
    2.22 +    
    2.23 +================================================================================
    2.24 +Usage
    2.25 +================================================================================
    2.26 +
    2.27 +Assuming the source for SDL is located at ~/sdl
    2.28 +
    2.29 +cd ~
    2.30 +mkdir build
    2.31 +cd build
    2.32 +cmake ../sdl
    2.33 +
    2.34 +This will build the static and dynamic versions of SDL in the ~/build directory.
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/cmake/macros.cmake	Fri Nov 16 09:23:18 2012 -0300
     3.3 @@ -0,0 +1,65 @@
     3.4 +macro(SET_OPTION _NAME _DESC)
     3.5 +  list(APPEND ALLOPTIONS ${_NAME})
     3.6 +  if(${ARGC} EQUAL 3)
     3.7 +    set(_DEFLT ${ARGV2})
     3.8 +  else()
     3.9 +    set(_DEFLT OFF)
    3.10 +  endif()
    3.11 +  option(${_NAME} ${_DESC} ${_DEFLT})
    3.12 +endmacro()
    3.13 +
    3.14 +macro(DEP_OPTION _NAME _DESC _DEFLT _DEPTEST _FAILDFLT)
    3.15 +  list(APPEND ALLOPTIONS ${_NAME})
    3.16 +  cmake_dependent_option(${_NAME} ${_DESC} ${_DEFLT} ${_DEPTEST} ${_FAILDFLT})
    3.17 +endmacro()
    3.18 +
    3.19 +macro(OPTION_STRING _NAME _DESC _VALUE)
    3.20 +  list(APPEND ALLOPTIONS ${_NAME})
    3.21 +  set(${_NAME} ${_VALUE} CACHE STRING "${_DESC}")
    3.22 +  set(HAVE_${_NAME} ${_VALUE})
    3.23 +ENDMACRO()
    3.24 +
    3.25 +# Message Output
    3.26 +macro(MESSAGE_WARN _TEXT)
    3.27 +  message(STATUS "*** WARNING: ${_TEXT}")
    3.28 +endmacro()
    3.29 +
    3.30 +macro(MESSAGE_ERROR _TEXT)
    3.31 +  message(FATAL_ERROR "*** ERROR: ${_TEXT}")
    3.32 +endmacro()
    3.33 +
    3.34 +macro(MESSAGE_BOOL_OPTION _NAME _VALUE)
    3.35 +  if(${_VALUE})
    3.36 +    message(STATUS "  ${_NAME}:\tON")
    3.37 +  else()
    3.38 +    message(STATUS "  ${_NAME}:\tOFF")
    3.39 +  endif()
    3.40 +endmacro()
    3.41 +
    3.42 +macro(MESSAGE_TESTED_OPTION _NAME)
    3.43 +  set(_REQVALUE ${${_NAME}})
    3.44 +  set(_PAD " ")
    3.45 +  if(${ARGC} EQUAL 2)
    3.46 +    set(_PAD ${ARGV1})
    3.47 +  endif()
    3.48 +  if(NOT HAVE_${_NAME})
    3.49 +    set(HAVE_${_NAME} OFF)
    3.50 +  elseif("${HAVE_${_NAME}}" MATCHES "1|TRUE|YES|Y")
    3.51 +    set(HAVE_${_NAME} ON)
    3.52 +  endif()
    3.53 +  message(STATUS "  ${_NAME}${_PAD}(Wanted: ${_REQVALUE}): ${HAVE_${_NAME}}")
    3.54 +endmacro()
    3.55 +
    3.56 +macro(LISTTOSTR _LIST _OUTPUT)
    3.57 +  if(${ARGC} EQUAL 3)
    3.58 +    # prefix for each element
    3.59 +    set(_LPREFIX ${ARGV2})
    3.60 +  else()
    3.61 +    set(_LPREFIX "")
    3.62 +  endif()
    3.63 +  # Do not use string(REPLACE ";" " ") here to avoid messing up list
    3.64 +  # entries
    3.65 +  foreach(_ITEM ${${_LIST}})
    3.66 +    set(${_OUTPUT} "${_LPREFIX}${_ITEM} ${${_OUTPUT}}")
    3.67 +  endforeach()
    3.68 +endmacro()
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/cmake/sdlchecks.cmake	Fri Nov 16 09:23:18 2012 -0300
     4.3 @@ -0,0 +1,808 @@
     4.4 +macro(CheckDLOPEN)
     4.5 +  check_function_exists(dlopen HAVE_DLOPEN)
     4.6 +  if(NOT HAVE_DLOPEN)
     4.7 +    foreach(_LIBNAME dl tdl)
     4.8 +      check_library_exists("${_LIBNAME}" "dlopen" "" DLOPEN_LIB)
     4.9 +      if(DLOPEN_LIB)
    4.10 +        list(APPEND EXTRA_LIBS ${_LIBNAME})
    4.11 +        set(_DLLIB ${_LIBNAME})
    4.12 +        set(HAVE_DLOPEN TRUE)
    4.13 +        break()
    4.14 +      endif(DLOPEN_LIB)
    4.15 +    endforeach()
    4.16 +  endif()
    4.17 +
    4.18 +  if(HAVE_DLOPEN)
    4.19 +    if(_DLLIB)
    4.20 +      set(CMAKE_REQUIRED_LIBRARIES ${_DLLIB})
    4.21 +    endif()
    4.22 +    check_c_source_compiles("
    4.23 +       #include <dlfcn.h>
    4.24 +       #if defined(MAC_OS_X_VERSION_MIN_REQUIRED) && MAC_OS_X_VERSION_MIN_REQUIRED <= 1020
    4.25 +       #error Use dlcompat for Mac OS X 10.2 compatibility
    4.26 +       #endif
    4.27 +       int main(int argc, char **argv) {}" HAVE_DLOPEN)
    4.28 +    set(CMAKE_REQUIRED_LIBRARIES)
    4.29 +  endif()
    4.30 +
    4.31 +  if (HAVE_DLOPEN)
    4.32 +    set(SDL_LOADSO_DLOPEN 1)
    4.33 +    set(HAVE_SDL_DLOPEN TRUE)
    4.34 +    file(GLOB DLOPEN_SOURCES ${SDL2_SOURCE_DIR}/src/loadso/dlopen/*.c)
    4.35 +    set(SOURCE_FILES ${SOURCE_FILES} ${DLOPEN_SOURCES})
    4.36 +    set(HAVE_SDL_LOADSO TRUE)
    4.37 +  endif()
    4.38 +endmacro(CheckDLOPEN)
    4.39 +
    4.40 +# Requires:
    4.41 +# - n/a
    4.42 +macro(CheckOSS)
    4.43 +  if(OSS)
    4.44 +    set(OSS_HEADER_FILE "sys/soundcard.h")
    4.45 +    check_c_source_compiles("
    4.46 +        #include <sys/soundcard.h>
    4.47 +        int main() { int arg = SNDCTL_DSP_SETFRAGMENT; }" OSS_FOUND)
    4.48 +    if(NOT OSS_FOUND)
    4.49 +      set(OSS_HEADER_FILE "soundcard.h")
    4.50 +      check_c_source_compiles("
    4.51 +          #include <soundcard.h>
    4.52 +          int main() { int arg = SNDCTL_DSP_SETFRAGMENT; }" OSS_FOUND)
    4.53 +    endif(NOT OSS_FOUND)
    4.54 +
    4.55 +    if(OSS_FOUND)
    4.56 +      set(HAVE_OSS TRUE)
    4.57 +      file(GLOB OSS_SOURCES ${SDL2_SOURCE_DIR}/src/audio/dsp/*.c)
    4.58 +      if(OSS_HEADER_FILE STREQUAL "soundcard.h")
    4.59 +        set(SDL_AUDIO_DRIVER_OSS_SOUNDCARD_H 1)
    4.60 +      endif(OSS_HEADER_FILE STREQUAL "soundcard.h")
    4.61 +      set(SDL_AUDIO_DRIVER_OSS 1)
    4.62 +      set(SOURCE_FILES ${SOURCE_FILES} ${OSS_SOURCES})
    4.63 +      if(NETBSD OR OPENBSD)
    4.64 +        list(APPEND EXTRA_LIBS ossaudio)
    4.65 +      endif(NETBSD OR OPENBSD)
    4.66 +      set(HAVE_SDL_AUDIO TRUE)
    4.67 +    endif(OSS_FOUND)
    4.68 +  endif(OSS)
    4.69 +endmacro(CheckOSS)
    4.70 +
    4.71 +# Requires:
    4.72 +# - n/a
    4.73 +# Optional:
    4.74 +# - ALSA_SHARED opt
    4.75 +# - HAVE_DLOPEN opt
    4.76 +macro(CheckALSA)
    4.77 +  if(ALSA)
    4.78 +    CHECK_INCLUDE_FILE(alsa/asoundlib.h HAVE_ASOUNDLIB_H)
    4.79 +    if(HAVE_ASOUNDLIB_H)
    4.80 +      CHECK_LIBRARY_EXISTS(asound snd_pcm_open "" HAVE_LIBASOUND)
    4.81 +      set(HAVE_ALSA TRUE)
    4.82 +      file(GLOB ALSA_SOURCES ${SDL2_SOURCE_DIR}/src/audio/alsa/*.c)
    4.83 +      set(SOURCE_FILES ${SOURCE_FILES} ${ALSA_SOURCES})
    4.84 +      set(SDL_AUDIO_DRIVER_ALSA 1)
    4.85 +      if(ALSA_SHARED)
    4.86 +        if(NOT HAVE_DLOPEN)
    4.87 +          message_warn("You must have SDL_LoadObject() support for dynamic ALSA loading")
    4.88 +        else()
    4.89 +          find_library(_ALSA_LIB asound)
    4.90 +          get_filename_component(F_ALSA_LIB ${_ALSA_LIB} NAME)
    4.91 +          set(SDL_AUDIO_DRIVER_ALSA_DYNAMIC "\"${F_ALSA_LIB}\"")
    4.92 +          set(HAVE_ALSA_SHARED TRUE)
    4.93 +        endif(NOT HAVE_DLOPEN)
    4.94 +      else(ALSA_SHARED)
    4.95 +        list(APPEND EXTRA_LIBS asound)
    4.96 +      endif(ALSA_SHARED)
    4.97 +      set(HAVE_SDL_AUDIO TRUE)
    4.98 +    endif(HAVE_ASOUNDLIB_H)
    4.99 +  endif(ALSA)
   4.100 +endmacro(CheckALSA)
   4.101 +
   4.102 +# Requires:
   4.103 +# - PkgCheckModules
   4.104 +# Optional:
   4.105 +# - PULSEAUDIO_SHARED opt
   4.106 +# - HAVE_DLOPEN opt
   4.107 +macro(CheckPulseAudio)
   4.108 +  if(PULSEAUDIO)
   4.109 +    pkg_check_modules(PKG_PULSEAUDIO libpulse-simple)
   4.110 +    if(PKG_PULSEAUDIO_FOUND)
   4.111 +      set(HAVE_PULSEAUDIO TRUE)
   4.112 +      file(GLOB PULSEAUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/pulseaudio/*.c)
   4.113 +      set(SOURCE_FILES ${SOURCE_FILES} ${PULSEAUDIO_SOURCES})
   4.114 +      set(SDL_AUDIO_DRIVER_PULSEAUDIO 1)
   4.115 +      list(APPEND EXTRA_CFLAGS ${PKG_PULSEAUDIO_CFLAGS})
   4.116 +      if(PULSEAUDIO_SHARED)
   4.117 +        if(NOT HAVE_DLOPEN)
   4.118 +          message_warn("You must have SDL_LoadObject() support for dynamic PulseAudio loading")
   4.119 +        else()
   4.120 +          find_library(D_PULSE_LIB pulse-simple)
   4.121 +          get_filename_component(F_PULSE_LIB ${D_PULSE_LIB} NAME)
   4.122 +          set(SDL_AUDIO_DRIVER_PULSEAUDIO_DYNAMIC "\"${F_PULSE_LIB}\"")
   4.123 +          set(HAVE_PULSEAUDIO_SHARED TRUE)
   4.124 +        endif(NOT HAVE_DLOPEN)
   4.125 +      else(PULSEAUDIO_SHARED)
   4.126 +        list(APPEND EXTRA_LDFLAGS ${PKG_PULSEAUDIO_LDFLAGS})
   4.127 +      endif(PULSEAUDIO_SHARED)
   4.128 +      set(HAVE_SDL_AUDIO TRUE)
   4.129 +    endif(PKG_PULSEAUDIO_FOUND)
   4.130 +  endif(PULSEAUDIO)
   4.131 +endmacro(CheckPulseAudio)
   4.132 +
   4.133 +# Requires:
   4.134 +# - PkgCheckModules
   4.135 +# Optional:
   4.136 +# - ESD_SHARED opt
   4.137 +# - HAVE_DLOPEN opt
   4.138 +macro(CheckESD)
   4.139 +  if(ESD)
   4.140 +    pkg_check_modules(PKG_ESD esound)
   4.141 +    if(PKG_ESD_FOUND)
   4.142 +      set(HAVE_ESD TRUE)
   4.143 +      file(GLOB ESD_SOURCES ${SDL2_SOURCE_DIR}/src/audio/esd/*.c)
   4.144 +      set(SOURCE_FILES ${SOURCE_FILES} ${ESD_SOURCES})
   4.145 +      set(SDL_AUDIO_DRIVER_ESD 1)
   4.146 +      list(APPEND EXTRA_CFLAGS ${PKG_ESD_CFLAGS})
   4.147 +      if(ESD_SHARED)
   4.148 +        if(NOT HAVE_DLOPEN)
   4.149 +          message_warn("You must have SDL_LoadObject() support for dynamic ESD loading")
   4.150 +        else()
   4.151 +          find_library(D_ESD_LIB esd)
   4.152 +          get_filename_component(F_ESD_LIB ${D_ESD_LIB} NAME)
   4.153 +          set(SDL_AUDIO_DRIVER_ESD_DYNAMIC "\"${F_ESD_LIB}\"")
   4.154 +          set(HAVE_ESD_SHARED TRUE)
   4.155 +        endif(NOT HAVE_DLOPEN)
   4.156 +      else(ESD_SHARED)
   4.157 +        list(APPEND EXTRA_LDFLAGS ${PKG_ESD_LDFLAGS})
   4.158 +      endif(ESD_SHARED)
   4.159 +      set(HAVE_SDL_AUDIO TRUE)
   4.160 +    endif(PKG_ESD_FOUND)
   4.161 +  endif(ESD)
   4.162 +endmacro(CheckESD)
   4.163 +
   4.164 +# Requires:
   4.165 +# - n/a
   4.166 +# Optional:
   4.167 +# - ARTS_SHARED opt
   4.168 +# - HAVE_DLOPEN opt
   4.169 +macro(CheckARTS)
   4.170 +  if(ARTS)
   4.171 +    find_program(ARTS_CONFIG arts-config)
   4.172 +    if(ARTS_CONFIG)
   4.173 +      execute_process(CMD_ARTSCFLAGS ${ARTS_CONFIG} --cflags
   4.174 +        OUTPUT_VARIABLE ARTS_CFLAGS OUTPUT_STRIP_TRAILING_WHITESPACE)
   4.175 +      list(APPEND EXTRA_CFLAGS ${ARTS_CFLAGS})
   4.176 +      execute_process(CMD_ARTSLIBS ${ARTS_CONFIG} --libs
   4.177 +        OUTPUT_VARIABLE ARTS_LIBS OUTPUT_STRIP_TRAILING_WHITESPACE)
   4.178 +      file(GLOB ARTS_SOURCES ${SDL2_SOURCE_DIR}/src/audio/arts/*.c)
   4.179 +      set(SOURCE_FILES ${SOURCE_FILES} ${ARTS_SOURCES})
   4.180 +      set(SDL_AUDIO_DRIVER_ARTS 1)
   4.181 +      set(HAVE_ARTS TRUE)
   4.182 +      if(ARTS_SHARED)
   4.183 +        if(NOT HAVE_DLOPEN)
   4.184 +          message_warn("You must have SDL_LoadObject() support for dynamic ARTS loading")
   4.185 +        else()
   4.186 +          # TODO
   4.187 +          find_library(D_ARTS_LIB artsc)
   4.188 +          get_filename_component(F_ARTS_LIB ${D_ARTS_LIB} NAME)
   4.189 +          set(SDL_AUDIO_DRIVER_ARTS_DYNAMIC "\"${F_ARTS_LIB}\"")
   4.190 +          set(HAVE_ARTS_SHARED TRUE)
   4.191 +        endif(NOT HAVE_DLOPEN)
   4.192 +      else(ARTS_SHARED)
   4.193 +        list(APPEND EXTRA_LDFLAGS ${ARTS_LIBS})
   4.194 +      endif(ARTS_SHARED)
   4.195 +      set(HAVE_SDL_AUDIO TRUE)
   4.196 +    endif(ARTS_CONFIG)
   4.197 +  endif(ARTS)
   4.198 +endmacro(CheckARTS)
   4.199 +
   4.200 +# Requires:
   4.201 +# - n/a
   4.202 +# Optional:
   4.203 +# - NAS_SHARED opt
   4.204 +# - HAVE_DLOPEN opt
   4.205 +macro(CheckNAS)
   4.206 +  if(NAS)
   4.207 +    # TODO: set include paths properly, so the NAS headers are found
   4.208 +    check_include_file(audio/audiolib.h HAVE_NAS_H)
   4.209 +    find_library(D_NAS_LIB audio)
   4.210 +    if(HAVE_NAS_H AND D_NAS_LIB)
   4.211 +      set(HAVE_NAS TRUE)
   4.212 +      file(GLOB NAS_SOURCES ${SDL2_SOURCE_DIR}/src/audio/nas/*.c)
   4.213 +      set(SOURCE_FILES ${SOURCE_FILES} ${NAS_SOURCES})
   4.214 +      set(SDL_AUDIO_DRIVER_NAS 1)
   4.215 +      if(NAS_SHARED)
   4.216 +        if(NOT HAVE_DLOPEN)
   4.217 +          message_warn("You must have SDL_LoadObject() support for dynamic NAS loading")
   4.218 +        else()
   4.219 +          get_filename_component(F_NAS_LIB ${D_NAS_LIB} NAME)
   4.220 +          set(SDL_AUDIO_DRIVER_NAS_DYNAMIC "\"${F_NAS_LIB}\"")
   4.221 +          set(HAVE_NAS_SHARED TRUE)
   4.222 +        endif(NOT HAVE_DLOPEN)
   4.223 +      else(NAS_SHARED)
   4.224 +        list(APPEND EXTRA_LIBS ${D_NAS_LIB})
   4.225 +      endif(NAS_SHARED)
   4.226 +      set(HAVE_SDL_AUDIO TRUE)
   4.227 +    endif(HAVE_NAS_H AND D_NAS_LIB)
   4.228 +  endif(NAS)
   4.229 +endmacro(CheckNAS)
   4.230 +
   4.231 +# Requires:
   4.232 +# - PkgCheckModules
   4.233 +# Optional:
   4.234 +# - FUSIONSOUND_SHARED opt
   4.235 +# - HAVE_DLOPEN opt
   4.236 +macro(CheckFusionSound)
   4.237 +  if(FUSIONSOUND)
   4.238 +    pkg_check_modules(PKG_FUSIONSOUND fusionsound>=1.0.0)
   4.239 +    if(PKG_FUSIONSOUND_FOUND)
   4.240 +      set(HAVE_FUSIONSOUND TRUE)
   4.241 +      file(GLOB FUSIONSOUND_SOURCES ${SDL2_SOURCE_DIR}/src/audio/fusionsound/*.c)
   4.242 +      set(SOURCE_FILES ${SOURCE_FILES} ${FUSIONSOUND_SOURCES})
   4.243 +      set(SDL_AUDIO_DRIVER_FUSIONSOUND 1)
   4.244 +      list(APPEND EXTRA_CFLAGS ${PKG_FUSIONSOUND_CFLAGS})
   4.245 +      if(FUSIONSOUND_SHARED)
   4.246 +        if(NOT HAVE_DLOPEN)
   4.247 +          message_warn("You must have SDL_LoadObject() support for dynamic FusionSound loading")
   4.248 +        else()
   4.249 +          find_library(D_FUSIONSOUND_LIB fusionsound)
   4.250 +          get_filename_component(F_FUSIONSOUND_LIB ${D_FUSIONSOUND_LIB} NAME)
   4.251 +          set(SDL_AUDIO_DRIVER_FUSIONSOUND_DYNAMIC "\"${F_FUSIONSOUND_LIB}\"")
   4.252 +          set(HAVE_FUSIONSOUND_SHARED TRUE)
   4.253 +        endif(NOT HAVE_DLOPEN)
   4.254 +      else(FUSIONSOUND_SHARED)
   4.255 +        list(APPEND EXTRA_LDFLAGS ${PKG_FUSIONSOUND_LDFLAGS})
   4.256 +      endif(FUSIONSOUND_SHARED)
   4.257 +      set(HAVE_SDL_AUDIO TRUE)
   4.258 +    endif(PKG_FUSIONSOUND_FOUND)
   4.259 +  endif(FUSIONSOUND)
   4.260 +endmacro(CheckFusionSound)
   4.261 +
   4.262 +# Requires:
   4.263 +# - n/a
   4.264 +# Optional:
   4.265 +# - X11_SHARED opt
   4.266 +# - HAVE_DLOPEN opt
   4.267 +macro(CheckX11)
   4.268 +  if(VIDEO_X11)
   4.269 +    foreach(_LIB X11 Xext Xcursor Xinerama Xi Xrandr Xrender Xss Xxf86vm)
   4.270 +      string(TOUPPER ${_LIB} _LNAME)
   4.271 +      find_library(${_LNAME}_LIB ${_LIB})
   4.272 +      if(${_LNAME}_LIB)
   4.273 +        # reduce the library name for shared linking
   4.274 +        get_filename_component(_TMP ${${_LNAME}_LIB} NAME)
   4.275 +        set(${_LNAME}_LIB ${_TMP})
   4.276 +      endif()
   4.277 +    endforeach()
   4.278 +
   4.279 +    check_include_file(X11/Xcursor/Xcursor.h HAVE_XCURSOR_H)
   4.280 +    check_include_file(X11/extensions/Xinerama.h HAVE_XINERAMA_H)
   4.281 +    check_include_file(X11/extensions/XInput2.h HAVE_XINPUT_H)
   4.282 +    check_include_file(X11/extensions/Xrandr.h HAVE_XRANDR_H)
   4.283 +    check_include_file(X11/extensions/Xrender.h HAVE_XRENDER_H)
   4.284 +    check_include_file(X11/extensions/scrnsaver.h HAVE_XSS_H)
   4.285 +    check_include_file(X11/extensions/shape.h HAVE_XSHAPE_H)
   4.286 +    check_include_files("X11/Xlib.h;X11/extensions/xf86vmode.h" HAVE_XF86VM_H)
   4.287 +
   4.288 +    if(X11_LIB)
   4.289 +      set(HAVE_VIDEO_X11 TRUE)
   4.290 +      set(HAVE_SDL_VIDEO TRUE)
   4.291 +
   4.292 +      file(GLOB X11_SOURCES ${SDL2_SOURCE_DIR}/src/video/x11/*.c)
   4.293 +      set(SOURCE_FILES ${SOURCE_FILES} ${X11_SOURCES})
   4.294 +      set(SDL_VIDEO_DRIVER_X11 1)
   4.295 +
   4.296 +      if(HAVE_GCC_FVISIBILITY)
   4.297 +        set(X11_SYMBOLS_PRIVATE TRUE)
   4.298 +      else()
   4.299 +        set(X11_SYMBOLS_PRIVATE FALSE)
   4.300 +      endif(HAVE_GCC_FVISIBILITY)
   4.301 +
   4.302 +      if(APPLE)
   4.303 +        set(X11_SHARED OFF)
   4.304 +        set(X11_SYMBOLS_PRIVATE TRUE)
   4.305 +      endif(APPLE)
   4.306 +
   4.307 +      check_function_exists("shmat" HAVE_SHMAT)
   4.308 +      if(NOT HAVE_SHMAT)
   4.309 +        check_library_exists(ipc shmat "" HAVE_SHMAT)
   4.310 +        if(HAVE_SHMAT)
   4.311 +          list(APPEND EXTRA_LIBS ipc)
   4.312 +        endif(HAVE_SHMAT)
   4.313 +        if(NOT HAVE_SHMAT)
   4.314 +          add_definitions(-DNO_SHARED_MEMORY)
   4.315 +        endif(NOT HAVE_SHMAT)
   4.316 +      endif(NOT HAVE_SHMAT)
   4.317 +
   4.318 +      if(X11_SHARED)
   4.319 +        if(NOT HAVE_DLOPEN)
   4.320 +          message_warn("You must have SDL_LoadObject() support for dynamic X11 loading")
   4.321 +          set(HAVE_X11_SHARED FALSE)
   4.322 +          if(X11_SYMBOLS_PRIVATE)
   4.323 +            message_warn("You must have gcc4 (-fvisibility=hidden) for dynamic X11 loading")
   4.324 +            set(HAVE_X11_SHARED TRUE)
   4.325 +          endif(X11_SYMBOLS_PRIVATE)
   4.326 +        else(NOT HAVE_DLOPEN)
   4.327 +          set(HAVE_X11_SHARED TRUE)
   4.328 +        endif()
   4.329 +        if(HAVE_X11_SHARED)
   4.330 +          set(SDL_VIDEO_DRIVER_X11_DYNAMIC "\"${X11_LIB}\"")
   4.331 +          set(SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT "\"${XEXT_LIB}\"")
   4.332 +        else(HAVE_X11_SHARED)
   4.333 +          list(APPEND EXTRA_LIBS ${X11_LIB} ${XEXT_LIB})
   4.334 +        endif(HAVE_X11_SHARED)
   4.335 +      endif(X11_SHARED)
   4.336 +
   4.337 +      set(CMAKE_REQUIRED_LIBRARIES ${X11_LIB} ${X11_LIB})
   4.338 +      check_c_source_compiles("
   4.339 +          #include <X11/Xlib.h>
   4.340 +          #include <X11/Xproto.h>
   4.341 +          #include <X11/extensions/Xext.h>
   4.342 +          #include <X11/extensions/extutil.h>
   4.343 +          extern XExtDisplayInfo* XextAddDisplay(XExtensionInfo* a,Display* b,_Xconst char* c,XExtensionHooks* d,int e,XPointer f);
   4.344 +          int main(int argc, char **argv) {}" HAVE_CONST_XEXT_ADDDISPLAY)
   4.345 +      if(HAVE_CONST_XEXT_ADDDISPLAY)
   4.346 +        set(SDL_VIDEO_DRIVER_X11_CONST_PARAM_XEXTADDDISPLAY 1)
   4.347 +      endif(HAVE_CONST_XEXT_ADDDISPLAY)
   4.348 +
   4.349 +      check_c_source_compiles("
   4.350 +          #include <X11/Xlib.h>
   4.351 +          int main(int argc, char **argv) {
   4.352 +            Display *display;
   4.353 +            XEvent event;
   4.354 +            XGenericEventCookie *cookie = &event.xcookie;
   4.355 +            XNextEvent(display, &event);
   4.356 +            XGetEventData(display, cookie);
   4.357 +            XFreeEventData(display, cookie); }" HAVE_XGENERICEVENT)
   4.358 +      if(HAVE_XGENERICEVENT)
   4.359 +        set(SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS 1)
   4.360 +      endif(HAVE_XGENERICEVENT)
   4.361 +
   4.362 +      check_function_exists(XkbKeycodeToKeysym SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM)
   4.363 +
   4.364 +      if(VIDEO_X11_XCURSOR AND HAVE_XCURSOR_H)
   4.365 +        set(HAVE_VIDEO_X11_XCURSOR TRUE)
   4.366 +        if(HAVE_X11_SHARED AND XCURSOR_LIB)
   4.367 +          set(SDL_VIDEO_DRIVER_X11_DYNAMIC_XCURSOR "\"${XCURSOR_LIB}\"")
   4.368 +        else(HAVE_X11_SHARED AND XCURSOR_LIB)
   4.369 +          list(APPEND EXTRA_LIBS ${XCURSOR_LIB})
   4.370 +        endif(HAVE_X11_SHARED AND XCURSOR_LIB)
   4.371 +        set(SDL_VIDEO_DRIVER_X11_XCURSOR 1)
   4.372 +      endif(VIDEO_X11_XCURSOR AND HAVE_XCURSOR_H)
   4.373 +
   4.374 +      if(VIDEO_X11_XINERAMA AND HAVE_XINERAMA_H)
   4.375 +        set(HAVE_VIDEO_X11_XINERAMA TRUE)
   4.376 +        if(HAVE_X11_SHARED AND XINERAMA_LIB)
   4.377 +          set(SDL_VIDEO_DRIVER_X11_DYNAMIC_XINERAMA "\"${XINERAMA_LIB}\"")
   4.378 +        else(HAVE_X11_SHARED AND XINERAMA_LIB)
   4.379 +          list(APPEND EXTRA_LIBS ${XINERAMA_LIB})
   4.380 +        endif(HAVE_X11_SHARED AND XINERAMA_LIB)
   4.381 +        set(SDL_VIDEO_DRIVER_X11_XINERAMA 1)
   4.382 +      endif(VIDEO_X11_XINERAMA AND HAVE_XINERAMA_H)
   4.383 +
   4.384 +      if(VIDEO_X11_XINPUT AND HAVE_XINPUT_H)
   4.385 +        set(HAVE_VIDEO_X11_XINPUT TRUE)
   4.386 +        if(HAVE_X11_SHARED AND XI_LIB)
   4.387 +          set(SDL_VIDEO_DRIVER_X11_DYNAMIC_XINPUT2 "\"${XI_LIB}\"")
   4.388 +        else(HAVE_X11_SHARED AND XI_LIB)
   4.389 +          list(APPEND EXTRA_LIBS ${XI_LIB})
   4.390 +        endif(HAVE_X11_SHARED AND XI_LIB)
   4.391 +        set(SDL_VIDEO_DRIVER_X11_XINPUT2 1)
   4.392 +
   4.393 +        # Check for multitouch
   4.394 +        check_c_source_compiles("
   4.395 +            #include <X11/Xlib.h>
   4.396 +            #include <X11/Xproto.h>
   4.397 +            #include <X11/extensions/XInput2.h>
   4.398 +            int event_type = XI_TouchBegin;
   4.399 +            XITouchClassInfo *t;
   4.400 +            Status XIAllowTouchEvents(Display *a,int b,unsigned int c,Window d,int f)
   4.401 +            {
   4.402 +              return (Status)0;
   4.403 +            }
   4.404 +            int main(int argc, char **argv) {}" HAVE_XINPUT2_MULTITOUCH)
   4.405 +        if(HAVE_XINPUT2_MULTITOUCH)
   4.406 +          set(SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH 1)
   4.407 +        endif(HAVE_XINPUT2_MULTITOUCH)
   4.408 +      endif(VIDEO_X11_XINPUT AND HAVE_XINPUT_H)
   4.409 +
   4.410 +      if(VIDEO_X11_XRANDR AND HAVE_XRANDR_H)
   4.411 +        if(HAVE_X11_SHARED AND XRANDR_LIB)
   4.412 +          set(SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR "\"${XRANDR_LIB}\"")
   4.413 +        else(HAVE_X11_SHARED AND XRANDR_LIB)
   4.414 +          list(APPEND EXTRA_LIBS ${XRANDR_LIB})
   4.415 +        endif(HAVE_X11_SHARED AND XRANDR_LIB)
   4.416 +        set(SDL_VIDEO_DRIVER_X11_XRANDR 1)
   4.417 +        set(HAVE_VIDEO_X11_XRANDR TRUE)
   4.418 +      endif(VIDEO_X11_XRANDR AND HAVE_XRANDR_H)
   4.419 +
   4.420 +      if(VIDEO_X11_XSCRNSAVER AND HAVE_XSS_H)
   4.421 +        if(HAVE_X11_SHARED AND XSS_LIB)
   4.422 +          set(SDL_VIDEO_DRIVER_X11_DYNAMIC_XSS "\"${XSS_LIB}\"")
   4.423 +        else(HAVE_X11_SHARED AND XSS_LIB)
   4.424 +          list(APPEND EXTRA_LIBS ${XSS_LIB})
   4.425 +        endif(HAVE_X11_SHARED AND XSS_LIB)
   4.426 +        set(SDL_VIDEO_DRIVER_X11_XSCRNSAVER 1)
   4.427 +        set(HAVE_VIDEO_X11_XSCRNSAVER TRUE)
   4.428 +      endif(VIDEO_X11_XSCRNSAVER AND HAVE_XSS_H)
   4.429 +
   4.430 +      if(VIDEO_X11_XSHAPE AND HAVE_XSHAPE_H)
   4.431 +        set(SDL_VIDEO_DRIVER_X11_XSHAPE 1)
   4.432 +        set(HAVE_VIDEO_X11_XSHAPE TRUE)
   4.433 +      endif(VIDEO_X11_XSHAPE AND HAVE_XSHAPE_H)
   4.434 +
   4.435 +      if(VIDEO_X11_XVM AND HAVE_XF86VM_H)
   4.436 +        if(HAVE_X11_SHARED AND XF86VMODE_LIB)
   4.437 +          set(SDL_VIDEO_DRIVER_X11_DYNAMIC_XVIDMODE "\"${XF86VMODE_LIB}\"")
   4.438 +        else(HAVE_X11_SHARED AND XF86VMODE_LIB)
   4.439 +          list(APPEND EXTRA_LIBS ${XF86VMODE_LIB})
   4.440 +        endif(HAVE_X11_SHARED AND XF86VMODE_LIB)
   4.441 +        set(SDL_VIDEO_DRIVER_X11_XVIDMODE 1)
   4.442 +        set(HAVE_VIDEO_X11_XVM TRUE)
   4.443 +      endif(VIDEO_X11_XVM AND HAVE_XF86VM_H)
   4.444 +
   4.445 +      set(CMAKE_REQUIRED_LIBRARIES)
   4.446 +    endif(X11_LIB)
   4.447 +  endif(VIDEO_X11)
   4.448 +endmacro(CheckX11)
   4.449 +
   4.450 +# Requires:
   4.451 +# - n/a
   4.452 +#
   4.453 +macro(CheckCOCOA)
   4.454 +  if(VIDEO_COCOA)
   4.455 +    check_c_source_compiles("
   4.456 +        #import <Cocoa/Cocoa.h>
   4.457 +        int main (int argc, char** argv) {}" HAVE_VIDEO_COCOA)
   4.458 +    if(HAVE_VIDEO_COCOA)
   4.459 +      file(GLOB COCOA_SOURCES ${SDL2_SOURCE_DIR}/src/video/cocoa/*.m)
   4.460 +      set(SOURCE_FILES ${SOURCE_FILES} ${COCOA_SOURCES})
   4.461 +      set(SDL_VIDEO_DRIVER_COCOA 1)
   4.462 +      set(HAVE_SDL_VIDEO TRUE)
   4.463 +    endif(HAVE_VIDEO_COCOA)
   4.464 +  endif(VIDEO_COCOA)
   4.465 +endmacro(CheckCOCOA)
   4.466 +
   4.467 +# Requires:
   4.468 +# - PkgCheckModules
   4.469 +# Optional:
   4.470 +# - DIRECTFB_SHARED opt
   4.471 +# - HAVE_DLOPEN opt
   4.472 +macro(CheckDirectFB)
   4.473 +  if(VIDEO_DIRECTFB)
   4.474 +    pkg_check_modules(PKG_DIRECTFB directfb>=1.0.0)
   4.475 +    if(PKG_DIRECTFB_FOUND)
   4.476 +      set(HAVE_VIDEO_DIRECTFB TRUE)
   4.477 +      file(GLOB DIRECTFB_SOURCES ${SDL2_SOURCE_DIR}/src/video/directfb/*.c)
   4.478 +      set(SOURCE_FILES ${SOURCE_FILES} ${DIRECTFB_SOURCES})
   4.479 +      set(SDL_VIDEO_DRIVER_DIRECTFB 1)
   4.480 +      set(SDL_VIDEO_RENDER_DIRECTFB 1)
   4.481 +      list(APPEND EXTRA_CFLAGS ${PKG_DIRECTFB_CFLAGS})
   4.482 +      if(DIRECTFB_SHARED)
   4.483 +        if(NOT HAVE_DLOPEN)
   4.484 +          message_warn("You must have SDL_LoadObject() support for dynamic DirectFB loading")
   4.485 +        else()
   4.486 +          find_library(D_DIRECTFB_LIB directfb)
   4.487 +          get_filename_component(F_DIRECTFB_LIB ${D_DIRECTFB_LIB} NAME)
   4.488 +          set(SDL_VIDEO_DRIVER_DIRECTFB_DYNAMIC "\"${F_DIRECTFB_LIB}\"")
   4.489 +          set(HAVE_DIRECTFB_SHARED TRUE)
   4.490 +        endif(NOT HAVE_DLOPEN)
   4.491 +      else(DIRECTFB_SHARED)
   4.492 +        list(APPEND EXTRA_LDFLAGS ${PKG_DIRECTFB_LDFLAGS})
   4.493 +      endif(DIRECTFB_SHARED)
   4.494 +      set(HAVE_SDL_VIDEO TRUE)
   4.495 +    endif(PKG_DIRECTFB_FOUND)
   4.496 +  endif(VIDEO_DIRECTFB)
   4.497 +endmacro(CheckDirectFB)
   4.498 +
   4.499 +# Requires:
   4.500 +# - nada
   4.501 +macro(CheckOpenGLX11)
   4.502 +  if(VIDEO_OPENGL)
   4.503 +    check_c_source_compiles("
   4.504 +        #include <GL/gl.h>
   4.505 +        #include <GL/glx.h>
   4.506 +        int main(int argc, char** argv) {}" HAVE_VIDEO_OPENGL)
   4.507 +
   4.508 +    if(HAVE_VIDEO_OPENGL)
   4.509 +      set(HAVE_VIDEO_OPENGL TRUE)
   4.510 +      set(SDL_VIDEO_OPENGL 1)
   4.511 +      set(SDL_VIDEO_OPENGL_GLX 1)
   4.512 +      set(SDL_VIDEO_RENDER_OGL 1)
   4.513 +      list(APPEND EXTRA_LIBS GL)
   4.514 +    endif(HAVE_VIDEO_OPENGL)
   4.515 +  endif(VIDEO_OPENGL)
   4.516 +endmacro(CheckOpenGLX11)
   4.517 +
   4.518 +# Requires:
   4.519 +# - nada
   4.520 +macro(CheckOpenGLESX11)
   4.521 +  if(VIDEO_OPENGLES)
   4.522 +    check_c_source_compiles("
   4.523 +        #include <EGL/egl.h>
   4.524 +        int main (int argc, char** argv) {}" HAVE_VIDEO_OPENGLES)
   4.525 +    if(HAVE_VIDEO_OPENGLES)
   4.526 +      check_c_source_compiles("
   4.527 +          #include <GLES/gl.h>
   4.528 +          #include <GLES/glext.h>
   4.529 +          int main (int argc, char** argv) {}" HAVE_VIDEO_OPENGLES_V1)
   4.530 +      if(HAVE_VIDEO_OPENGLES_V1)
   4.531 +        set(SDL_VIDEO_OPENGL_ES 1)
   4.532 +        set(SDL_VIDEO_RENDER_OGL_ES 1)
   4.533 +      endif(HAVE_VIDEO_OPENGLES_V1)
   4.534 +      check_c_source_compiles("
   4.535 +          #include <GLES2/gl2.h>
   4.536 +          #include <GLES2/gl2ext.h>
   4.537 +          int main (int argc, char** argv) {}" HAVE_VIDEO_OPENGLES_V2)
   4.538 +      if(HAVE_VIDEO_OPENGLES_V2)
   4.539 +        set(SDL_VIDEO_OPENGL_ES2 1)
   4.540 +        set(SDL_VIDEO_RENDER_OGL_ES2 1)
   4.541 +      endif(HAVE_VIDEO_OPENGLES_V2)
   4.542 +    endif(HAVE_VIDEO_OPENGLES)
   4.543 +  endif(VIDEO_OPENGLES)
   4.544 +endmacro(CheckOpenGLESX11)
   4.545 +
   4.546 +# Rquires:
   4.547 +# - nada
   4.548 +# Optional:
   4.549 +# - THREADS opt
   4.550 +# Sets:
   4.551 +# PTHREAD_CFLAGS
   4.552 +# PTHREAD_LIBS
   4.553 +macro(CheckPTHREAD)
   4.554 +  if(PTHREADS)
   4.555 +    if(LINUX)
   4.556 +      set(PTHREAD_CFLAGS "-D_REENTRANT")
   4.557 +      set(PTHREAD_LDFLAGS "-lpthread")
   4.558 +    elseif(BSDI)
   4.559 +      set(PTHREAD_CFLAGS "-D_REENTRANT -D_THREAD_SAFE")
   4.560 +      set(PTHREAD_LDFLAGS "")
   4.561 +    elseif(DARWIN)
   4.562 +      set(PTHREAD_CFLAGS "-D_THREAD_SAFE")
   4.563 +      # causes Carbon.p complaints?
   4.564 +      # set(PTHREAD_CFLAGS "-D_REENTRANT -D_THREAD_SAFE")
   4.565 +      set(PTHREAD_LDFLAGS "")
   4.566 +    elseif(FREEBSD)
   4.567 +      set(PTHREAD_CFLAGS "-D_REENTRANT -D_THREAD_SAFE")
   4.568 +      set(PTHREAD_LDFLAGS "-pthread")
   4.569 +    elseif(NETBSD)
   4.570 +      set(PTHREAD_CFLAGS "-D_REENTRANT -D_THREAD_SAFE")
   4.571 +      set(PTHREAD_LDFLAGS "-lpthread")
   4.572 +    elseif(OPENBSD)
   4.573 +      set(PTHREAD_CFLAGS "-D_REENTRANT")
   4.574 +      set(PTHREAD_LDFLAGS "-pthread")
   4.575 +    elseif(SOLARIS)
   4.576 +      set(PTHREAD_CFLAGS "-D_REENTRANT")
   4.577 +      set(PTHREAD_LDFLAGS "-pthread -lposix4")
   4.578 +    elseif(SYSV5)
   4.579 +      set(PTHREAD_CFLAGS "-D_REENTRANT -Kthread")
   4.580 +      set(PTHREAD_LDFLAGS "")
   4.581 +    elseif(AIX)
   4.582 +      set(PTHREAD_CFLAGS "-D_REENTRANT -mthreads")
   4.583 +      set(PTHREAD_LDFLAGS "-pthread")
   4.584 +    elseif(HPUX)
   4.585 +      set(PTHREAD_CFLAGS "-D_REENTRANT")
   4.586 +      set(PTHREAD_LDFLAGS "-L/usr/lib -pthread")
   4.587 +    else()
   4.588 +      set(PTHREAD_CFLAGS "-D_REENTRANT")
   4.589 +      set(PTHREAD_LDFLAGS "-lpthread")
   4.590 +    endif(LINUX)
   4.591 +
   4.592 +    # Run some tests
   4.593 +    set(CMAKE_REQUIRED_FLAGS "${PTHREAD_CFLAGS} ${PTHREAD_LDFLAGS}")
   4.594 +    check_c_source_runs("
   4.595 +        #include <pthread.h>
   4.596 +        int main(int argc, char** argv) {
   4.597 +          pthread_attr_t type;
   4.598 +          pthread_attr_init(&type);
   4.599 +          return 0;
   4.600 +        }" HAVE_PTHREADS)
   4.601 +    if(HAVE_PTHREADS)
   4.602 +      set(SDL_THREAD_PTHREAD 1)
   4.603 +      list(APPEND EXTRA_CFLAGS ${PTHREAD_CFLAGS})
   4.604 +      list(APPEND EXTRA_LDFLAGS ${PTHREAD_LDFLAGS})
   4.605 +      set(SDL_CFLAGS "${SDL_CFLAGS} ${PTHREAD_CFLAGS}")
   4.606 +      list(APPEND SDL_LIBS ${PTHREAD_LDFLAGS})
   4.607 +
   4.608 +      check_c_source_compiles("
   4.609 +        #include <pthread.h>
   4.610 +        int main(int argc, char **argv) {
   4.611 +          pthread_mutexattr_t attr;
   4.612 +          pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
   4.613 +        }" HAVE_RECURSIVE_MUTEXES)
   4.614 +      if(HAVE_RECURSIVE_MUTEXES)
   4.615 +        set(SDL_THREAD_PTHREAD_RECURSIVE_MUTEX 1)
   4.616 +      else(HAVE_RECURSIVE_MUTEXES)
   4.617 +        check_c_source_compiles("
   4.618 +            #include <pthread.h>
   4.619 +            int main(int argc, char **argv) {
   4.620 +              pthread_mutexattr_t attr;
   4.621 +              pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
   4.622 +            }" HAVE_RECURSIVE_MUTEXES_NP)
   4.623 +        if(HAVE_RECURSIVE_MUTEXES_NP)
   4.624 +          set(SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP 1)
   4.625 +        endif(HAVE_RECURSIVE_MUTEXES_NP)
   4.626 +      endif(HAVE_RECURSIVE_MUTEXES)
   4.627 +
   4.628 +      if(PTHREADS_SEM)
   4.629 +        check_c_source_compiles("#include <pthread.h>
   4.630 +                                 #include <semaphore.h>" HAVE_PTHREADS_SEM)
   4.631 +        if(HAVE_PTHREADS_SEM)
   4.632 +          check_c_source_compiles("
   4.633 +              #include <pthread.h>
   4.634 +              #include <semaphore.h>
   4.635 +              int main(int argc, char **argv) {
   4.636 +                  sem_timedwait(NULL, NULL);
   4.637 +                  return 0;
   4.638 +              }" HAVE_SEM_TIMEDWAIT)
   4.639 +        endif(HAVE_PTHREADS_SEM)
   4.640 +      endif(PTHREADS_SEM)
   4.641 +
   4.642 +      check_c_source_compiles("
   4.643 +          #include <pthread.h>
   4.644 +          int main(int argc, char** argv) {
   4.645 +              pthread_spin_trylock(NULL);
   4.646 +              return 0;
   4.647 +          }" HAVE_PTHREAD_SPINLOCK)
   4.648 +
   4.649 +      check_c_source_compiles("
   4.650 +          #include <pthread.h>
   4.651 +          #include <pthread_np.h>
   4.652 +          int main(int argc, char** argv) { return 0; }" HAVE_PTHREAD_NP_H)
   4.653 +      check_function_exists(pthread_setname_np HAVE_PTHREAD_setNAME_NP)
   4.654 +      check_function_exists(pthread_set_name_np HAVE_PTHREAD_set_NAME_NP)
   4.655 +      set(CMAKE_REQUIRED_FLAGS)
   4.656 +
   4.657 +      set(SOURCE_FILES ${SOURCE_FILES}
   4.658 +          ${SDL2_SOURCE_DIR}/src/thread/pthread/SDL_systhread.c
   4.659 +          ${SDL2_SOURCE_DIR}/src/thread/pthread/SDL_sysmutex.c   # Can be faked, if necessary
   4.660 +          ${SDL2_SOURCE_DIR}/src/thread/pthread/SDL_syscond.c    # Can be faked, if necessary
   4.661 +          )
   4.662 +      if(HAVE_PTHREADS_SEM)
   4.663 +        set(SOURCE_FILES ${SOURCE_FILES}
   4.664 +            ${SDL2_SOURCE_DIR}/src/thread/pthread/SDL_syssem.c)
   4.665 +      else(HAVE_PTHREADS_SEM)
   4.666 +        set(SOURCE_FILES ${SOURCE_FILES}
   4.667 +            ${SDL2_SOURCE_DIR}/src/thread/generic/SDL_syssem.c)
   4.668 +      endif(HAVE_PTHREADS_SEM)
   4.669 +      set(HAVE_SDL_THREADS TRUE)
   4.670 +    endif(HAVE_PTHREADS)
   4.671 +  endif(PTHREADS)
   4.672 +endmacro(CheckPTHREAD)
   4.673 +
   4.674 +# Requires
   4.675 +# - nada
   4.676 +# Optional:
   4.677 +# Sets:
   4.678 +# USB_LIBS
   4.679 +# USB_CFLAGS
   4.680 +macro(CheckUSBHID)
   4.681 +  check_library_exists(usbhid hid_init "" LIBUSBHID)
   4.682 +  if(LIBUSBHID)
   4.683 +    check_include_file(usbhid.h HAVE_USBHID_H)
   4.684 +    if(HAVE_USBHID_H)
   4.685 +      set(USB_CFLAGS "-DHAVE_USBHID_H")
   4.686 +    endif(HAVE_USBHID_H)
   4.687 +
   4.688 +    check_include_file(libusbhid.h HAVE_LIBUSBHID_H)
   4.689 +    if(HAVE_LIBUSBHID_H)
   4.690 +      set(USB_CFLAGS "${USB_CFLAGS} -DHAVE_LIBUSBHID_H")
   4.691 +    endif(HAVE_LIBUSBHID_H)
   4.692 +    set(USB_LIBS ${USB_LIBS} usbhid)
   4.693 +  else(LIBUSBHID)
   4.694 +    check_include_file(usb.h HAVE_USB_H)
   4.695 +    if(HAVE_USB_H)
   4.696 +      set(USB_CFLAGS "-DHAVE_USB_H")
   4.697 +    endif(HAVE_USB_H)
   4.698 +    check_include_file(libusb.h HAVE_LIBUSB_H)
   4.699 +    if(HAVE_LIBUSB_H)
   4.700 +      set(USB_CFLAGS "${USB_CFLAGS} -DHAVE_LIBUSB_H")
   4.701 +    endif(HAVE_LIBUSB_H)
   4.702 +    check_library_exists(usb hid_init "" LIBUSB)
   4.703 +    if(LIBUSB)
   4.704 +      set(USB_LIBS ${USB_LIBS} usb)
   4.705 +    endif(LIBUSB)
   4.706 +  endif(LIBUSBHID)
   4.707 +
   4.708 +  set(CMAKE_REQUIRED_FLAGS "${USB_CFLAGS}")
   4.709 +  set(CMAKE_REQUIRED_LIBRARIES "${USB_LIBS}")
   4.710 +  check_c_source_compiles("
   4.711 +       #include <sys/types.h>
   4.712 +        #if defined(HAVE_USB_H)
   4.713 +        #include <usb.h>
   4.714 +        #endif
   4.715 +        #ifdef __DragonFly__
   4.716 +        # include <bus/usb/usb.h>
   4.717 +        # include <bus/usb/usbhid.h>
   4.718 +        #else
   4.719 +        # include <dev/usb/usb.h>
   4.720 +        # include <dev/usb/usbhid.h>
   4.721 +        #endif
   4.722 +        #if defined(HAVE_USBHID_H)
   4.723 +        #include <usbhid.h>
   4.724 +        #elif defined(HAVE_LIBUSB_H)
   4.725 +        #include <libusb.h>
   4.726 +        #elif defined(HAVE_LIBUSBHID_H)
   4.727 +        #include <libusbhid.h>
   4.728 +        #endif
   4.729 +        int main(int argc, char **argv) {
   4.730 +          struct report_desc *repdesc;
   4.731 +          struct usb_ctl_report *repbuf;
   4.732 +          hid_kind_t hidkind;
   4.733 +          return 0;
   4.734 +        }" HAVE_USBHID)
   4.735 +  if(HAVE_USBHID)
   4.736 +    check_c_source_compiles("
   4.737 +          #include <sys/types.h>
   4.738 +          #if defined(HAVE_USB_H)
   4.739 +          #include <usb.h>
   4.740 +          #endif
   4.741 +          #ifdef __DragonFly__
   4.742 +          # include <bus/usb/usb.h>
   4.743 +          # include <bus/usb/usbhid.h>
   4.744 +          #else
   4.745 +          # include <dev/usb/usb.h>
   4.746 +          # include <dev/usb/usbhid.h>
   4.747 +          #endif
   4.748 +          #if defined(HAVE_USBHID_H)
   4.749 +          #include <usbhid.h>
   4.750 +          #elif defined(HAVE_LIBUSB_H)
   4.751 +          #include <libusb.h>
   4.752 +          #elif defined(HAVE_LIBUSBHID_H)
   4.753 +          #include <libusbhid.h>
   4.754 +          #endif
   4.755 +          int main(int argc, char** argv) {
   4.756 +            struct usb_ctl_report buf;
   4.757 +            if (buf.ucr_data) { }
   4.758 +            return 0;
   4.759 +          }" HAVE_USBHID_UCR_DATA)
   4.760 +    if(HAVE_USBHID_UCR_DATA)
   4.761 +      set(USB_CFLAGS "${USB_CFLAGS} -DUSBHID_UCR_DATA")
   4.762 +    endif(HAVE_USBHID_UCR_DATA)
   4.763 +
   4.764 +    check_c_source_compiles("
   4.765 +          #include <sys/types.h>
   4.766 +          #if defined(HAVE_USB_H)
   4.767 +          #include <usb.h>
   4.768 +          #endif
   4.769 +          #ifdef __DragonFly__
   4.770 +          #include <bus/usb/usb.h>
   4.771 +          #include <bus/usb/usbhid.h>
   4.772 +          #else
   4.773 +          #include <dev/usb/usb.h>
   4.774 +          #include <dev/usb/usbhid.h>
   4.775 +          #endif
   4.776 +          #if defined(HAVE_USBHID_H)
   4.777 +          #include <usbhid.h>
   4.778 +          #elif defined(HAVE_LIBUSB_H)
   4.779 +          #include <libusb.h>
   4.780 +          #elif defined(HAVE_LIBUSBHID_H)
   4.781 +          #include <libusbhid.h>
   4.782 +          #endif
   4.783 +          int main(int argc, char **argv) {
   4.784 +            report_desc_t d;
   4.785 +            hid_start_parse(d, 1, 1);
   4.786 +            return 0;
   4.787 +          }" HAVE_USBHID_NEW)
   4.788 +    if(HAVE_USBHID_NEW)
   4.789 +      set(USB_CFLAGS "${USB_CFLAGS} -DUSBHID_NEW")
   4.790 +    endif(HAVE_USBHID_NEW)
   4.791 +
   4.792 +    check_c_source_compiles("
   4.793 +        #include <machine/joystick.h>
   4.794 +        int main(int argc, char** argv) {
   4.795 +            struct joystick t;
   4.796 +            return 0;
   4.797 +        }" HAVE_MACHINE_JOYSTICK)
   4.798 +    if(HAVE_MACHINE_JOYSTICK)
   4.799 +      set(SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H 1)
   4.800 +    endif(HAVE_MACHINE_JOYSTICK)
   4.801 +    set(SDL_JOYSTICK_USBHID 1)
   4.802 +    file(GLOB BSD_JOYSTICK_SOURCES ${SDL2_SOURCE_DIR}/src/joystick/bsd/*.c)
   4.803 +    set(SOURCE_FILES ${SOURCE_FILES} ${BSD_JOYSTICK_SOURCES})
   4.804 +    list(APPEND EXTRA_CFLAGS ${USB_CFLAGS})
   4.805 +    list(APPEND EXTRA_LIBS ${USB_LIBS})
   4.806 +    set(HAVE_SDL_JOYSTICK TRUE)
   4.807 +
   4.808 +    set(CMAKE_REQUIRED_LIBRARIES)
   4.809 +    set(CMAKE_REQUIRED_FLAGS)
   4.810 +  endif(HAVE_USBHID)
   4.811 +endmacro(CheckUSBHID)
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/include/SDL_config.h.cmake	Fri Nov 16 09:23:18 2012 -0300
     5.3 @@ -0,0 +1,364 @@
     5.4 +/*
     5.5 +  Simple DirectMedia Layer
     5.6 +  Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
     5.7 +
     5.8 +  This software is provided 'as-is', without any express or implied
     5.9 +  warranty.  In no event will the authors be held liable for any damages
    5.10 +  arising from the use of this software.
    5.11 +
    5.12 +  Permission is granted to anyone to use this software for any purpose,
    5.13 +  including commercial applications, and to alter it and redistribute it
    5.14 +  freely, subject to the following restrictions:
    5.15 +
    5.16 +  1. The origin of this software must not be misrepresented; you must not
    5.17 +     claim that you wrote the original software. If you use this software
    5.18 +     in a product, an acknowledgment in the product documentation would be
    5.19 +     appreciated but is not required.
    5.20 +  2. Altered source versions must be plainly marked as such, and must not be
    5.21 +     misrepresented as being the original software.
    5.22 +  3. This notice may not be removed or altered from any source distribution.
    5.23 +*/
    5.24 +
    5.25 +#ifndef _SDL_config_h
    5.26 +#define _SDL_config_h
    5.27 +
    5.28 +/**
    5.29 + *  \file SDL_config.h.in
    5.30 + *
    5.31 + *  This is a set of defines to configure the SDL features
    5.32 + */
    5.33 +
    5.34 +/* General platform specific identifiers */
    5.35 +#include "SDL_platform.h"
    5.36 +
    5.37 +/* C language features */
    5.38 +#cmakedefine const @HAVE_CONST@
    5.39 +#cmakedefine inline @HAVE_INLINE@
    5.40 +#cmakedefine volatile @HAVE_VOLATILE@
    5.41 +
    5.42 +/* C datatypes */
    5.43 +#cmakedefine SIZEOF_VOIDP @SIZEOF_VOIDP@
    5.44 +#cmakedefine HAVE_GCC_ATOMICS @HAVE_GCC_ATOMICS@
    5.45 +#cmakedefine HAVE_GCC_SYNC_LOCK_TEST_AND_SET @HAVE_GCC_SYNC_LOCK_TEST_AND_SET@
    5.46 +#cmakedefine HAVE_PTHREAD_SPINLOCK @HAVE_PTHREAD_SPINLOCK@
    5.47 +
    5.48 +/* Comment this if you want to build without any C library requirements */
    5.49 +#cmakedefine HAVE_LIBC 1
    5.50 +#if HAVE_LIBC
    5.51 +
    5.52 +/* Useful headers */
    5.53 +#cmakedefine HAVE_ALLOCA_H 1
    5.54 +#cmakedefine HAVE_SYS_TYPES_H 1
    5.55 +#cmakedefine HAVE_STDIO_H 1
    5.56 +#cmakedefine STDC_HEADERS 1
    5.57 +#cmakedefine HAVE_STDLIB_H 1
    5.58 +#cmakedefine HAVE_STDARG_H 1
    5.59 +#cmakedefine HAVE_MALLOC_H 1
    5.60 +#cmakedefine HAVE_MEMORY_H 1
    5.61 +#cmakedefine HAVE_STRING_H 1
    5.62 +#cmakedefine HAVE_STRINGS_H 1
    5.63 +#cmakedefine HAVE_INTTYPES_H 1
    5.64 +#cmakedefine HAVE_STDINT_H 1
    5.65 +#cmakedefine HAVE_CTYPE_H 1
    5.66 +#cmakedefine HAVE_MATH_H 1
    5.67 +#cmakedefine HAVE_ICONV_H 1
    5.68 +#cmakedefine HAVE_SIGNAL_H 1
    5.69 +#cmakedefine HAVE_ALTIVEC_H 1
    5.70 +#cmakedefine HAVE_PTHREAD_NP_H 1
    5.71 +
    5.72 +/* C library functions */
    5.73 +#cmakedefine HAVE_MALLOC 1
    5.74 +#cmakedefine HAVE_CALLOC 1
    5.75 +#cmakedefine HAVE_REALLOC 1
    5.76 +#cmakedefine HAVE_FREE 1
    5.77 +#cmakedefine HAVE_ALLOCA 1
    5.78 +#ifndef __WIN32__ /* Don't use C runtime versions of these on Windows */
    5.79 +#cmakedefine HAVE_GETENV 1
    5.80 +#cmakedefine HAVE_SETENV 1
    5.81 +#cmakedefine HAVE_PUTENV 1
    5.82 +#cmakedefine HAVE_UNSETENV 1
    5.83 +#endif
    5.84 +#cmakedefine HAVE_QSORT 1
    5.85 +#cmakedefine HAVE_ABS 1
    5.86 +#cmakedefine HAVE_BCOPY 1
    5.87 +#cmakedefine HAVE_MEMSET 1
    5.88 +#cmakedefine HAVE_MEMCPY 1
    5.89 +#cmakedefine HAVE_MEMMOVE 1
    5.90 +#cmakedefine HAVE_MEMCMP 1
    5.91 +#cmakedefine HAVE_STRLEN 1
    5.92 +#cmakedefine HAVE_STRLCPY 1
    5.93 +#cmakedefine HAVE_STRLCAT 1
    5.94 +#cmakedefine HAVE_STRDUP 1
    5.95 +#cmakedefine HAVE__STRREV 1
    5.96 +#cmakedefine HAVE__STRUPR 1
    5.97 +#cmakedefine HAVE__STRLWR 1
    5.98 +#cmakedefine HAVE_INDEX 1
    5.99 +#cmakedefine HAVE_RINDEX 1
   5.100 +#cmakedefine HAVE_STRCHR 1
   5.101 +#cmakedefine HAVE_STRRCHR 1
   5.102 +#cmakedefine HAVE_STRSTR 1
   5.103 +#cmakedefine HAVE_ITOA 1
   5.104 +#cmakedefine HAVE__LTOA 1
   5.105 +#cmakedefine HAVE__UITOA 1
   5.106 +#cmakedefine HAVE__ULTOA 1
   5.107 +#cmakedefine HAVE_STRTOL 1
   5.108 +#cmakedefine HAVE_STRTOUL 1
   5.109 +#cmakedefine HAVE__I64TOA 1
   5.110 +#cmakedefine HAVE__UI64TOA 1
   5.111 +#cmakedefine HAVE_STRTOLL 1
   5.112 +#cmakedefine HAVE_STRTOULL 1
   5.113 +#cmakedefine HAVE_STRTOD 1
   5.114 +#cmakedefine HAVE_ATOI 1
   5.115 +#cmakedefine HAVE_ATOF 1
   5.116 +#cmakedefine HAVE_STRCMP 1
   5.117 +#cmakedefine HAVE_STRNCMP 1
   5.118 +#cmakedefine HAVE__STRICMP 1
   5.119 +#cmakedefine HAVE_STRCASECMP 1
   5.120 +#cmakedefine HAVE__STRNICMP 1
   5.121 +#cmakedefine HAVE_STRNCASECMP 1
   5.122 +#cmakedefine HAVE_SSCANF 1
   5.123 +#cmakedefine HAVE_SNPRINTF 1
   5.124 +#cmakedefine HAVE_VSNPRINTF 1
   5.125 +#cmakedefine HAVE_M_PI 1
   5.126 +#cmakedefine HAVE_ATAN 1
   5.127 +#cmakedefine HAVE_ATAN2 1
   5.128 +#cmakedefine HAVE_CEIL 1
   5.129 +#cmakedefine HAVE_COPYSIGN 1
   5.130 +#cmakedefine HAVE_COS 1
   5.131 +#cmakedefine HAVE_COSF 1
   5.132 +#cmakedefine HAVE_FABS 1
   5.133 +#cmakedefine HAVE_FLOOR 1
   5.134 +#cmakedefine HAVE_LOG 1
   5.135 +#cmakedefine HAVE_POW 1
   5.136 +#cmakedefine HAVE_SCALBN 1
   5.137 +#cmakedefine HAVE_SIN 1
   5.138 +#cmakedefine HAVE_SINF 1
   5.139 +#cmakedefine HAVE_SQRT 1
   5.140 +#cmakedefine HAVE_FSEEKO 1
   5.141 +#cmakedefine HAVE_FSEEKO64 1
   5.142 +#cmakedefine HAVE_SIGACTION 1
   5.143 +#cmakedefine HAVE_SA_SIGACTION 1
   5.144 +#cmakedefine HAVE_SETJMP 1
   5.145 +#cmakedefine HAVE_NANOSLEEP 1
   5.146 +#cmakedefine HAVE_SYSCONF 1
   5.147 +#cmakedefine HAVE_SYSCTLBYNAME 1
   5.148 +#cmakedefine HAVE_CLOCK_GETTIME 1
   5.149 +#cmakedefine HAVE_GETPAGESIZE 1
   5.150 +#cmakedefine HAVE_MPROTECT 1
   5.151 +#cmakedefine HAVE_ICONV 1
   5.152 +#cmakedefine HAVE_PTHREAD_SETNAME_NP 1
   5.153 +#cmakedefine HAVE_PTHREAD_SET_NAME_NP 1
   5.154 +#cmakedefine HAVE_SEM_TIMEDWAIT 1
   5.155 +#elif __WIN32__
   5.156 +#cmakedefine HAVE_STDARG_H 1
   5.157 +#cmakedefine HAVE_STDDEF_H 1
   5.158 +#else
   5.159 +/* We may need some replacement for stdarg.h here */
   5.160 +#include <stdarg.h>
   5.161 +#endif /* HAVE_LIBC */
   5.162 +
   5.163 +/* SDL internal assertion support */
   5.164 +#cmakedefine SDL_DEFAULT_ASSERT_LEVEL @SDL_DEFAULT_ASSERT_LEVEL@
   5.165 +
   5.166 +/* Allow disabling of core subsystems */
   5.167 +#cmakedefine SDL_ATOMIC_DISABLED @SDL_ATOMIC_DISABLED@
   5.168 +#cmakedefine SDL_AUDIO_DISABLED @SDL_AUDIO_DISABLED@
   5.169 +#cmakedefine SDL_CPUINFO_DISABLED @SDL_CPUINFO_DISABLED@
   5.170 +#cmakedefine SDL_EVENTS_DISABLED @SDL_EVENTS_DISABLED@
   5.171 +#cmakedefine SDL_FILE_DISABLED @SDL_FILE_DISABLED@
   5.172 +#cmakedefine SDL_JOYSTICK_DISABLED @SDL_JOYSTICK_DISABLED@
   5.173 +#cmakedefine SDL_HAPTIC_DISABLED @SDL_HAPTIC_DISABLED@
   5.174 +#cmakedefine SDL_LOADSO_DISABLED @SDL_LOADSO_DISABLED@
   5.175 +#cmakedefine SDL_RENDER_DISABLED @SDL_RENDER_DISABLED@
   5.176 +#cmakedefine SDL_THREADS_DISABLED @SDL_THREADS_DISABLED@
   5.177 +#cmakedefine SDL_TIMERS_DISABLED @SDL_TIMERS_DISABLED@
   5.178 +#cmakedefine SDL_VIDEO_DISABLED @SDL_VIDEO_DISABLED@
   5.179 +#cmakedefine SDL_POWER_DISABLED @SDL_POWER_DISABLED@
   5.180 +
   5.181 +/* Enable various audio drivers */
   5.182 +#cmakedefine SDL_AUDIO_DRIVER_ALSA @SDL_AUDIO_DRIVER_ALSA@
   5.183 +#cmakedefine SDL_AUDIO_DRIVER_ALSA_DYNAMIC @SDL_AUDIO_DRIVER_ALSA_DYNAMIC@
   5.184 +#cmakedefine SDL_AUDIO_DRIVER_ARTS @SDL_AUDIO_DRIVER_ARTS@
   5.185 +#cmakedefine SDL_AUDIO_DRIVER_ARTS_DYNAMIC @SDL_AUDIO_DRIVER_ARTS_DYNAMIC@
   5.186 +#cmakedefine SDL_AUDIO_DRIVER_PULSEAUDIO @SDL_AUDIO_DRIVER_PULSEAUDIO@
   5.187 +#cmakedefine SDL_AUDIO_DRIVER_PULSEAUDIO_DYNAMIC @SDL_AUDIO_DRIVER_PULSEAUDIO_DYNAMIC@
   5.188 +#cmakedefine SDL_AUDIO_DRIVER_BEOSAUDIO @SDL_AUDIO_DRIVER_BEOSAUDIO@
   5.189 +#cmakedefine SDL_AUDIO_DRIVER_BSD @SDL_AUDIO_DRIVER_BSD@
   5.190 +#cmakedefine SDL_AUDIO_DRIVER_COREAUDIO @SDL_AUDIO_DRIVER_COREAUDIO@
   5.191 +#cmakedefine SDL_AUDIO_DRIVER_DISK @SDL_AUDIO_DRIVER_DISK@
   5.192 +#cmakedefine SDL_AUDIO_DRIVER_DUMMY @SDL_AUDIO_DRIVER_DUMMY@
   5.193 +#cmakedefine SDL_AUDIO_DRIVER_XAUDIO2 @SDL_AUDIO_DRIVER_XAUDIO2@
   5.194 +#cmakedefine SDL_AUDIO_DRIVER_DSOUND @SDL_AUDIO_DRIVER_DSOUND@
   5.195 +#cmakedefine SDL_AUDIO_DRIVER_ESD @SDL_AUDIO_DRIVER_ESD@
   5.196 +#cmakedefine SDL_AUDIO_DRIVER_ESD_DYNAMIC @SDL_AUDIO_DRIVER_ESD_DYNAMIC@
   5.197 +#cmakedefine SDL_AUDIO_DRIVER_NAS @SDL_AUDIO_DRIVER_NAS@
   5.198 +#cmakedefine SDL_AUDIO_DRIVER_NAS_DYNAMIC @SDL_AUDIO_DRIVER_NAS_DYNAMIC@
   5.199 +#cmakedefine SDL_AUDIO_DRIVER_NDS @SDL_AUDIO_DRIVER_NDS@
   5.200 +#cmakedefine SDL_AUDIO_DRIVER_OSS @SDL_AUDIO_DRIVER_OSS@
   5.201 +#cmakedefine SDL_AUDIO_DRIVER_OSS_SOUNDCARD_H @SDL_AUDIO_DRIVER_OSS_SOUNDCARD_H@
   5.202 +#cmakedefine SDL_AUDIO_DRIVER_PAUDIO @SDL_AUDIO_DRIVER_PAUDIO@
   5.203 +#cmakedefine SDL_AUDIO_DRIVER_QSA @SDL_AUDIO_DRIVER_QSA@
   5.204 +#cmakedefine SDL_AUDIO_DRIVER_SUNAUDIO @SDL_AUDIO_DRIVER_SUNAUDIO@
   5.205 +#cmakedefine SDL_AUDIO_DRIVER_WINMM @SDL_AUDIO_DRIVER_WINMM@
   5.206 +#cmakedefine SDL_AUDIO_DRIVER_FUSIONSOUND @SDL_AUDIO_DRIVER_FUSIONSOUND@
   5.207 +#cmakedefine SDL_AUDIO_DRIVER_FUSIONSOUND_DYNAMIC @SDL_AUDIO_DRIVER_FUSIONSOUND_DYNAMIC@
   5.208 +
   5.209 +/* Enable various input drivers */
   5.210 +#cmakedefine SDL_INPUT_LINUXEV @SDL_INPUT_LINUXEV@
   5.211 +#cmakedefine SDL_INPUT_TSLIB @SDL_INPUT_TSLIB@
   5.212 +#cmakedefine SDL_JOYSTICK_BEOS @SDL_JOYSTICK_BEOS@
   5.213 +#cmakedefine SDL_JOYSTICK_DINPUT @SDL_JOYSTICK_DINPUT@
   5.214 +#cmakedefine SDL_JOYSTICK_DUMMY @SDL_JOYSTICK_DUMMY@
   5.215 +#cmakedefine SDL_JOYSTICK_IOKIT @SDL_JOYSTICK_IOKIT@
   5.216 +#cmakedefine SDL_JOYSTICK_LINUX @SDL_JOYSTICK_LINUX@
   5.217 +#cmakedefine SDL_JOYSTICK_NDS @SDL_JOYSTICK_NDS@
   5.218 +#cmakedefine SDL_JOYSTICK_WINMM @SDL_JOYSTICK_WINMM@
   5.219 +#cmakedefine SDL_JOYSTICK_USBHID @SDL_JOYSTICK_USBHID@
   5.220 +#cmakedefine SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H @SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H@
   5.221 +#cmakedefine SDL_HAPTIC_DUMMY @SDL_HAPTIC_DUMMY@
   5.222 +#cmakedefine SDL_HAPTIC_LINUX @SDL_HAPTIC_LINUX@
   5.223 +#cmakedefine SDL_HAPTIC_IOKIT @SDL_HAPTIC_IOKIT@
   5.224 +#cmakedefine SDL_HAPTIC_DINPUT @SDL_HAPTIC_DINPUT@
   5.225 +
   5.226 +/* Enable various shared object loading systems */
   5.227 +#cmakedefine SDL_LOADSO_BEOS @SDL_LOADSO_BEOS@
   5.228 +#cmakedefine SDL_LOADSO_DLOPEN @SDL_LOADSO_DLOPEN@
   5.229 +#cmakedefine SDL_LOADSO_DUMMY @SDL_LOADSO_DUMMY@
   5.230 +#cmakedefine SDL_LOADSO_LDG @SDL_LOADSO_LDG@
   5.231 +#cmakedefine SDL_LOADSO_WINDOWS @SDL_LOADSO_WINDOWS@
   5.232 +
   5.233 +/* Enable various threading systems */
   5.234 +#cmakedefine SDL_THREAD_BEOS @SDL_THREAD_BEOS@
   5.235 +#cmakedefine SDL_THREAD_NDS @SDL_THREAD_NDS@
   5.236 +#cmakedefine SDL_THREAD_PTHREAD @SDL_THREAD_PTHREAD@
   5.237 +#cmakedefine SDL_THREAD_PTHREAD_RECURSIVE_MUTEX @SDL_THREAD_PTHREAD_RECURSIVE_MUTEX@
   5.238 +#cmakedefine SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP @SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP@
   5.239 +#cmakedefine SDL_THREAD_WINDOWS @SDL_THREAD_WINDOWS@
   5.240 +
   5.241 +/* Enable various timer systems */
   5.242 +#cmakedefine SDL_TIMER_BEOS @SDL_TIMER_BEOS@
   5.243 +#cmakedefine SDL_TIMER_DUMMY @SDL_TIMER_DUMMY@
   5.244 +#cmakedefine SDL_TIMER_NDS @SDL_TIMER_NDS@
   5.245 +#cmakedefine SDL_TIMER_UNIX @SDL_TIMER_UNIX@
   5.246 +#cmakedefine SDL_TIMER_WINDOWS @SDL_TIMER_WINDOWS@
   5.247 +#cmakedefine SDL_TIMER_WINCE @SDL_TIMER_WINCE@
   5.248 +
   5.249 +/* Enable various video drivers */
   5.250 +#cmakedefine SDL_VIDEO_DRIVER_BWINDOW @SDL_VIDEO_DRIVER_BWINDOW@
   5.251 +#cmakedefine SDL_VIDEO_DRIVER_COCOA @SDL_VIDEO_DRIVER_COCOA@
   5.252 +#cmakedefine SDL_VIDEO_DRIVER_DIRECTFB @SDL_VIDEO_DRIVER_DIRECTFB@
   5.253 +#cmakedefine SDL_VIDEO_DRIVER_DIRECTFB_DYNAMIC @SDL_VIDEO_DRIVER_DIRECTFB_DYNAMIC@
   5.254 +#cmakedefine SDL_VIDEO_DRIVER_DUMMY @SDL_VIDEO_DRIVER_DUMMY@
   5.255 +#cmakedefine SDL_VIDEO_DRIVER_NDS @SDL_VIDEO_DRIVER_NDS@
   5.256 +#cmakedefine SDL_VIDEO_DRIVER_WINDOWS @SDL_VIDEO_DRIVER_WINDOWS@
   5.257 +#cmakedefine SDL_VIDEO_DRIVER_X11 @SDL_VIDEO_DRIVER_X11@
   5.258 +#cmakedefine SDL_VIDEO_DRIVER_X11_DYNAMIC @SDL_VIDEO_DRIVER_X11_DYNAMIC@
   5.259 +#cmakedefine SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT @SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT@
   5.260 +#cmakedefine SDL_VIDEO_DRIVER_X11_DYNAMIC_XCURSOR @SDL_VIDEO_DRIVER_X11_DYNAMIC_XCURSOR@
   5.261 +#cmakedefine SDL_VIDEO_DRIVER_X11_DYNAMIC_XINERAMA @SDL_VIDEO_DRIVER_X11_DYNAMIC_XINERAMA@
   5.262 +#cmakedefine SDL_VIDEO_DRIVER_X11_DYNAMIC_XINPUT2 @SDL_VIDEO_DRIVER_X11_DYNAMIC_XINPUT2@
   5.263 +#cmakedefine SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR @SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR@
   5.264 +#cmakedefine SDL_VIDEO_DRIVER_X11_DYNAMIC_XSS @SDL_VIDEO_DRIVER_X11_DYNAMIC_XSS@
   5.265 +#cmakedefine SDL_VIDEO_DRIVER_X11_DYNAMIC_XVIDMODE @SDL_VIDEO_DRIVER_X11_DYNAMIC_XVIDMODE@
   5.266 +#cmakedefine SDL_VIDEO_DRIVER_X11_XCURSOR @SDL_VIDEO_DRIVER_X11_XCURSOR@
   5.267 +#cmakedefine SDL_VIDEO_DRIVER_X11_XINERAMA @SDL_VIDEO_DRIVER_X11_XINERAMA@
   5.268 +#cmakedefine SDL_VIDEO_DRIVER_X11_XINPUT2 @SDL_VIDEO_DRIVER_X11_XINPUT2@
   5.269 +#cmakedefine SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH @SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH@
   5.270 +#cmakedefine SDL_VIDEO_DRIVER_X11_XRANDR @SDL_VIDEO_DRIVER_X11_XRANDR@
   5.271 +#cmakedefine SDL_VIDEO_DRIVER_X11_XSCRNSAVER @SDL_VIDEO_DRIVER_X11_XSCRNSAVER@
   5.272 +#cmakedefine SDL_VIDEO_DRIVER_X11_XSHAPE @SDL_VIDEO_DRIVER_X11_XSHAPE@
   5.273 +#cmakedefine SDL_VIDEO_DRIVER_X11_XVIDMODE @SDL_VIDEO_DRIVER_X11_XVIDMODE@
   5.274 +#cmakedefine SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS @SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS@
   5.275 +#cmakedefine SDL_VIDEO_DRIVER_X11_CONST_PARAM_XEXTADDDISPLAY @SDL_VIDEO_DRIVER_X11_CONST_PARAM_XEXTADDDISPLAY@
   5.276 +#cmakedefine SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM @SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM@
   5.277 +
   5.278 +#cmakedefine SDL_VIDEO_RENDER_D3D @SDL_VIDEO_RENDER_D3D@
   5.279 +#cmakedefine SDL_VIDEO_RENDER_OGL @SDL_VIDEO_RENDER_OGL@
   5.280 +#cmakedefine SDL_VIDEO_RENDER_OGL_ES @SDL_VIDEO_RENDER_OGL_ES@
   5.281 +#cmakedefine SDL_VIDEO_RENDER_OGL_ES2 @SDL_VIDEO_RENDER_OGL_ES2@
   5.282 +#cmakedefine SDL_VIDEO_RENDER_DIRECTFB @SDL_VIDEO_RENDER_DIRECTFB@
   5.283 +
   5.284 +/* Enable OpenGL support */
   5.285 +#cmakedefine SDL_VIDEO_OPENGL @SDL_VIDEO_OPENGL@
   5.286 +#cmakedefine SDL_VIDEO_OPENGL_ES @SDL_VIDEO_OPENGL_ES@
   5.287 +#cmakedefine SDL_VIDEO_OPENGL_BGL @SDL_VIDEO_OPENGL_BGL@
   5.288 +#cmakedefine SDL_VIDEO_OPENGL_CGL @SDL_VIDEO_OPENGL_CGL@
   5.289 +#cmakedefine SDL_VIDEO_OPENGL_GLX @SDL_VIDEO_OPENGL_GLX@
   5.290 +#cmakedefine SDL_VIDEO_OPENGL_WGL @SDL_VIDEO_OPENGL_WGL@
   5.291 +#cmakedefine SDL_VIDEO_OPENGL_OSMESA @SDL_VIDEO_OPENGL_OSMESA@
   5.292 +#cmakedefine SDL_VIDEO_OPENGL_OSMESA_DYNAMIC @SDL_VIDEO_OPENGL_OSMESA_DYNAMIC@
   5.293 +
   5.294 +/* Enable system power support */
   5.295 +#cmakedefine SDL_POWER_LINUX @SDL_POWER_LINUX@
   5.296 +#cmakedefine SDL_POWER_WINDOWS @SDL_POWER_WINDOWS@
   5.297 +#cmakedefine SDL_POWER_MACOSX @SDL_POWER_MACOSX@
   5.298 +#cmakedefine SDL_POWER_BEOS @SDL_POWER_BEOS@
   5.299 +#cmakedefine SDL_POWER_NINTENDODS @SDL_POWER_NINTENDODS@
   5.300 +#cmakedefine SDL_POWER_HARDWIRED @SDL_POWER_HARDWIRED@
   5.301 +
   5.302 +/* Enable assembly routines */
   5.303 +#cmakedefine SDL_ASSEMBLY_ROUTINES @SDL_ASSEMBLY_ROUTINES@
   5.304 +#cmakedefine SDL_ALTIVEC_BLITTERS @SDL_ALTIVEC_BLITTERS@
   5.305 +
   5.306 +
   5.307 +/* Platform specific definitions */
   5.308 +#if !defined(__WIN32__)
   5.309 +#  if !defined(_STDINT_H_) && !defined(_STDINT_H) && !defined(HAVE_STDINT_H) && !defined(_HAVE_STDINT_H)
   5.310 +typedef unsigned int size_t;
   5.311 +typedef signed char int8_t;
   5.312 +typedef unsigned char uint8_t;
   5.313 +typedef signed short int16_t;
   5.314 +typedef unsigned short uint16_t;
   5.315 +typedef signed int int32_t;
   5.316 +typedef unsigned int uint32_t;
   5.317 +typedef signed long long int64_t;
   5.318 +typedef unsigned long long uint64_t;
   5.319 +typedef unsigned long uintptr_t;
   5.320 +#  endif /* if (stdint.h isn't available) */
   5.321 +#else /* __WIN32__ */
   5.322 +#  if !defined(_STDINT_H_) && !defined(HAVE_STDINT_H) && !defined(_HAVE_STDINT_H)
   5.323 +#    if defined(__GNUC__) || defined(__DMC__) || defined(__WATCOMC__)
   5.324 +#define HAVE_STDINT_H	1
   5.325 +#    elif defined(_MSC_VER)
   5.326 +typedef signed __int8 int8_t;
   5.327 +typedef unsigned __int8 uint8_t;
   5.328 +typedef signed __int16 int16_t;
   5.329 +typedef unsigned __int16 uint16_t;
   5.330 +typedef signed __int32 int32_t;
   5.331 +typedef unsigned __int32 uint32_t;
   5.332 +typedef signed __int64 int64_t;
   5.333 +typedef unsigned __int64 uint64_t;
   5.334 +#      ifndef _UINTPTR_T_DEFINED
   5.335 +#        ifdef  _WIN64
   5.336 +typedef unsigned __int64 uintptr_t;
   5.337 +#          else
   5.338 +typedef unsigned int uintptr_t;
   5.339 +#        endif
   5.340 +#define _UINTPTR_T_DEFINED
   5.341 +#      endif
   5.342 +/* Older Visual C++ headers don't have the Win64-compatible typedefs... */
   5.343 +#      if ((_MSC_VER <= 1200) && (!defined(DWORD_PTR)))
   5.344 +#define DWORD_PTR DWORD
   5.345 +#      endif
   5.346 +#      if ((_MSC_VER <= 1200) && (!defined(LONG_PTR)))
   5.347 +#define LONG_PTR LONG
   5.348 +#      endif
   5.349 +#    else /* !__GNUC__ && !_MSC_VER */
   5.350 +typedef signed char int8_t;
   5.351 +typedef unsigned char uint8_t;
   5.352 +typedef signed short int16_t;
   5.353 +typedef unsigned short uint16_t;
   5.354 +typedef signed int int32_t;
   5.355 +typedef unsigned int uint32_t;
   5.356 +typedef signed long long int64_t;
   5.357 +typedef unsigned long long uint64_t;
   5.358 +#      ifndef _SIZE_T_DEFINED_
   5.359 +#define _SIZE_T_DEFINED_
   5.360 +typedef unsigned int size_t;
   5.361 +#      endif
   5.362 +typedef unsigned int uintptr_t;
   5.363 +#    endif /* __GNUC__ || _MSC_VER */
   5.364 +#  endif /* !_STDINT_H_ && !HAVE_STDINT_H */
   5.365 +#endif /* __WIN32__ */
   5.366 +
   5.367 +#endif /* _SDL_config_h */