CMakeLists.txt
changeset 6674 45a21e50ba5e
child 6729 fdaeea9e7567
     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)