CMakeLists.txt
author Olli Kallioinen <olli.kallioinen@iki.fi>
Thu, 08 Jun 2017 22:07:55 +0300
changeset 11207 4ed2e42b7497
parent 11175 cbc6a8a5b701
child 11210 c92070a96da5
permissions -rw-r--r--
Android build fixes
-Enabling checking for GCC_ATOMICS also on clang by default. This way all Android ABIs build successfully
-Android cmake: Threading was not enabled correctly
-Android cmake: Timers and dynamic lib loading were not included in the sources
     1 if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
     2   message(FATAL_ERROR "Prevented in-tree built. Please create a build directory outside of the SDL source code and call cmake from there")
     3 endif()
     4 
     5 cmake_minimum_required(VERSION 2.8.5)
     6 project(SDL2 C)
     7 
     8 # !!! FIXME: this should probably do "MACOSX_RPATH ON" as a target property
     9 # !!! FIXME:  for the SDL2 shared library (so you get an
    10 # !!! FIXME:  install_name ("soname") of "@rpath/libSDL-whatever.dylib"
    11 # !!! FIXME:  instead of "/usr/local/lib/libSDL-whatever.dylib"), but I'm
    12 # !!! FIXME:  punting for now and leaving the existing behavior. Until this
    13 # !!! FIXME:  properly resolved, this line silences a warning in CMake 3.0+.
    14 # !!! FIXME:  remove it and this comment entirely once the problem is
    15 # !!! FIXME:  properly resolved.
    16 #cmake_policy(SET CMP0042 OLD)
    17 
    18 include(CheckFunctionExists)
    19 include(CheckLibraryExists)
    20 include(CheckIncludeFiles)
    21 include(CheckIncludeFile)
    22 include(CheckSymbolExists)
    23 include(CheckCSourceRuns)
    24 include(CheckCCompilerFlag)
    25 include(CheckTypeSize)
    26 include(CheckStructHasMember)
    27 include(CMakeDependentOption)
    28 include(FindPkgConfig)
    29 include(GNUInstallDirs)
    30 set(CMAKE_MODULE_PATH "${SDL2_SOURCE_DIR}/cmake")
    31 include(${SDL2_SOURCE_DIR}/cmake/macros.cmake)
    32 include(${SDL2_SOURCE_DIR}/cmake/sdlchecks.cmake)
    33 
    34 # General settings
    35 # Edit include/SDL_version.h and change the version, then:
    36 #   SDL_MICRO_VERSION += 1;
    37 #   SDL_INTERFACE_AGE += 1;
    38 #   SDL_BINARY_AGE += 1;
    39 # if any functions have been added, set SDL_INTERFACE_AGE to 0.
    40 # if backwards compatibility has been broken,
    41 # set SDL_BINARY_AGE and SDL_INTERFACE_AGE to 0.
    42 set(SDL_MAJOR_VERSION 2)
    43 set(SDL_MINOR_VERSION 0)
    44 set(SDL_MICRO_VERSION 5)
    45 set(SDL_INTERFACE_AGE 1)
    46 set(SDL_BINARY_AGE 5)
    47 set(SDL_VERSION "${SDL_MAJOR_VERSION}.${SDL_MINOR_VERSION}.${SDL_MICRO_VERSION}")
    48 
    49 # Calculate a libtool-like version number
    50 math(EXPR LT_CURRENT "${SDL_MICRO_VERSION} - ${SDL_INTERFACE_AGE}")
    51 math(EXPR LT_AGE "${SDL_BINARY_AGE} - ${SDL_INTERFACE_AGE}")
    52 math(EXPR LT_MAJOR "${LT_CURRENT}- ${LT_AGE}")
    53 set(LT_REVISION "${SDL_INTERFACE_AGE}")
    54 set(LT_RELEASE "${SDL_MAJOR_VERSION}.${SDL_MINOR_VERSION}")
    55 set(LT_VERSION "${LT_MAJOR}.${LT_AGE}.${LT_REVISION}")
    56 
    57 message(STATUS "${LT_VERSION} :: ${LT_AGE} :: ${LT_REVISION} :: ${LT_CURRENT} :: ${LT_RELEASE}")
    58 
    59 # General settings & flags
    60 set(LIBRARY_OUTPUT_DIRECTORY "build")
    61 # Check for 64 or 32 bit
    62 set(SIZEOF_VOIDP ${CMAKE_SIZEOF_VOID_P})
    63 if(CMAKE_SIZEOF_VOID_P EQUAL 8)
    64   set(ARCH_64 TRUE)
    65   set(PROCESSOR_ARCH "x64")
    66 else()
    67   set(ARCH_64 FALSE)
    68   set(PROCESSOR_ARCH "x86")
    69 endif()
    70 set(LIBNAME SDL2)
    71 if(NOT LIBTYPE)
    72   set(LIBTYPE SHARED)
    73 endif()
    74 
    75 # Get the platform
    76 if(WIN32)
    77   if(NOT WINDOWS)
    78     set(WINDOWS TRUE)
    79   endif()
    80 elseif(UNIX AND NOT APPLE)
    81   if(CMAKE_SYSTEM_NAME MATCHES ".*Linux")
    82     set(LINUX TRUE)
    83   elseif(CMAKE_SYSTEM_NAME MATCHES "kFreeBSD.*")
    84     set(FREEBSD TRUE)
    85   elseif(CMAKE_SYSTEM_NAME MATCHES "kNetBSD.*|NetBSD.*")
    86     set(NETBSD TRUE)
    87   elseif(CMAKE_SYSTEM_NAME MATCHES "kOpenBSD.*|OpenBSD.*")
    88     set(OPENBSD TRUE)
    89   elseif(CMAKE_SYSTEM_NAME MATCHES ".*GNU.*")
    90     set(GNU TRUE)
    91   elseif(CMAKE_SYSTEM_NAME MATCHES ".*BSDI.*")
    92     set(BSDI TRUE)
    93   elseif(CMAKE_SYSTEM_NAME MATCHES "DragonFly.*|FreeBSD")
    94     set(FREEBSD TRUE)
    95   elseif(CMAKE_SYSTEM_NAME MATCHES "SYSV5.*")
    96     set(SYSV5 TRUE)
    97   elseif(CMAKE_SYSTEM_NAME MATCHES "Solaris.*")
    98     set(SOLARIS TRUE)
    99   elseif(CMAKE_SYSTEM_NAME MATCHES "HP-UX.*")
   100     set(HPUX TRUE)
   101   elseif(CMAKE_SYSTEM_NAME MATCHES "AIX.*")
   102     set(AIX TRUE)
   103   elseif(CMAKE_SYSTEM_NAME MATCHES "Minix.*")
   104     set(MINIX TRUE)
   105   endif()
   106 elseif(APPLE)
   107   if(CMAKE_SYSTEM_NAME MATCHES ".*Darwin.*")
   108     set(DARWIN TRUE)
   109   elseif(CMAKE_SYSTEM_NAME MATCHES ".*MacOS.*")
   110     set(MACOSX TRUE)
   111   endif()
   112   # TODO: iOS?
   113 elseif(CMAKE_SYSTEM_NAME MATCHES "BeOS.*")
   114   message_error("BeOS support has been removed as of SDL 2.0.2.")
   115 elseif(CMAKE_SYSTEM_NAME MATCHES "Haiku.*")
   116   set(HAIKU TRUE)
   117 endif()
   118 
   119 # Don't mistake osx for unix
   120 if(UNIX AND NOT APPLE)
   121   set(UNIX_SYS ON)
   122 else()
   123   set(UNIX_SYS OFF)
   124 endif()
   125 
   126 if(UNIX OR APPLE)
   127   set(UNIX_OR_MAC_SYS ON)
   128 else()
   129   set(UNIX_OR_MAC_SYS OFF)
   130 endif()
   131 
   132 if (UNIX_OR_MAC_SYS AND NOT EMSCRIPTEN) # JavaScript does not yet have threading support, so disable pthreads when building for Emscripten.
   133   set(SDL_PTHREADS_ENABLED_BY_DEFAULT ON)
   134 else()
   135   set(SDL_PTHREADS_ENABLED_BY_DEFAULT OFF)
   136 endif()
   137 
   138 # Default option knobs
   139 if(APPLE OR ARCH_64)
   140   if(NOT "${CMAKE_OSX_ARCHITECTURES}" MATCHES "arm")
   141     set(OPT_DEF_SSEMATH ON)
   142   endif()
   143 endif()
   144 if(UNIX OR MINGW OR MSYS)
   145   set(OPT_DEF_LIBC ON)
   146 endif()
   147 
   148 # Compiler info
   149 if(CMAKE_COMPILER_IS_GNUCC)
   150   set(USE_GCC TRUE)
   151   set(OPT_DEF_ASM TRUE)
   152 elseif(CMAKE_C_COMPILER_ID MATCHES "Clang")
   153   set(USE_CLANG TRUE)
   154   set(OPT_DEF_ASM TRUE)
   155 elseif(MSVC_VERSION GREATER 1400) # VisualStudio 8.0+
   156   set(OPT_DEF_ASM TRUE)
   157   #set(CMAKE_C_FLAGS "/ZI /WX- /
   158 else()
   159   set(OPT_DEF_ASM FALSE)
   160 endif()
   161 
   162 if(USE_GCC OR USE_CLANG)
   163   set(OPT_DEF_GCC_ATOMICS ON)
   164 endif()
   165 
   166 # Default flags, if not set otherwise
   167 if("$ENV{CFLAGS}" STREQUAL "")
   168   if(CMAKE_BUILD_TYPE STREQUAL "")
   169     if(USE_GCC OR USE_CLANG)
   170       set(CMAKE_C_FLAGS "-g -O3")
   171     endif()
   172   endif()
   173 else()
   174   set(CMAKE_C_FLAGS "$ENV{CFLAGS}")
   175   list(APPEND EXTRA_CFLAGS "$ENV{CFLAGS}")
   176 endif()
   177 if(NOT ("$ENV{CFLAGS}" STREQUAL "")) # Hackish, but does the trick on Win32
   178   list(APPEND EXTRA_LDFLAGS "$ENV{LDFLAGS}")
   179 endif()
   180 
   181 if(MSVC)
   182   option(FORCE_STATIC_VCRT "Force /MT for static VC runtimes" OFF)
   183   if(FORCE_STATIC_VCRT)
   184     foreach(flag_var
   185         CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
   186         CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO)
   187       if(${flag_var} MATCHES "/MD")
   188         string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
   189       endif()
   190     endforeach()
   191   endif()
   192 
   193   # Make sure /RTC1 is disabled, otherwise it will use functions from the CRT
   194   foreach(flag_var
   195       CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
   196       CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO)
   197     string(REGEX REPLACE "/RTC(su|[1su])" "" ${flag_var} "${${flag_var}}")
   198   endforeach(flag_var)
   199 endif()
   200 
   201 # Those are used for pkg-config and friends, so that the SDL2.pc, sdl2-config,
   202 # etc. are created correctly.
   203 set(SDL_LIBS "-lSDL2")
   204 set(SDL_CFLAGS "")
   205 
   206 # Emscripten toolchain has a nonempty default value for this, and the checks 
   207 # in this file need to change that, so remember the original value, and 
   208 # restore back to that afterwards. For check_function_exists() to work in
   209 # Emscripten, this value must be at its default value.
   210 set(ORIG_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
   211 
   212 if(CYGWIN)
   213   # We build SDL on cygwin without the UNIX emulation layer
   214   include_directories("-I/usr/include/mingw")
   215   set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -mno-cygwin")
   216   check_c_source_compiles("int main(int argc, char **argv) {}"
   217     HAVE_GCC_NO_CYGWIN)
   218   set(CMAKE_REQUIRED_FLAGS ${ORIG_CMAKE_REQUIRED_FLAGS})
   219   if(HAVE_GCC_NO_CYGWIN)
   220     list(APPEND EXTRA_LDFLAGS "-mno-cygwin")
   221     list(APPEND SDL_LIBS "-mno-cygwin")
   222   endif()
   223   set(SDL_CFLAGS "${SDL_CFLAGS} -I/usr/include/mingw")
   224 endif()
   225 
   226 add_definitions(-DUSING_GENERATED_CONFIG_H)
   227 # General includes
   228 include_directories(${SDL2_BINARY_DIR}/include ${SDL2_SOURCE_DIR}/include)
   229 
   230 # All these ENABLED_BY_DEFAULT vars will default to ON if not specified, so
   231 #  you only need to have a platform override them if they are disabling.
   232 set(OPT_DEF_ASM TRUE)
   233 if(EMSCRIPTEN)
   234   # Set up default values for the currently supported set of subsystems:
   235   # Emscripten/Javascript does not have assembly support, a dynamic library 
   236   # loading architecture, low-level CPU inspection or multithreading.
   237   set(OPT_DEF_ASM FALSE)
   238   set(SDL_SHARED_ENABLED_BY_DEFAULT OFF)
   239   set(SDL_ATOMIC_ENABLED_BY_DEFAULT OFF)
   240   set(SDL_THREADS_ENABLED_BY_DEFAULT OFF)
   241   set(SDL_LOADSO_ENABLED_BY_DEFAULT OFF)
   242   set(SDL_CPUINFO_ENABLED_BY_DEFAULT OFF)
   243   set(SDL_DLOPEN_ENABLED_BY_DEFAULT OFF)
   244 endif()
   245 
   246 if (NOT DEFINED SDL_SHARED_ENABLED_BY_DEFAULT)
   247     set(SDL_SHARED_ENABLED_BY_DEFAULT ON)
   248 endif()
   249 
   250 set(SDL_SUBSYSTEMS
   251     Atomic Audio Video Render Events Joystick Haptic Power Threads Timers
   252     File Loadso CPUinfo Filesystem Dlopen)
   253 foreach(_SUB ${SDL_SUBSYSTEMS})
   254   string(TOUPPER ${_SUB} _OPT)
   255   if (NOT DEFINED SDL_${_OPT}_ENABLED_BY_DEFAULT)
   256     set(SDL_${_OPT}_ENABLED_BY_DEFAULT ON)
   257   endif()
   258   option(SDL_${_OPT} "Enable the ${_SUB} subsystem" ${SDL_${_OPT}_ENABLED_BY_DEFAULT})
   259 endforeach()
   260 
   261 option_string(ASSERTIONS "Enable internal sanity checks (auto/disabled/release/enabled/paranoid)" "auto")
   262 #set_option(DEPENDENCY_TRACKING "Use gcc -MMD -MT dependency tracking" ON)
   263 set_option(LIBC                "Use the system C library" ${OPT_DEF_LIBC})
   264 set_option(GCC_ATOMICS         "Use gcc builtin atomics" ${OPT_DEF_GCC_ATOMICS})
   265 set_option(ASSEMBLY            "Enable assembly routines" ${OPT_DEF_ASM})
   266 set_option(SSEMATH             "Allow GCC to use SSE floating point math" ${OPT_DEF_SSEMATH})
   267 set_option(MMX                 "Use MMX assembly routines" ${OPT_DEF_ASM})
   268 set_option(3DNOW               "Use 3Dnow! MMX assembly routines" ${OPT_DEF_ASM})
   269 set_option(SSE                 "Use SSE assembly routines" ${OPT_DEF_ASM})
   270 set_option(SSE2                "Use SSE2 assembly routines" ${OPT_DEF_SSEMATH})
   271 set_option(SSE3                "Use SSE3 assembly routines" ${OPT_DEF_SSEMATH})
   272 set_option(ALTIVEC             "Use Altivec assembly routines" ${OPT_DEF_ASM})
   273 set_option(DISKAUDIO           "Support the disk writer audio driver" ON)
   274 set_option(DUMMYAUDIO          "Support the dummy audio driver" ON)
   275 set_option(VIDEO_DIRECTFB      "Use DirectFB video driver" OFF)
   276 dep_option(DIRECTFB_SHARED     "Dynamically load directfb support" ON "VIDEO_DIRECTFB" OFF)
   277 set_option(VIDEO_DUMMY         "Use dummy video driver" ON)
   278 set_option(VIDEO_OPENGL        "Include OpenGL support" ON)
   279 set_option(VIDEO_OPENGLES      "Include OpenGL ES support" ON)
   280 set_option(PTHREADS            "Use POSIX threads for multi-threading" ${SDL_PTHREADS_ENABLED_BY_DEFAULT})
   281 dep_option(PTHREADS_SEM        "Use pthread semaphores" ON "PTHREADS" OFF)
   282 set_option(SDL_DLOPEN          "Use dlopen for shared object loading" ${SDL_DLOPEN_ENABLED_BY_DEFAULT})
   283 set_option(OSS                 "Support the OSS audio API" ${UNIX_SYS})
   284 set_option(ALSA                "Support the ALSA audio API" ${UNIX_SYS})
   285 dep_option(ALSA_SHARED         "Dynamically load ALSA audio support" ON "ALSA" OFF)
   286 set_option(JACK                "Support the JACK audio API" ${UNIX_SYS})
   287 dep_option(JACK_SHARED         "Dynamically load JACK audio support" ON "JACK" OFF)
   288 set_option(ESD                 "Support the Enlightened Sound Daemon" ${UNIX_SYS})
   289 dep_option(ESD_SHARED          "Dynamically load ESD audio support" ON "ESD" OFF)
   290 set_option(PULSEAUDIO          "Use PulseAudio" ${UNIX_SYS})
   291 dep_option(PULSEAUDIO_SHARED   "Dynamically load PulseAudio support" ON "PULSEAUDIO" OFF)
   292 set_option(ARTS                "Support the Analog Real Time Synthesizer" ${UNIX_SYS})
   293 dep_option(ARTS_SHARED         "Dynamically load aRts audio support" ON "ARTS" OFF)
   294 set_option(NAS                 "Support the NAS audio API" ${UNIX_SYS})
   295 set_option(NAS_SHARED          "Dynamically load NAS audio API" ${UNIX_SYS})
   296 set_option(SNDIO               "Support the sndio audio API" ${UNIX_SYS})
   297 set_option(FUSIONSOUND         "Use FusionSound audio driver" OFF)
   298 dep_option(FUSIONSOUND_SHARED  "Dynamically load fusionsound audio support" ON "FUSIONSOUND" OFF)
   299 set_option(LIBSAMPLERATE       "Use libsamplerate for audio rate conversion" ${UNIX_SYS})
   300 dep_option(LIBSAMPLERATE_SHARED "Dynamically load libsamplerate" ON "LIBSAMPLERATE" OFF)
   301 set_option(RPATH               "Use an rpath when linking SDL" ${UNIX_SYS})
   302 set_option(CLOCK_GETTIME       "Use clock_gettime() instead of gettimeofday()" OFF)
   303 set_option(INPUT_TSLIB         "Use the Touchscreen library for input" ${UNIX_SYS})
   304 set_option(VIDEO_X11           "Use X11 video driver" ${UNIX_SYS})
   305 set_option(VIDEO_WAYLAND       "Use Wayland video driver" ${UNIX_SYS})
   306 dep_option(WAYLAND_SHARED      "Dynamically load Wayland support" ON "VIDEO_WAYLAND" OFF)
   307 dep_option(VIDEO_WAYLAND_QT_TOUCH  "QtWayland server support for Wayland video driver" ON "VIDEO_WAYLAND" OFF)
   308 set_option(VIDEO_MIR           "Use Mir video driver" ${UNIX_SYS})
   309 dep_option(MIR_SHARED          "Dynamically load Mir support" ON "VIDEO_MIR" OFF)
   310 set_option(VIDEO_RPI           "Use Raspberry Pi video driver" ${UNIX_SYS})
   311 dep_option(X11_SHARED          "Dynamically load X11 support" ON "VIDEO_X11" OFF)
   312 set(SDL_X11_OPTIONS Xcursor Xinerama XInput Xrandr Xscrnsaver XShape Xvm)
   313 foreach(_SUB ${SDL_X11_OPTIONS})
   314   string(TOUPPER "VIDEO_X11_${_SUB}" _OPT)
   315   dep_option(${_OPT}           "Enable ${_SUB} support" ON "VIDEO_X11" OFF)
   316 endforeach()
   317 set_option(VIDEO_COCOA         "Use Cocoa video driver" ${APPLE})
   318 set_option(DIRECTX             "Use DirectX for Windows audio/video" ${WINDOWS})
   319 set_option(RENDER_D3D          "Enable the Direct3D render driver" ${WINDOWS})
   320 set_option(VIDEO_VIVANTE       "Use Vivante EGL video driver" ${UNIX_SYS})
   321 set_option(VIDEO_KMSDRM        "Use KMS DRM video driver" ${UNIX_SYS})
   322 dep_option(KMSDRM_SHARED       "Dynamically load KMS DRM support" ON "VIDEO_KMSDRM" OFF)
   323 
   324 # TODO: We should (should we?) respect cmake's ${BUILD_SHARED_LIBS} flag here
   325 # The options below are for compatibility to configure's default behaviour.
   326 set(SDL_SHARED ${SDL_SHARED_ENABLED_BY_DEFAULT} CACHE BOOL "Build a shared version of the library")
   327 set(SDL_STATIC ON CACHE BOOL "Build a static version of the library")
   328 
   329 dep_option(SDL_STATIC_PIC      "Static version of the library should be built with Position Independent Code" OFF "SDL_STATIC" OFF)
   330 
   331 # General source files
   332 file(GLOB SOURCE_FILES
   333   ${SDL2_SOURCE_DIR}/src/*.c
   334   ${SDL2_SOURCE_DIR}/src/atomic/*.c
   335   ${SDL2_SOURCE_DIR}/src/audio/*.c
   336   ${SDL2_SOURCE_DIR}/src/cpuinfo/*.c
   337   ${SDL2_SOURCE_DIR}/src/dynapi/*.c
   338   ${SDL2_SOURCE_DIR}/src/events/*.c
   339   ${SDL2_SOURCE_DIR}/src/file/*.c
   340   ${SDL2_SOURCE_DIR}/src/libm/*.c
   341   ${SDL2_SOURCE_DIR}/src/render/*.c
   342   ${SDL2_SOURCE_DIR}/src/render/*/*.c
   343   ${SDL2_SOURCE_DIR}/src/stdlib/*.c
   344   ${SDL2_SOURCE_DIR}/src/thread/*.c
   345   ${SDL2_SOURCE_DIR}/src/timer/*.c
   346   ${SDL2_SOURCE_DIR}/src/video/*.c)
   347 
   348 
   349 if(ASSERTIONS STREQUAL "auto")
   350   # Do nada - use optimization settings to determine the assertion level
   351 elseif(ASSERTIONS STREQUAL "disabled")
   352   set(SDL_DEFAULT_ASSERT_LEVEL 0)
   353 elseif(ASSERTIONS STREQUAL "release")
   354   set(SDL_DEFAULT_ASSERT_LEVEL 1)
   355 elseif(ASSERTIONS STREQUAL "enabled")
   356   set(SDL_DEFAULT_ASSERT_LEVEL 2)
   357 elseif(ASSERTIONS STREQUAL "paranoid")
   358   set(SDL_DEFAULT_ASSERT_LEVEL 3)
   359 else()
   360   message_error("unknown assertion level")
   361 endif()
   362 set(HAVE_ASSERTIONS ${ASSERTIONS})
   363 
   364 # Compiler option evaluation
   365 if(USE_GCC OR USE_CLANG)
   366   # Check for -Wall first, so later things can override pieces of it.
   367   check_c_compiler_flag(-Wall HAVE_GCC_WALL)
   368   if(HAVE_GCC_WALL)
   369     list(APPEND EXTRA_CFLAGS "-Wall")
   370     if(HAIKU)
   371       set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-multichar")
   372     endif()
   373   endif()
   374 
   375   check_c_compiler_flag(-Wdeclaration-after-statement HAVE_GCC_WDECLARATION_AFTER_STATEMENT)
   376   if(HAVE_GCC_WDECLARATION_AFTER_STATEMENT)
   377     check_c_compiler_flag(-Werror=declaration-after-statement HAVE_GCC_WERROR_DECLARATION_AFTER_STATEMENT)
   378     if(HAVE_GCC_WERROR_DECLARATION_AFTER_STATEMENT)
   379       list(APPEND EXTRA_CFLAGS "-Werror=declaration-after-statement")
   380     endif()
   381     list(APPEND EXTRA_CFLAGS "-Wdeclaration-after-statement")
   382   endif()
   383 
   384   if(DEPENDENCY_TRACKING)
   385     check_c_source_compiles("
   386         #if !defined(__GNUC__) || __GNUC__ < 3
   387         #error Dependency tracking requires GCC 3.0 or newer
   388         #endif
   389         int main(int argc, char **argv) { }" HAVE_DEPENDENCY_TRACKING)
   390   endif()
   391 
   392   if(GCC_ATOMICS)
   393     check_c_source_compiles("int main(int argc, char **argv) {
   394         int a;
   395         void *x, *y, *z;
   396         __sync_lock_test_and_set(&a, 4);
   397         __sync_lock_test_and_set(&x, y);
   398         __sync_fetch_and_add(&a, 1);
   399         __sync_bool_compare_and_swap(&a, 5, 10);
   400         __sync_bool_compare_and_swap(&x, y, z); }" HAVE_GCC_ATOMICS)
   401     if(NOT HAVE_GCC_ATOMICS)
   402       check_c_source_compiles("int main(int argc, char **argv) {
   403           int a;
   404           __sync_lock_test_and_set(&a, 1);
   405           __sync_lock_release(&a); }" HAVE_GCC_SYNC_LOCK_TEST_AND_SET)
   406     endif()
   407   endif()
   408 
   409   set(CMAKE_REQUIRED_FLAGS "-mpreferred-stack-boundary=2")
   410   check_c_source_compiles("int x = 0; int main(int argc, char **argv) {}"
   411     HAVE_GCC_PREFERRED_STACK_BOUNDARY)
   412   set(CMAKE_REQUIRED_FLAGS ${ORIG_CMAKE_REQUIRED_FLAGS})
   413 
   414   set(CMAKE_REQUIRED_FLAGS "-fvisibility=hidden -Werror")
   415   check_c_source_compiles("
   416       #if !defined(__GNUC__) || __GNUC__ < 4
   417       #error SDL only uses visibility attributes in GCC 4 or newer
   418       #endif
   419       int main(int argc, char **argv) {}" HAVE_GCC_FVISIBILITY)
   420   if(HAVE_GCC_FVISIBILITY)
   421     list(APPEND EXTRA_CFLAGS "-fvisibility=hidden")
   422   endif()
   423   set(CMAKE_REQUIRED_FLAGS ${ORIG_CMAKE_REQUIRED_FLAGS})
   424 
   425   check_c_compiler_flag(-Wshadow HAVE_GCC_WSHADOW)
   426   if(HAVE_GCC_WSHADOW)
   427     list(APPEND EXTRA_CFLAGS "-Wshadow")
   428   endif()
   429 
   430   set(CMAKE_REQUIRED_FLAGS "-Wl,--no-undefined")
   431   check_c_compiler_flag("" HAVE_NO_UNDEFINED)
   432   set(CMAKE_REQUIRED_FLAGS ${ORIG_CMAKE_REQUIRED_FLAGS})
   433   if(HAVE_NO_UNDEFINED)
   434     list(APPEND EXTRA_LDFLAGS "-Wl,--no-undefined")
   435   endif()
   436 endif()
   437 
   438 if(ASSEMBLY)
   439   if(USE_GCC OR USE_CLANG)
   440     set(SDL_ASSEMBLY_ROUTINES 1)
   441     # TODO: Those all seem to be quite GCC specific - needs to be
   442     # reworked for better compiler support
   443     set(HAVE_ASSEMBLY TRUE)
   444     if(MMX)
   445       set(CMAKE_REQUIRED_FLAGS "-mmmx")
   446       check_c_source_compiles("
   447           #ifdef __MINGW32__
   448           #include <_mingw.h>
   449           #ifdef __MINGW64_VERSION_MAJOR
   450           #include <intrin.h>
   451           #else
   452           #include <mmintrin.h>
   453           #endif
   454           #else
   455           #include <mmintrin.h>
   456           #endif
   457           #ifndef __MMX__
   458           #error Assembler CPP flag not enabled
   459           #endif
   460           int main(int argc, char **argv) { }" HAVE_MMX)
   461       if(HAVE_MMX)
   462         list(APPEND EXTRA_CFLAGS "-mmmx")
   463       endif()
   464       set(CMAKE_REQUIRED_FLAGS ${ORIG_CMAKE_REQUIRED_FLAGS})
   465     endif()
   466 
   467     if(3DNOW)
   468       set(CMAKE_REQUIRED_FLAGS "-m3dnow")
   469       check_c_source_compiles("
   470           #include <mm3dnow.h>
   471           #ifndef __3dNOW__
   472           #error Assembler CPP flag not enabled
   473           #endif
   474           int main(int argc, char **argv) {
   475             void *p = 0;
   476             _m_prefetch(p);
   477           }" HAVE_3DNOW)
   478       if(HAVE_3DNOW)
   479         list(APPEND EXTRA_CFLAGS "-m3dnow")
   480       endif()
   481       set(CMAKE_REQUIRED_FLAGS ${ORIG_CMAKE_REQUIRED_FLAGS})
   482     endif()
   483 
   484     if(SSE)
   485       set(CMAKE_REQUIRED_FLAGS "-msse")
   486       check_c_source_compiles("
   487           #ifdef __MINGW32__
   488           #include <_mingw.h>
   489           #ifdef __MINGW64_VERSION_MAJOR
   490           #include <intrin.h>
   491           #else
   492           #include <xmmintrin.h>
   493           #endif
   494           #else
   495           #include <xmmintrin.h>
   496           #endif
   497           #ifndef __SSE__
   498           #error Assembler CPP flag not enabled
   499           #endif
   500           int main(int argc, char **argv) { }" HAVE_SSE)
   501       if(HAVE_SSE)
   502         list(APPEND EXTRA_CFLAGS "-msse")
   503       endif()
   504       set(CMAKE_REQUIRED_FLAGS ${ORIG_CMAKE_REQUIRED_FLAGS})
   505     endif()
   506 
   507     if(SSE2)
   508       set(CMAKE_REQUIRED_FLAGS "-msse2")
   509       check_c_source_compiles("
   510           #ifdef __MINGW32__
   511           #include <_mingw.h>
   512           #ifdef __MINGW64_VERSION_MAJOR
   513           #include <intrin.h>
   514           #else
   515           #include <emmintrin.h>
   516           #endif
   517           #else
   518           #include <emmintrin.h>
   519           #endif
   520           #ifndef __SSE2__
   521           #error Assembler CPP flag not enabled
   522           #endif
   523           int main(int argc, char **argv) { }" HAVE_SSE2)
   524       if(HAVE_SSE2)
   525         list(APPEND EXTRA_CFLAGS "-msse2")
   526       endif()
   527       set(CMAKE_REQUIRED_FLAGS ${ORIG_CMAKE_REQUIRED_FLAGS})
   528     endif()
   529 
   530     if(SSE3)
   531       set(CMAKE_REQUIRED_FLAGS "-msse3")
   532       check_c_source_compiles("
   533           #ifdef __MINGW32__
   534           #include <_mingw.h>
   535           #ifdef __MINGW64_VERSION_MAJOR
   536           #include <intrin.h>
   537           #else
   538           #include <pmmintrin.h>
   539           #endif
   540           #else
   541           #include <pmmintrin.h>
   542           #endif
   543           #ifndef __SSE3__
   544           #error Assembler CPP flag not enabled
   545           #endif
   546           int main(int argc, char **argv) { }" HAVE_SSE3)
   547       if(HAVE_SSE3)
   548         list(APPEND EXTRA_CFLAGS "-msse3")
   549       endif()
   550       set(CMAKE_REQUIRED_FLAGS ${ORIG_CMAKE_REQUIRED_FLAGS})
   551     endif()
   552 
   553     if(NOT SSEMATH)
   554       if(SSE OR SSE2 OR SSE3)
   555         if(USE_GCC)
   556           check_c_compiler_flag(-mfpmath=387 HAVE_FP_387)
   557           if(HAVE_FP_387)
   558             list(APPEND EXTRA_CFLAGS "-mfpmath=387")
   559           endif()
   560         endif()
   561         set(HAVE_SSEMATH TRUE)
   562       endif()
   563     endif()
   564 
   565     if(ALTIVEC)
   566       set(CMAKE_REQUIRED_FLAGS "-maltivec")
   567       check_c_source_compiles("
   568           #include <altivec.h>
   569           vector unsigned int vzero() {
   570               return vec_splat_u32(0);
   571           }
   572           int main(int argc, char **argv) { }" HAVE_ALTIVEC_H_HDR)
   573       check_c_source_compiles("
   574           vector unsigned int vzero() {
   575               return vec_splat_u32(0);
   576           }
   577           int main(int argc, char **argv) { }" HAVE_ALTIVEC)
   578       set(CMAKE_REQUIRED_FLAGS ${ORIG_CMAKE_REQUIRED_FLAGS})
   579       if(HAVE_ALTIVEC OR HAVE_ALTIVEC_H_HDR)
   580         set(HAVE_ALTIVEC TRUE) # if only HAVE_ALTIVEC_H_HDR is set
   581         list(APPEND EXTRA_CFLAGS "-maltivec")
   582         set(SDL_ALTIVEC_BLITTERS 1)
   583         if(HAVE_ALTIVEC_H_HDR)
   584           set(HAVE_ALTIVEC_H 1)
   585         endif()
   586       endif()
   587     endif()
   588   elseif(MSVC_VERSION GREATER 1500)
   589     # TODO: SDL_cpuinfo.h needs to support the user's configuration wish
   590     # for MSVC - right now it is always activated
   591     if(NOT ARCH_64)
   592       set(HAVE_MMX TRUE)
   593       set(HAVE_3DNOW TRUE)
   594     endif()
   595     set(HAVE_SSE TRUE)
   596     set(HAVE_SSE2 TRUE)
   597     set(HAVE_SSE3 TRUE)
   598     set(SDL_ASSEMBLY_ROUTINES 1)
   599   endif()
   600 # TODO:
   601 #else()
   602 #  if(USE_GCC OR USE_CLANG)
   603 #    list(APPEND EXTRA_CFLAGS "-mno-sse" "-mno-sse2" "-mno-sse3" "-mno-mmx")
   604 #  endif()
   605 endif()
   606 
   607 # TODO: Can't deactivate on FreeBSD? w/o LIBC, SDL_stdinc.h can't define
   608 # anything.
   609 if(LIBC)
   610   if(WINDOWS AND NOT MINGW)
   611     set(HAVE_LIBC TRUE)
   612     foreach(_HEADER stdio.h string.h ctype.h math.h)
   613       string(TOUPPER "HAVE_${_HEADER}" _UPPER)
   614       string(REPLACE "." "_" _HAVE_H ${_UPPER})
   615       set(${_HAVE_H} 1)
   616     endforeach()
   617     set(HAVE_SIGNAL_H 1)
   618     foreach(_FN
   619             malloc calloc realloc free qsort abs memset memcpy memmove memcmp
   620             strlen _strrev _strupr _strlwr strchr strrchr strstr itoa _ltoa
   621             _ultoa strtol strtoul strtoll strtod atoi atof strcmp strncmp
   622             _stricmp _strnicmp sscanf atan atan2 acos asin ceil copysign cos
   623             cosf fabs floor log pow scalbn sin sinf sqrt sqrtf tan tanf)
   624       string(TOUPPER ${_FN} _UPPER)
   625       set(HAVE_${_UPPER} 1)
   626     endforeach()
   627     if(NOT CYGWIN AND NOT MINGW)
   628       set(HAVE_ALLOCA 1)
   629     endif()
   630     set(HAVE_M_PI 1)
   631     add_definitions(-D_USE_MATH_DEFINES) # needed for M_PI
   632     set(STDC_HEADERS 1)
   633   else()
   634     set(HAVE_LIBC TRUE)
   635     check_include_file(sys/types.h HAVE_SYS_TYPES_H)
   636     foreach(_HEADER
   637             stdio.h stdlib.h stddef.h stdarg.h malloc.h memory.h string.h
   638             strings.h inttypes.h stdint.h ctype.h math.h iconv.h signal.h)
   639       string(TOUPPER "HAVE_${_HEADER}" _UPPER)
   640       string(REPLACE "." "_" _HAVE_H ${_UPPER})
   641       check_include_file("${_HEADER}" ${_HAVE_H})
   642     endforeach()
   643 
   644     check_include_files("dlfcn.h;stdint.h;stddef.h;inttypes.h;stdlib.h;strings.h;string.h;float.h" STDC_HEADERS)
   645     check_type_size("size_t" SIZEOF_SIZE_T)
   646     check_symbol_exists(M_PI math.h HAVE_M_PI)
   647     # TODO: refine the mprotect check
   648     check_c_source_compiles("#include <sys/types.h>
   649                              #include <sys/mman.h>
   650                              int main() { }" HAVE_MPROTECT)
   651     foreach(_FN
   652             strtod malloc calloc realloc free getenv setenv putenv unsetenv
   653             qsort abs bcopy memset memcpy memmove memcmp strlen strlcpy strlcat
   654             strdup _strrev _strupr _strlwr strchr strrchr strstr itoa _ltoa
   655             _uitoa _ultoa strtol strtoul _i64toa _ui64toa strtoll strtoull
   656             atoi atof strcmp strncmp _stricmp strcasecmp _strnicmp strncasecmp
   657             vsscanf vsnprintf fseeko fseeko64 sigaction setjmp
   658             nanosleep sysconf sysctlbyname getauxval
   659             )
   660       string(TOUPPER ${_FN} _UPPER)
   661       set(_HAVEVAR "HAVE_${_UPPER}")
   662       check_function_exists("${_FN}" ${_HAVEVAR})
   663     endforeach()
   664 
   665     check_library_exists(m pow "" HAVE_LIBM)
   666     if(HAVE_LIBM)
   667       set(CMAKE_REQUIRED_LIBRARIES m)
   668       foreach(_FN
   669               atan atan2 ceil copysign cos cosf fabs floor log pow scalbn sin
   670               sinf sqrt sqrtf tan tanf acos asin)
   671         string(TOUPPER ${_FN} _UPPER)
   672         set(_HAVEVAR "HAVE_${_UPPER}")
   673         check_function_exists("${_FN}" ${_HAVEVAR})
   674       endforeach()
   675       set(CMAKE_REQUIRED_LIBRARIES)
   676       list(APPEND EXTRA_LIBS m)
   677     endif()
   678 
   679     check_library_exists(iconv iconv_open "" HAVE_LIBICONV)
   680     if(HAVE_LIBICONV)
   681       list(APPEND EXTRA_LIBS iconv)
   682       set(HAVE_ICONV 1)
   683     endif()
   684 
   685     if(NOT APPLE)
   686       check_include_file(alloca.h HAVE_ALLOCA_H)
   687       check_function_exists(alloca HAVE_ALLOCA)
   688     else()
   689       set(HAVE_ALLOCA_H 1)
   690       set(HAVE_ALLOCA 1)
   691     endif()
   692 
   693     check_struct_has_member("struct sigaction" "sa_sigaction" "signal.h" HAVE_SA_SIGACTION)
   694   endif()
   695 else()
   696   if(WINDOWS)
   697     set(HAVE_STDARG_H 1)
   698     set(HAVE_STDDEF_H 1)
   699   endif()
   700 endif()
   701 
   702 
   703 # Enable/disable various subsystems of the SDL library
   704 foreach(_SUB ${SDL_SUBSYSTEMS})
   705   string(TOUPPER ${_SUB} _OPT)
   706   if(NOT SDL_${_OPT})
   707     set(SDL_${_OPT}_DISABLED 1)
   708   endif()
   709 endforeach()
   710 if(SDL_JOYSTICK)
   711   file(GLOB JOYSTICK_SOURCES ${SDL2_SOURCE_DIR}/src/joystick/*.c)
   712   set(SOURCE_FILES ${SOURCE_FILES} ${JOYSTICK_SOURCES})
   713 endif()
   714 if(SDL_HAPTIC)
   715   if(NOT SDL_JOYSTICK)
   716     # Haptic requires some private functions from the joystick subsystem.
   717     message_error("SDL_HAPTIC requires SDL_JOYSTICK, which is not enabled")
   718   endif()
   719   file(GLOB HAPTIC_SOURCES ${SDL2_SOURCE_DIR}/src/haptic/*.c)
   720   set(SOURCE_FILES ${SOURCE_FILES} ${HAPTIC_SOURCES})
   721 endif()
   722 if(SDL_POWER)
   723   file(GLOB POWER_SOURCES ${SDL2_SOURCE_DIR}/src/power/*.c)
   724   set(SOURCE_FILES ${SOURCE_FILES} ${POWER_SOURCES})
   725 endif()
   726 # TODO: in configure.in, the test for LOADSO and SDL_DLOPEN is a bit weird:
   727 # if LOADSO is not wanted, SDL_LOADSO_DISABLED is set
   728 # If however on Unix or APPLE dlopen() is detected via CheckDLOPEN(),
   729 # SDL_LOADSO_DISABLED will not be set, regardless of the LOADSO settings
   730 
   731 # General SDL subsystem options, valid for all platforms
   732 if(SDL_AUDIO)
   733   # CheckDummyAudio/CheckDiskAudio - valid for all platforms
   734   if(DUMMYAUDIO)
   735     set(SDL_AUDIO_DRIVER_DUMMY 1)
   736     file(GLOB DUMMYAUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/dummy/*.c)
   737     set(SOURCE_FILES ${SOURCE_FILES} ${DUMMYAUDIO_SOURCES})
   738     set(HAVE_DUMMYAUDIO TRUE)
   739   endif()
   740   if(DISKAUDIO)
   741     set(SDL_AUDIO_DRIVER_DISK 1)
   742     file(GLOB DISKAUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/disk/*.c)
   743     set(SOURCE_FILES ${SOURCE_FILES} ${DISKAUDIO_SOURCES})
   744     set(HAVE_DISKAUDIO TRUE)
   745   endif()
   746 endif()
   747 
   748 if(SDL_DLOPEN)
   749   # Relevant for Unix/Darwin only
   750   if(UNIX OR APPLE)
   751     CheckDLOPEN()
   752   endif()
   753 endif()
   754 
   755 if(SDL_VIDEO)
   756   if(VIDEO_DUMMY)
   757     set(SDL_VIDEO_DRIVER_DUMMY 1)
   758     file(GLOB VIDEO_DUMMY_SOURCES ${SDL2_SOURCE_DIR}/src/video/dummy/*.c)
   759     set(SOURCE_FILES ${SOURCE_FILES} ${VIDEO_DUMMY_SOURCES})
   760     set(HAVE_VIDEO_DUMMY TRUE)
   761     set(HAVE_SDL_VIDEO TRUE)
   762   endif()
   763 endif()
   764 
   765 if(ANDROID)
   766   file(GLOB ANDROID_CORE_SOURCES ${SDL2_SOURCE_DIR}/src/core/android/*.c)
   767   set(SOURCE_FILES ${SOURCE_FILES} ${ANDROID_CORE_SOURCES})
   768 
   769   # SDL_spinlock.c Needs to be compiled in ARM mode.
   770   # There seems to be no better way currently to set the ARM mode.
   771   # see: https://issuetracker.google.com/issues/62264618
   772   # Another option would be to set ARM mode to all compiled files
   773   check_c_compiler_flag(-marm HAVE_ARM_MODE)
   774   if(HAVE_ARM_MODE)
   775     set_source_files_properties(${SDL2_SOURCE_DIR}/src/atomic/SDL_spinlock.c PROPERTIES COMPILE_FLAGS -marm)
   776   endif()
   777 
   778   file(GLOB ANDROID_MAIN_SOURCES ${SDL2_SOURCE_DIR}/src/main/android/*.c)
   779   set(SDLMAIN_SOURCES ${SDLMAIN_SOURCES} ${ANDROID_MAIN_SOURCES})
   780 
   781   if(SDL_AUDIO)
   782     set(SDL_AUDIO_DRIVER_ANDROID 1)
   783     file(GLOB ANDROID_AUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/android/*.c)
   784     set(SOURCE_FILES ${SOURCE_FILES} ${ANDROID_AUDIO_SOURCES})
   785     set(HAVE_SDL_AUDIO TRUE)
   786   endif()
   787   if(SDL_FILESYSTEM)
   788     set(SDL_FILESYSTEM_ANDROID 1)
   789     file(GLOB ANDROID_FILESYSTEM_SOURCES ${SDL2_SOURCE_DIR}/src/filesystem/android/*.c)
   790     set(SOURCE_FILES ${SOURCE_FILES} ${ANDROID_FILESYSTEM_SOURCES})
   791     set(HAVE_SDL_FILESYSTEM TRUE)
   792   endif()
   793   if(SDL_JOYSTICK)
   794     set(SDL_JOYSTICK_ANDROID 1)
   795     file(GLOB ANDROID_JOYSTICK_SOURCES ${SDL2_SOURCE_DIR}/src/joystick/android/*.c)
   796     set(SOURCE_FILES ${SOURCE_FILES} ${ANDROID_JOYSTICK_SOURCES})
   797     set(HAVE_SDL_JOYSTICK TRUE)
   798   endif()
   799   if(SDL_LOADSO)
   800     set(SDL_LOADSO_DLOPEN 1)
   801     file(GLOB LOADSO_SOURCES ${SDL2_SOURCE_DIR}/src/loadso/dlopen/*.c)
   802     set(SOURCE_FILES ${SOURCE_FILES} ${LOADSO_SOURCES})
   803     set(HAVE_SDL_LOADSO TRUE)
   804   endif()
   805   if(SDL_POWER)
   806     set(SDL_POWER_ANDROID 1)
   807     file(GLOB ANDROID_POWER_SOURCES ${SDL2_SOURCE_DIR}/src/power/android/*.c)
   808     set(SOURCE_FILES ${SOURCE_FILES} ${ANDROID_POWER_SOURCES})
   809     set(HAVE_SDL_POWER TRUE)
   810   endif()
   811   if(SDL_TIMERS)
   812     set(SDL_TIMER_UNIX 1)
   813     file(GLOB TIMER_SOURCES ${SDL2_SOURCE_DIR}/src/timer/unix/*.c)
   814     set(SOURCE_FILES ${SOURCE_FILES} ${TIMER_SOURCES})
   815     set(HAVE_SDL_TIMERS TRUE)
   816   endif()
   817   if(SDL_VIDEO)
   818     set(SDL_VIDEO_DRIVER_ANDROID 1)
   819     file(GLOB ANDROID_VIDEO_SOURCES ${SDL2_SOURCE_DIR}/src/video/android/*.c)
   820     set(SOURCE_FILES ${SOURCE_FILES} ${ANDROID_VIDEO_SOURCES})
   821     set(HAVE_SDL_VIDEO TRUE)
   822 
   823     # Core stuff
   824     find_library(ANDROID_DL_LIBRARY dl)
   825     find_library(ANDROID_LOG_LIBRARY log)
   826     find_library(ANDROID_LIBRARY_LIBRARY android)
   827     list(APPEND EXTRA_LIBS ${ANDROID_DL_LIBRARY} ${ANDROID_LOG_LIBRARY} ${ANDROID_LIBRARY_LIBRARY})
   828     add_definitions(-DGL_GLEXT_PROTOTYPES)
   829 
   830     #enable gles
   831     if(VIDEO_OPENGLES)
   832       set(SDL_VIDEO_OPENGL_EGL 1)
   833       set(HAVE_VIDEO_OPENGLES TRUE)
   834       set(SDL_VIDEO_OPENGL_ES2 1)
   835       set(SDL_VIDEO_RENDER_OGL_ES2 1)
   836 
   837       find_library(OpenGLES1_LIBRARY GLESv1_CM)
   838       find_library(OpenGLES2_LIBRARY GLESv2)
   839       list(APPEND EXTRA_LIBS ${OpenGLES1_LIBRARY} ${OpenGLES2_LIBRARY})
   840     endif()
   841   endif()
   842 
   843   CheckPTHREAD()
   844 
   845   list(APPEND EXTRA_LDFLAGS "-Wl,--undefined=Java_org_libsdl_app_SDLActivity_nativeInit")
   846 endif()
   847 
   848 # Platform-specific options and settings
   849 if(EMSCRIPTEN)
   850   # Hide noisy warnings that intend to aid mostly during initial stages of porting a new
   851   # project. Uncomment at will for verbose cross-compiling -I/../ path info.
   852   add_definitions(-Wno-warn-absolute-paths)
   853   if(SDL_AUDIO)
   854     set(SDL_AUDIO_DRIVER_EMSCRIPTEN 1)
   855     file(GLOB EM_AUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/emscripten/*.c)
   856     set(SOURCE_FILES ${SOURCE_FILES} ${EM_AUDIO_SOURCES})
   857     set(HAVE_SDL_AUDIO TRUE)
   858   endif()
   859   if(SDL_FILESYSTEM)
   860     set(SDL_FILESYSTEM_EMSCRIPTEN 1)
   861     file(GLOB EM_FILESYSTEM_SOURCES ${SDL2_SOURCE_DIR}/src/filesystem/emscripten/*.c)
   862     set(SOURCE_FILES ${SOURCE_FILES} ${EM_FILESYSTEM_SOURCES})
   863     set(HAVE_SDL_FILESYSTEM TRUE)
   864   endif()
   865   if(SDL_JOYSTICK)
   866     set(SDL_JOYSTICK_EMSCRIPTEN 1)
   867     file(GLOB EM_JOYSTICK_SOURCES ${SDL2_SOURCE_DIR}/src/joystick/emscripten/*.c)
   868     set(SOURCE_FILES ${SOURCE_FILES} ${EM_JOYSTICK_SOURCES})
   869     set(HAVE_SDL_JOYSTICK TRUE)
   870   endif()
   871   if(SDL_POWER)
   872     set(SDL_POWER_EMSCRIPTEN 1)
   873     file(GLOB EM_POWER_SOURCES ${SDL2_SOURCE_DIR}/src/power/emscripten/*.c)
   874     set(SOURCE_FILES ${SOURCE_FILES} ${EM_POWER_SOURCES})
   875     set(HAVE_SDL_POWER TRUE)
   876   endif()
   877   if(SDL_TIMERS)
   878     set(SDL_TIMER_UNIX 1)
   879     file(GLOB TIMER_SOURCES ${SDL2_SOURCE_DIR}/src/timer/unix/*.c)
   880     set(SOURCE_FILES ${SOURCE_FILES} ${TIMER_SOURCES})
   881     set(HAVE_SDL_TIMERS TRUE)
   882 
   883     if(CLOCK_GETTIME)
   884       set(HAVE_CLOCK_GETTIME 1)
   885     endif()
   886   endif()
   887   if(SDL_VIDEO)
   888     set(SDL_VIDEO_DRIVER_EMSCRIPTEN 1)
   889     file(GLOB EM_VIDEO_SOURCES ${SDL2_SOURCE_DIR}/src/video/emscripten/*.c)
   890     set(SOURCE_FILES ${SOURCE_FILES} ${EM_VIDEO_SOURCES})
   891     set(HAVE_SDL_VIDEO TRUE)
   892 
   893     #enable gles
   894     if(VIDEO_OPENGLES)
   895       set(SDL_VIDEO_OPENGL_EGL 1)
   896       set(HAVE_VIDEO_OPENGLES TRUE)
   897       set(SDL_VIDEO_OPENGL_ES2 1)
   898       set(SDL_VIDEO_RENDER_OGL_ES2 1)
   899     endif()
   900   endif()
   901 elseif(UNIX AND NOT APPLE AND NOT ANDROID)
   902   if(SDL_AUDIO)
   903     if(SYSV5 OR SOLARIS OR HPUX)
   904         set(SDL_AUDIO_DRIVER_SUNAUDIO 1)
   905         file(GLOB SUN_AUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/sun/*.c)
   906         set(SOURCE_FILES ${SOURCE_FILES} ${SUN_AUDIO_SOURCES})
   907         set(HAVE_SDL_AUDIO TRUE)
   908     elseif(NETBSD)
   909         set(SDL_AUDIO_DRIVER_NETBSD 1)
   910         file(GLOB NETBSD_AUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/netbsd/*.c)
   911         set(SOURCE_FILES ${SOURCE_FILES} ${NETBSD_AUDIO_SOURCES})
   912         set(HAVE_SDL_AUDIO TRUE)
   913     elseif(AIX)
   914         set(SDL_AUDIO_DRIVER_PAUDIO 1)
   915         file(GLOB AIX_AUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/paudio/*.c)
   916         set(SOURCE_FILES ${SOURCE_FILES} ${AIX_AUDIO_SOURCES})
   917         set(HAVE_SDL_AUDIO TRUE)
   918     endif()
   919     CheckOSS()
   920     CheckALSA()
   921     CheckJACK()
   922     CheckPulseAudio()
   923     CheckESD()
   924     CheckARTS()
   925     CheckNAS()
   926     CheckSNDIO()
   927     CheckFusionSound()
   928     CheckLibSampleRate()
   929   endif()
   930 
   931   if(SDL_VIDEO)
   932     # Need to check for Raspberry PI first and add platform specific compiler flags, otherwise the test for GLES fails!
   933     CheckRPI()
   934     CheckX11()
   935     CheckMir()
   936     CheckDirectFB()
   937     CheckOpenGLX11()
   938     CheckOpenGLESX11()
   939     CheckWayland()
   940     CheckVivante()
   941     CheckKMSDRM()
   942   endif()
   943 
   944   if(LINUX)
   945     check_c_source_compiles("
   946         #include <linux/input.h>
   947         #ifndef EVIOCGNAME
   948         #error EVIOCGNAME() ioctl not available
   949         #endif
   950         int main(int argc, char** argv) {}" HAVE_INPUT_EVENTS)
   951 
   952     check_c_source_compiles("
   953         #include <linux/kd.h>
   954         #include <linux/keyboard.h>
   955 
   956         int main(int argc, char **argv) 
   957         {
   958             struct kbentry kbe;
   959             kbe.kb_table = KG_CTRL;
   960             ioctl(0, KDGKBENT, &kbe);
   961         }" HAVE_INPUT_KD)
   962 
   963     file(GLOB CORE_SOURCES ${SDL2_SOURCE_DIR}/src/core/linux/*.c)
   964     set(SOURCE_FILES ${SOURCE_FILES} ${CORE_SOURCES})
   965 
   966     if(HAVE_INPUT_EVENTS)
   967       set(SDL_INPUT_LINUXEV 1)
   968     endif()
   969 
   970     if(SDL_HAPTIC AND HAVE_INPUT_EVENTS)
   971       set(SDL_HAPTIC_LINUX 1)
   972       file(GLOB HAPTIC_SOURCES ${SDL2_SOURCE_DIR}/src/haptic/linux/*.c)
   973       set(SOURCE_FILES ${SOURCE_FILES} ${HAPTIC_SOURCES})
   974       set(HAVE_SDL_HAPTIC TRUE)
   975     endif()
   976 
   977     if(HAVE_INPUT_KD)
   978       set(SDL_INPUT_LINUXKD 1)
   979     endif()
   980 
   981     check_include_file("libudev.h" HAVE_LIBUDEV_H)
   982 
   983     if(PKG_CONFIG_FOUND)
   984       pkg_search_module(DBUS dbus-1 dbus)
   985       if(DBUS_FOUND)
   986         set(HAVE_DBUS_DBUS_H TRUE)
   987         include_directories(${DBUS_INCLUDE_DIRS})
   988         list(APPEND EXTRA_LIBS ${DBUS_LIBRARIES})
   989       endif()
   990 
   991       pkg_search_module(IBUS ibus-1.0 ibus)
   992       if(IBUS_FOUND)
   993         set(HAVE_IBUS_IBUS_H TRUE)
   994         include_directories(${IBUS_INCLUDE_DIRS})
   995         list(APPEND EXTRA_LIBS ${IBUS_LIBRARIES})
   996       endif()
   997     endif()
   998 
   999     check_include_file("fcitx/frontend.h" HAVE_FCITX_FRONTEND_H)
  1000 
  1001   endif()
  1002 
  1003   if(INPUT_TSLIB)
  1004     check_c_source_compiles("
  1005         #include \"tslib.h\"
  1006         int main(int argc, char** argv) { }" HAVE_INPUT_TSLIB)
  1007     if(HAVE_INPUT_TSLIB)
  1008       set(SDL_INPUT_TSLIB 1)
  1009       list(APPEND EXTRA_LIBS ts)
  1010     endif()
  1011   endif()
  1012 
  1013   if(SDL_JOYSTICK)
  1014     CheckUSBHID()   # seems to be BSD specific - limit the test to BSD only?
  1015     if(LINUX AND NOT ANDROID)
  1016       set(SDL_JOYSTICK_LINUX 1)
  1017       file(GLOB JOYSTICK_SOURCES ${SDL2_SOURCE_DIR}/src/joystick/linux/*.c)
  1018       set(SOURCE_FILES ${SOURCE_FILES} ${JOYSTICK_SOURCES})
  1019       set(HAVE_SDL_JOYSTICK TRUE)
  1020     endif()
  1021   endif()
  1022 
  1023   CheckPTHREAD()
  1024 
  1025   if(CLOCK_GETTIME)
  1026     check_library_exists(rt clock_gettime "" FOUND_CLOCK_GETTIME)
  1027     if(FOUND_CLOCK_GETTIME)
  1028       list(APPEND EXTRA_LIBS rt)
  1029       set(HAVE_CLOCK_GETTIME 1)
  1030     else()
  1031       check_library_exists(c clock_gettime "" FOUND_CLOCK_GETTIME)
  1032       if(FOUND_CLOCK_GETTIME)
  1033         set(HAVE_CLOCK_GETTIME 1)
  1034       endif()
  1035     endif()
  1036   endif()
  1037 
  1038   check_include_file(linux/version.h HAVE_LINUX_VERSION_H)
  1039   if(HAVE_LINUX_VERSION_H)
  1040     set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DHAVE_LINUX_VERSION_H")
  1041   endif()
  1042 
  1043   if(SDL_POWER)
  1044     if(LINUX)
  1045       set(SDL_POWER_LINUX 1)
  1046       file(GLOB POWER_SOURCES ${SDL2_SOURCE_DIR}/src/power/linux/*.c)
  1047       set(SOURCE_FILES ${SOURCE_FILES} ${POWER_SOURCES})
  1048       set(HAVE_SDL_POWER TRUE)
  1049     endif()
  1050   endif()
  1051 
  1052   if(SDL_FILESYSTEM)
  1053     set(SDL_FILESYSTEM_UNIX 1)
  1054     file(GLOB FILESYSTEM_SOURCES ${SDL2_SOURCE_DIR}/src/filesystem/unix/*.c)
  1055     set(SOURCE_FILES ${SOURCE_FILES} ${FILESYSTEM_SOURCES})
  1056     set(HAVE_SDL_FILESYSTEM TRUE)
  1057   endif()
  1058 
  1059   if(SDL_TIMERS)
  1060     set(SDL_TIMER_UNIX 1)
  1061     file(GLOB TIMER_SOURCES ${SDL2_SOURCE_DIR}/src/timer/unix/*.c)
  1062     set(SOURCE_FILES ${SOURCE_FILES} ${TIMER_SOURCES})
  1063     set(HAVE_SDL_TIMERS TRUE)
  1064   endif()
  1065 
  1066   if(RPATH)
  1067     set(SDL_RLD_FLAGS "")
  1068     if(BSDI OR FREEBSD OR LINUX OR NETBSD)
  1069       set(CMAKE_REQUIRED_FLAGS "-Wl,--enable-new-dtags")
  1070       check_c_compiler_flag("" HAVE_ENABLE_NEW_DTAGS)
  1071       set(CMAKE_REQUIRED_FLAGS ${ORIG_CMAKE_REQUIRED_FLAGS})
  1072       if(HAVE_ENABLE_NEW_DTAGS)
  1073         set(SDL_RLD_FLAGS "-Wl,-rpath,\${libdir} -Wl,--enable-new-dtags")
  1074       else()
  1075         set(SDL_RLD_FLAGS "-Wl,-rpath,\${libdir}")
  1076       endif()
  1077     elseif(SOLARIS)
  1078       set(SDL_RLD_FLAGS "-R\${libdir}")
  1079     endif()
  1080     set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
  1081     set(HAVE_RPATH TRUE)
  1082   endif()
  1083 
  1084 elseif(WINDOWS)
  1085   find_program(WINDRES windres)
  1086 
  1087   check_c_source_compiles("
  1088     #include <windows.h>
  1089     int main(int argc, char **argv) { }" HAVE_WIN32_CC)
  1090 
  1091   file(GLOB CORE_SOURCES ${SDL2_SOURCE_DIR}/src/core/windows/*.c)
  1092   set(SOURCE_FILES ${SOURCE_FILES} ${CORE_SOURCES})
  1093 
  1094   if(MSVC)
  1095     # Prevent codegen that would use the VC runtime libraries.
  1096     add_definitions(/GS-)
  1097     if(NOT ARCH_64)
  1098       add_definitions(/arch:SSE)
  1099     endif()
  1100   endif()
  1101 
  1102   # Check for DirectX
  1103   if(DIRECTX)
  1104     if(DEFINED MSVC_VERSION AND NOT ${MSVC_VERSION} LESS 1700)
  1105         set(USE_WINSDK_DIRECTX TRUE)
  1106     endif()
  1107     if(NOT CMAKE_COMPILER_IS_MINGW AND NOT USE_WINSDK_DIRECTX)
  1108       if("$ENV{DXSDK_DIR}" STREQUAL "")
  1109         message_error("DIRECTX requires the \$DXSDK_DIR environment variable to be set")
  1110       endif()
  1111       set(CMAKE_REQUIRED_FLAGS "/I\"$ENV{DXSDK_DIR}\\Include\"")
  1112     endif()
  1113 
  1114     if(HAVE_WIN32_CC)
  1115       # xinput.h may need windows.h, but doesn't include it itself.
  1116       check_c_source_compiles("
  1117         #include <windows.h>
  1118         #include <xinput.h>
  1119         int main(int argc, char **argv) { }" HAVE_XINPUT_H)
  1120       check_c_source_compiles("
  1121         #include <windows.h>
  1122         #include <xinput.h>
  1123         XINPUT_GAMEPAD_EX x1;
  1124         int main(int argc, char **argv) { }" HAVE_XINPUT_GAMEPAD_EX)
  1125       check_c_source_compiles("
  1126         #include <windows.h>
  1127         #include <xinput.h>
  1128         XINPUT_STATE_EX s1;
  1129         int main(int argc, char **argv) { }" HAVE_XINPUT_STATE_EX)
  1130     else()
  1131       check_include_file(xinput.h HAVE_XINPUT_H)
  1132     endif()
  1133 
  1134     check_include_file(d3d9.h HAVE_D3D_H)
  1135     check_include_file(d3d11_1.h HAVE_D3D11_H)
  1136     check_include_file(ddraw.h HAVE_DDRAW_H)
  1137     check_include_file(dsound.h HAVE_DSOUND_H)
  1138     check_include_file(dinput.h HAVE_DINPUT_H)
  1139     check_include_file(xaudio2.h HAVE_XAUDIO2_H)
  1140     check_include_file(audioclient.h HAVE_AUDIOCLIENT_H)
  1141     check_include_file(dxgi.h HAVE_DXGI_H)
  1142     if(HAVE_D3D_H OR HAVE_D3D11_H OR HAVE_DDRAW_H OR HAVE_DSOUND_H OR HAVE_DINPUT_H OR HAVE_XAUDIO2_H)
  1143       set(HAVE_DIRECTX TRUE)
  1144       if(NOT CMAKE_COMPILER_IS_MINGW AND NOT USE_WINSDK_DIRECTX)
  1145       # TODO: change $ENV{DXSDL_DIR} to get the path from the include checks
  1146         link_directories($ENV{DXSDK_DIR}\\lib\\${PROCESSOR_ARCH})
  1147         include_directories($ENV{DXSDK_DIR}\\Include)
  1148       endif()
  1149     endif()
  1150     set(CMAKE_REQUIRED_FLAGS ${ORIG_CMAKE_REQUIRED_FLAGS})
  1151   endif()
  1152 
  1153   if(SDL_AUDIO)
  1154     set(SDL_AUDIO_DRIVER_WINMM 1)
  1155     file(GLOB WINMM_AUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/winmm/*.c)
  1156     set(SOURCE_FILES ${SOURCE_FILES} ${WINMM_AUDIO_SOURCES})
  1157     set(HAVE_SDL_AUDIO TRUE)
  1158 
  1159     if(HAVE_DSOUND_H)
  1160       set(SDL_AUDIO_DRIVER_DSOUND 1)
  1161       file(GLOB DSOUND_AUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/directsound/*.c)
  1162       set(SOURCE_FILES ${SOURCE_FILES} ${DSOUND_AUDIO_SOURCES})
  1163     endif()
  1164 
  1165     if(HAVE_XAUDIO2_H)
  1166       set(SDL_AUDIO_DRIVER_XAUDIO2 1)
  1167       file(GLOB XAUDIO2_AUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/xaudio2/*.c)
  1168       set(SOURCE_FILES ${SOURCE_FILES} ${XAUDIO2_AUDIO_SOURCES})
  1169     endif()
  1170 
  1171     if(HAVE_AUDIOCLIENT_H)
  1172       set(SDL_AUDIO_DRIVER_WASAPI 1)
  1173       file(GLOB WASAPI_AUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/wasapi/*.c)
  1174       set(SOURCE_FILES ${SOURCE_FILES} ${WASAPI_AUDIO_SOURCES})
  1175     endif()
  1176   endif()
  1177 
  1178   if(SDL_VIDEO)
  1179     # requires SDL_LOADSO on Windows (IME, DX, etc.)
  1180     if(NOT SDL_LOADSO)
  1181       message_error("SDL_VIDEO requires SDL_LOADSO, which is not enabled")
  1182     endif()
  1183     set(SDL_VIDEO_DRIVER_WINDOWS 1)
  1184     file(GLOB WIN_VIDEO_SOURCES ${SDL2_SOURCE_DIR}/src/video/windows/*.c)
  1185     set(SOURCE_FILES ${SOURCE_FILES} ${WIN_VIDEO_SOURCES})
  1186 
  1187     if(RENDER_D3D AND HAVE_D3D_H)
  1188       set(SDL_VIDEO_RENDER_D3D 1)
  1189       set(HAVE_RENDER_D3D TRUE)
  1190     endif()
  1191     if(RENDER_D3D AND HAVE_D3D11_H)
  1192       set(SDL_VIDEO_RENDER_D3D11 1)
  1193       set(HAVE_RENDER_D3D TRUE)
  1194     endif()
  1195     set(HAVE_SDL_VIDEO TRUE)
  1196   endif()
  1197 
  1198   if(SDL_THREADS)
  1199     set(SDL_THREAD_WINDOWS 1)
  1200     set(SOURCE_FILES ${SOURCE_FILES}
  1201       ${SDL2_SOURCE_DIR}/src/thread/windows/SDL_sysmutex.c
  1202       ${SDL2_SOURCE_DIR}/src/thread/windows/SDL_syssem.c
  1203       ${SDL2_SOURCE_DIR}/src/thread/windows/SDL_systhread.c
  1204       ${SDL2_SOURCE_DIR}/src/thread/windows/SDL_systls.c
  1205       ${SDL2_SOURCE_DIR}/src/thread/generic/SDL_syscond.c)
  1206     set(HAVE_SDL_THREADS TRUE)
  1207   endif()
  1208 
  1209   if(SDL_POWER)
  1210     set(SDL_POWER_WINDOWS 1)
  1211     set(SOURCE_FILES ${SOURCE_FILES} ${SDL2_SOURCE_DIR}/src/power/windows/SDL_syspower.c)
  1212     set(HAVE_SDL_POWER TRUE)
  1213   endif()
  1214 
  1215   if(SDL_FILESYSTEM)
  1216     set(SDL_FILESYSTEM_WINDOWS 1)
  1217     file(GLOB FILESYSTEM_SOURCES ${SDL2_SOURCE_DIR}/src/filesystem/windows/*.c)
  1218     set(SOURCE_FILES ${SOURCE_FILES} ${FILESYSTEM_SOURCES})
  1219     set(HAVE_SDL_FILESYSTEM TRUE)
  1220   endif()
  1221 
  1222   # Libraries for Win32 native and MinGW
  1223   list(APPEND EXTRA_LIBS user32 gdi32 winmm imm32 ole32 oleaut32 version uuid)
  1224 
  1225   # TODO: in configure.in the check for timers is set on
  1226   # cygwin | mingw32* - does this include mingw32CE?
  1227   if(SDL_TIMERS)
  1228     set(SDL_TIMER_WINDOWS 1)
  1229     file(GLOB TIMER_SOURCES ${SDL2_SOURCE_DIR}/src/timer/windows/*.c)
  1230     set(SOURCE_FILES ${SOURCE_FILES} ${TIMER_SOURCES})
  1231     set(HAVE_SDL_TIMERS TRUE)
  1232   endif()
  1233 
  1234   if(SDL_LOADSO)
  1235     set(SDL_LOADSO_WINDOWS 1)
  1236     file(GLOB LOADSO_SOURCES ${SDL2_SOURCE_DIR}/src/loadso/windows/*.c)
  1237     set(SOURCE_FILES ${SOURCE_FILES} ${LOADSO_SOURCES})
  1238     set(HAVE_SDL_LOADSO TRUE)
  1239   endif()
  1240 
  1241   file(GLOB CORE_SOURCES ${SDL2_SOURCE_DIR}/src/core/windows/*.c)
  1242   set(SOURCE_FILES ${SOURCE_FILES} ${CORE_SOURCES})
  1243 
  1244   if(SDL_VIDEO)
  1245     if(VIDEO_OPENGL)
  1246       set(SDL_VIDEO_OPENGL 1)
  1247       set(SDL_VIDEO_OPENGL_WGL 1)
  1248       set(SDL_VIDEO_RENDER_OGL 1)
  1249       set(HAVE_VIDEO_OPENGL TRUE)
  1250     endif()
  1251 
  1252     if(VIDEO_OPENGLES)
  1253       set(SDL_VIDEO_OPENGL_EGL 1)
  1254       set(SDL_VIDEO_OPENGL_ES2 1)
  1255       set(SDL_VIDEO_RENDER_OGL_ES2 1)
  1256       set(HAVE_VIDEO_OPENGLES TRUE)
  1257     endif()
  1258   endif()
  1259 
  1260   if(SDL_JOYSTICK)
  1261     file(GLOB JOYSTICK_SOURCES ${SDL2_SOURCE_DIR}/src/joystick/windows/*.c)
  1262     set(SOURCE_FILES ${SOURCE_FILES} ${JOYSTICK_SOURCES})
  1263     if(HAVE_DINPUT_H)
  1264       set(SDL_JOYSTICK_DINPUT 1)
  1265       list(APPEND EXTRA_LIBS dinput8)
  1266       if(CMAKE_COMPILER_IS_MINGW)
  1267         list(APPEND EXTRA_LIBS dxerr8)
  1268       elseif (NOT USE_WINSDK_DIRECTX)
  1269         list(APPEND EXTRA_LIBS dxerr)
  1270       endif()
  1271     endif()
  1272     if(HAVE_XINPUT_H)
  1273       set(SDL_JOYSTICK_XINPUT 1)
  1274     endif()
  1275     if(NOT HAVE_DINPUT_H AND NOT HAVE_XINPUT_H)
  1276       set(SDL_JOYSTICK_WINMM 1)
  1277     endif()
  1278     set(HAVE_SDL_JOYSTICK TRUE)
  1279 
  1280     if(SDL_HAPTIC)
  1281       if(HAVE_DINPUT_H OR HAVE_XINPUT_H)
  1282         file(GLOB HAPTIC_SOURCES ${SDL2_SOURCE_DIR}/src/haptic/windows/*.c)
  1283         if(HAVE_DINPUT_H)
  1284           set(SDL_HAPTIC_DINPUT 1)
  1285         endif()
  1286         if(HAVE_XINPUT_H)
  1287           set(SDL_HAPTIC_XINPUT 1)
  1288         endif()
  1289       else()
  1290         file(GLOB HAPTIC_SOURCES ${SDL2_SOURCE_DIR}/src/haptic/dummy/*.c)
  1291         set(SDL_HAPTIC_DUMMY 1)
  1292       endif()
  1293       set(SOURCE_FILES ${SOURCE_FILES} ${HAPTIC_SOURCES})
  1294       set(HAVE_SDL_HAPTIC TRUE)
  1295     endif()
  1296   endif()
  1297 
  1298   file(GLOB VERSION_SOURCES ${SDL2_SOURCE_DIR}/src/main/windows/*.rc)
  1299   file(GLOB SDLMAIN_SOURCES ${SDL2_SOURCE_DIR}/src/main/windows/*.c)
  1300   if(MINGW OR CYGWIN)
  1301     list(APPEND EXTRA_LIBS mingw32)
  1302     list(APPEND EXTRA_LDFLAGS "-mwindows")
  1303     set(SDL_CFLAGS "${SDL_CFLAGS} -Dmain=SDL_main")
  1304     list(APPEND SDL_LIBS "-lmingw32" "-lSDL2main" "-mwindows")
  1305   endif()
  1306 elseif(APPLE)
  1307   # TODO: rework this for proper MacOS X, iOS and Darwin support
  1308 
  1309   # Requires the darwin file implementation
  1310   if(SDL_FILE)
  1311     file(GLOB EXTRA_SOURCES ${SDL2_SOURCE_DIR}/src/file/cocoa/*.m)
  1312     set(SOURCE_FILES ${EXTRA_SOURCES} ${SOURCE_FILES})
  1313     set_source_files_properties(${EXTRA_SOURCES} PROPERTIES LANGUAGE C)
  1314     set(HAVE_SDL_FILE TRUE)
  1315     set(SDL_FRAMEWORK_COCOA 1)
  1316     set(SDL_FRAMEWORK_COREVIDEO 1)
  1317   else()
  1318     message_error("SDL_FILE must be enabled to build on MacOS X")
  1319   endif()
  1320 
  1321   if(SDL_AUDIO)
  1322     set(SDL_AUDIO_DRIVER_COREAUDIO 1)
  1323     file(GLOB AUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/coreaudio/*.m)
  1324     set(SOURCE_FILES ${SOURCE_FILES} ${AUDIO_SOURCES})
  1325     set(HAVE_SDL_AUDIO TRUE)
  1326     set(SDL_FRAMEWORK_COREAUDIO 1)
  1327     set(SDL_FRAMEWORK_AUDIOTOOLBOX 1)
  1328   endif()
  1329 
  1330   if(SDL_JOYSTICK)
  1331     set(SDL_JOYSTICK_IOKIT 1)
  1332     if (IOS)
  1333       file(GLOB JOYSTICK_SOURCES ${SDL2_SOURCE_DIR}/src/joystick/iphoneos/*.m)
  1334     else()
  1335       file(GLOB JOYSTICK_SOURCES ${SDL2_SOURCE_DIR}/src/joystick/darwin/*.c)
  1336     endif()
  1337     set(SOURCE_FILES ${SOURCE_FILES} ${JOYSTICK_SOURCES})
  1338     set(HAVE_SDL_JOYSTICK TRUE)
  1339     set(SDL_FRAMEWORK_IOKIT 1)
  1340     set(SDL_FRAMEWORK_FF 1)
  1341   endif()
  1342 
  1343   if(SDL_HAPTIC)
  1344     set(SDL_HAPTIC_IOKIT 1)
  1345     if (IOS)
  1346       file(GLOB HAPTIC_SOURCES ${SDL2_SOURCE_DIR}/src/haptic/dummy/*.c)
  1347       set(SDL_HAPTIC_DUMMY 1)
  1348     else()
  1349       file(GLOB HAPTIC_SOURCES ${SDL2_SOURCE_DIR}/src/haptic/darwin/*.c)
  1350     endif()
  1351     set(SOURCE_FILES ${SOURCE_FILES} ${HAPTIC_SOURCES})
  1352     set(HAVE_SDL_HAPTIC TRUE)
  1353     set(SDL_FRAMEWORK_IOKIT 1)
  1354     set(SDL_FRAMEWORK_FF 1)
  1355     if(NOT SDL_JOYSTICK)
  1356       message(FATAL_ERROR "SDL_HAPTIC requires SDL_JOYSTICK to be enabled")
  1357     endif()
  1358   endif()
  1359 
  1360   if(SDL_POWER)
  1361     set(SDL_POWER_MACOSX 1)
  1362     if (IOS)
  1363       file(GLOB POWER_SOURCES ${SDL2_SOURCE_DIR}/src/power/uikit/*.m)
  1364     else()
  1365       file(GLOB POWER_SOURCES ${SDL2_SOURCE_DIR}/src/power/macosx/*.c)
  1366     endif()
  1367     set(SOURCE_FILES ${SOURCE_FILES} ${POWER_SOURCES})
  1368     set(HAVE_SDL_POWER TRUE)
  1369     set(SDL_FRAMEWORK_CARBON 1)
  1370     set(SDL_FRAMEWORK_IOKIT 1)
  1371   endif()
  1372 
  1373   if(SDL_TIMERS)
  1374     set(SDL_TIMER_UNIX 1)
  1375     file(GLOB TIMER_SOURCES ${SDL2_SOURCE_DIR}/src/timer/unix/*.c)
  1376     set(SOURCE_FILES ${SOURCE_FILES} ${TIMER_SOURCES})
  1377     set(HAVE_SDL_TIMERS TRUE)
  1378   endif(SDL_TIMERS)
  1379 
  1380   if(SDL_FILESYSTEM)
  1381     set(SDL_FILESYSTEM_COCOA 1)
  1382     file(GLOB FILESYSTEM_SOURCES ${SDL2_SOURCE_DIR}/src/filesystem/cocoa/*.m)
  1383     set_source_files_properties(${FILESYSTEM_SOURCES} PROPERTIES LANGUAGE C)
  1384     set(SOURCE_FILES ${SOURCE_FILES} ${FILESYSTEM_SOURCES})
  1385     set(HAVE_SDL_FILESYSTEM TRUE)
  1386   endif()
  1387 
  1388   # Actually load the frameworks at the end so we don't duplicate include.
  1389   if(SDL_FRAMEWORK_COREVIDEO)
  1390     find_library(COREVIDEO CoreVideo)
  1391     list(APPEND EXTRA_LIBS ${COREVIDEO})
  1392   endif()
  1393   if(SDL_FRAMEWORK_COCOA)
  1394     find_library(COCOA_LIBRARY Cocoa)
  1395     list(APPEND EXTRA_LIBS ${COCOA_LIBRARY})
  1396   endif()
  1397   if(SDL_FRAMEWORK_IOKIT)
  1398     find_library(IOKIT IOKit)
  1399     list(APPEND EXTRA_LIBS ${IOKIT})
  1400   endif()
  1401   if(SDL_FRAMEWORK_FF)
  1402     find_library(FORCEFEEDBACK ForceFeedback)
  1403     list(APPEND EXTRA_LIBS ${FORCEFEEDBACK})
  1404   endif()
  1405   if(SDL_FRAMEWORK_CARBON)
  1406     find_library(CARBON_LIBRARY Carbon)
  1407     list(APPEND EXTRA_LIBS ${CARBON_LIBRARY})
  1408   endif()
  1409   if(SDL_FRAMEWORK_COREAUDIO)
  1410     find_library(COREAUDIO CoreAudio)
  1411     list(APPEND EXTRA_LIBS ${COREAUDIO})
  1412   endif()
  1413   if(SDL_FRAMEWORK_AUDIOTOOLBOX)
  1414     find_library(AUDIOTOOLBOX AudioToolbox)
  1415     list(APPEND EXTRA_LIBS ${AUDIOTOOLBOX})
  1416   endif()
  1417 
  1418   # iOS hack needed - http://code.google.com/p/ios-cmake/ ?
  1419   if(SDL_VIDEO)
  1420     if (IOS)
  1421       set(SDL_VIDEO_DRIVER_UIKIT 1)
  1422       file(GLOB UIKITVIDEO_SOURCES ${SDL2_SOURCE_DIR}/src/video/uikit/*.m)
  1423       set(SOURCE_FILES ${SOURCE_FILES} ${UIKITVIDEO_SOURCES})
  1424     else()
  1425       CheckCOCOA()
  1426       if(VIDEO_OPENGL)
  1427         set(SDL_VIDEO_OPENGL 1)
  1428         set(SDL_VIDEO_OPENGL_CGL 1)
  1429         set(SDL_VIDEO_RENDER_OGL 1)
  1430         set(HAVE_VIDEO_OPENGL TRUE)
  1431       endif()
  1432     endif()
  1433   endif()
  1434 
  1435   CheckPTHREAD()
  1436 elseif(HAIKU)
  1437   if(SDL_VIDEO)
  1438     set(SDL_VIDEO_DRIVER_HAIKU 1)
  1439     file(GLOB HAIKUVIDEO_SOURCES ${SDL2_SOURCE_DIR}/src/video/haiku/*.c)
  1440     set(SOURCE_FILES ${SOURCE_FILES} ${HAIKUVIDEO_SOURCES})
  1441     set(HAVE_SDL_VIDEO TRUE)
  1442 
  1443     set(SDL_FILESYSTEM_HAIKU 1)
  1444     file(GLOB FILESYSTEM_SOURCES ${SDL2_SOURCE_DIR}/src/filesystem/haiku/*.cc)
  1445     set(SOURCE_FILES ${SOURCE_FILES} ${FILESYSTEM_SOURCES})
  1446     set(HAVE_SDL_FILESYSTEM TRUE)
  1447 
  1448     if(SDL_TIMERS)
  1449       set(SDL_TIMER_HAIKU 1)
  1450       file(GLOB TIMER_SOURCES ${SDL2_SOURCE_DIR}/src/timer/haiku/*.c)
  1451       set(SOURCE_FILES ${SOURCE_FILES} ${TIMER_SOURCES})
  1452       set(HAVE_SDL_TIMERS TRUE)
  1453     endif(SDL_TIMERS)
  1454 
  1455     if(VIDEO_OPENGL)
  1456       # TODO: Use FIND_PACKAGE(OpenGL) instead
  1457       set(SDL_VIDEO_OPENGL 1)
  1458       set(SDL_VIDEO_OPENGL_BGL 1)
  1459       set(SDL_VIDEO_RENDER_OGL 1)
  1460       list(APPEND EXTRA_LIBS GL)
  1461       set(HAVE_VIDEO_OPENGL TRUE)
  1462     endif()
  1463   endif()
  1464 
  1465   CheckPTHREAD()
  1466 endif()
  1467 
  1468 # Dummies
  1469 # configure.in does it differently:
  1470 # if not have X
  1471 #   if enable_X {  SDL_X_DISABLED = 1 }
  1472 #   [add dummy sources]
  1473 # so it always adds a dummy, without checking, if it was actually requested.
  1474 # This leads to missing internal references on building, since the
  1475 # src/X/*.c does not get included.
  1476 if(NOT HAVE_SDL_JOYSTICK)
  1477   set(SDL_JOYSTICK_DISABLED 1)
  1478   if(SDL_JOYSTICK AND NOT APPLE) # results in unresolved symbols on OSX
  1479 
  1480     file(GLOB JOYSTICK_SOURCES ${SDL2_SOURCE_DIR}/src/joystick/dummy/*.c)
  1481     set(SOURCE_FILES ${SOURCE_FILES} ${JOYSTICK_SOURCES})
  1482   endif()
  1483 endif()
  1484 if(NOT HAVE_SDL_HAPTIC)
  1485   set(SDL_HAPTIC_DISABLED 1)
  1486   file(GLOB HAPTIC_SOURCES ${SDL2_SOURCE_DIR}/src/haptic/dummy/*.c)
  1487   set(SOURCE_FILES ${SOURCE_FILES} ${HAPTIC_SOURCES})
  1488 endif()
  1489 if(NOT HAVE_SDL_LOADSO)
  1490   set(SDL_LOADSO_DISABLED 1)
  1491   file(GLOB LOADSO_SOURCES ${SDL2_SOURCE_DIR}/src/loadso/dummy/*.c)
  1492   set(SOURCE_FILES ${SOURCE_FILES} ${LOADSO_SOURCES})
  1493 endif()
  1494 if(NOT HAVE_SDL_FILESYSTEM)
  1495   set(SDL_FILESYSTEM_DISABLED 1)
  1496   file(GLOB FILESYSTEM_SOURCES ${SDL2_SOURCE_DIR}/src/filesystem/dummy/*.c)
  1497   set(SOURCE_FILES ${SOURCE_FILES} ${FILESYSTEM_SOURCES})
  1498 endif()
  1499 
  1500 # We always need to have threads and timers around
  1501 if(NOT HAVE_SDL_THREADS)
  1502   set(SDL_THREADS_DISABLED 1)
  1503   file(GLOB THREADS_SOURCES ${SDL2_SOURCE_DIR}/src/thread/generic/*.c)
  1504   set(SOURCE_FILES ${SOURCE_FILES} ${THREADS_SOURCES})
  1505 endif()
  1506 if(NOT HAVE_SDL_TIMERS)
  1507   set(SDL_TIMERS_DISABLED 1)
  1508   file(GLOB TIMER_SOURCES ${SDL2_SOURCE_DIR}/src/timer/dummy/*.c)
  1509   set(SOURCE_FILES ${SOURCE_FILES} ${TIMER_SOURCES})
  1510 endif()
  1511 
  1512 if(NOT SDLMAIN_SOURCES)
  1513   file(GLOB SDLMAIN_SOURCES ${SDL2_SOURCE_DIR}/src/main/dummy/*.c)
  1514 endif()
  1515 
  1516 # Append the -MMD -MT flags
  1517 # if(DEPENDENCY_TRACKING)
  1518 #   if(COMPILER_IS_GNUCC)
  1519 #     set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -MMD -MT \$@")
  1520 #   endif()
  1521 # endif()
  1522 
  1523 configure_file("${SDL2_SOURCE_DIR}/include/SDL_config.h.cmake"
  1524   "${SDL2_BINARY_DIR}/include/SDL_config.h")
  1525 
  1526 # Prepare the flags and remove duplicates
  1527 if(EXTRA_LDFLAGS)
  1528   list(REMOVE_DUPLICATES EXTRA_LDFLAGS)
  1529 endif()
  1530 if(EXTRA_LIBS)
  1531   list(REMOVE_DUPLICATES EXTRA_LIBS)
  1532 endif()
  1533 if(EXTRA_CFLAGS)
  1534   list(REMOVE_DUPLICATES EXTRA_CFLAGS)
  1535 endif()
  1536 listtostr(EXTRA_CFLAGS _EXTRA_CFLAGS)
  1537 set(EXTRA_CFLAGS ${_EXTRA_CFLAGS})
  1538 
  1539 # Compat helpers for the configuration files
  1540 if(NOT WINDOWS OR CYGWIN)
  1541   # TODO: we need a Windows script, too
  1542   execute_process(COMMAND sh ${SDL2_SOURCE_DIR}/build-scripts/updaterev.sh)
  1543 
  1544   set(prefix ${CMAKE_INSTALL_PREFIX})
  1545   set(exec_prefix "\${prefix}")
  1546   set(libdir "\${exec_prefix}/lib${LIB_SUFFIX}")
  1547   set(bindir "\${exec_prefix}/bin")
  1548   set(includedir "\${prefix}/include")
  1549   if(SDL_STATIC)
  1550     set(ENABLE_STATIC_TRUE "")
  1551     set(ENABLE_STATIC_FALSE "#")
  1552   else()
  1553     set(ENABLE_STATIC_TRUE "#")
  1554     set(ENABLE_STATIC_FALSE "")
  1555   endif()
  1556   if(SDL_SHARED)
  1557     set(ENABLE_SHARED_TRUE "")
  1558     set(ENABLE_SHARED_FALSE "#")
  1559   else()
  1560     set(ENABLE_SHARED_TRUE "#")
  1561     set(ENABLE_SHARED_FALSE "")
  1562   endif()
  1563 
  1564   # Clean up the different lists
  1565   listtostr(EXTRA_LIBS _EXTRA_LIBS "-l")
  1566   set(SDL_STATIC_LIBS ${SDL_LIBS} ${EXTRA_LDFLAGS} ${_EXTRA_LIBS})
  1567   list(REMOVE_DUPLICATES SDL_STATIC_LIBS)
  1568   listtostr(SDL_STATIC_LIBS _SDL_STATIC_LIBS)
  1569   set(SDL_STATIC_LIBS ${_SDL_STATIC_LIBS})
  1570   listtostr(SDL_LIBS _SDL_LIBS)
  1571   set(SDL_LIBS ${_SDL_LIBS})
  1572 
  1573   # MESSAGE(STATUS "SDL_LIBS: ${SDL_LIBS}")
  1574   # MESSAGE(STATUS "SDL_STATIC_LIBS: ${SDL_STATIC_LIBS}")
  1575 
  1576   configure_file("${SDL2_SOURCE_DIR}/sdl2.pc.in"
  1577     "${SDL2_BINARY_DIR}/sdl2.pc" @ONLY)
  1578   configure_file("${SDL2_SOURCE_DIR}/sdl2-config.in"
  1579     "${SDL2_BINARY_DIR}/sdl2-config")
  1580   configure_file("${SDL2_SOURCE_DIR}/sdl2-config.in"
  1581     "${SDL2_BINARY_DIR}/sdl2-config" @ONLY)
  1582   configure_file("${SDL2_SOURCE_DIR}/SDL2.spec.in"
  1583     "${SDL2_BINARY_DIR}/SDL2.spec" @ONLY)
  1584 endif()
  1585 
  1586 ##### Info output #####
  1587 message(STATUS "")
  1588 message(STATUS "SDL2 was configured with the following options:")
  1589 message(STATUS "")
  1590 message(STATUS "Platform: ${CMAKE_SYSTEM}")
  1591 message(STATUS "64-bit:   ${ARCH_64}")
  1592 message(STATUS "Compiler: ${CMAKE_C_COMPILER}")
  1593 message(STATUS "")
  1594 message(STATUS "Subsystems:")
  1595 foreach(_SUB ${SDL_SUBSYSTEMS})
  1596   string(TOUPPER ${_SUB} _OPT)
  1597   message_bool_option(${_SUB} SDL_${_OPT})
  1598 endforeach()
  1599 message(STATUS "")
  1600 message(STATUS "Options:")
  1601 list(SORT ALLOPTIONS)
  1602 foreach(_OPT ${ALLOPTIONS})
  1603   # Longest option is VIDEO_X11_XSCREENSAVER = 22 characters
  1604   # Get the padding
  1605   string(LENGTH ${_OPT} _OPTLEN)
  1606   math(EXPR _PADLEN "23 - ${_OPTLEN}")
  1607   string(RANDOM LENGTH ${_PADLEN} ALPHABET " " _PADDING)
  1608   message_tested_option(${_OPT} ${_PADDING})
  1609 endforeach()
  1610 message(STATUS "")
  1611 message(STATUS " CFLAGS:        ${CMAKE_C_FLAGS}")
  1612 message(STATUS " EXTRA_CFLAGS:  ${EXTRA_CFLAGS}")
  1613 message(STATUS " EXTRA_LDFLAGS: ${EXTRA_LDFLAGS}")
  1614 message(STATUS " EXTRA_LIBS:    ${EXTRA_LIBS}")
  1615 message(STATUS "")
  1616 message(STATUS " Build Shared Library: ${SDL_SHARED}")
  1617 message(STATUS " Build Static Library: ${SDL_STATIC}")
  1618 if(SDL_STATIC)
  1619     message(STATUS " Build Static Library with Position Independent Code: ${SDL_STATIC_PIC}")
  1620 endif()
  1621 message(STATUS "")
  1622 if(UNIX)
  1623   message(STATUS "If something was not detected, although the libraries")
  1624   message(STATUS "were installed, then make sure you have set the")
  1625   message(STATUS "CFLAGS and LDFLAGS environment variables correctly.")
  1626   message(STATUS "")
  1627 endif()
  1628 
  1629 # Ensure that the extra cflags are used at compile time
  1630 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
  1631 
  1632 # Always build SDLmain
  1633 add_library(SDL2main STATIC ${SDLMAIN_SOURCES})
  1634 set(_INSTALL_LIBS "SDL2main")
  1635 
  1636 if(SDL_SHARED)
  1637   add_library(SDL2 SHARED ${SOURCE_FILES} ${VERSION_SOURCES})
  1638   if(UNIX AND NOT ANDROID)
  1639     set_target_properties(SDL2 PROPERTIES
  1640       VERSION ${LT_VERSION}
  1641       SOVERSION ${LT_REVISION}
  1642       OUTPUT_NAME "SDL2-${LT_RELEASE}")
  1643   else()
  1644     set_target_properties(SDL2 PROPERTIES
  1645       VERSION ${SDL_VERSION}
  1646       SOVERSION ${LT_REVISION}
  1647       OUTPUT_NAME "SDL2")
  1648   endif()
  1649   if(MSVC AND NOT LIBC)
  1650     # Don't try to link with the default set of libraries.
  1651     set_target_properties(SDL2 PROPERTIES LINK_FLAGS_RELEASE "/NODEFAULTLIB")
  1652     set_target_properties(SDL2 PROPERTIES LINK_FLAGS_DEBUG "/NODEFAULTLIB")
  1653     set_target_properties(SDL2 PROPERTIES STATIC_LIBRARY_FLAGS "/NODEFAULTLIB")
  1654   endif()
  1655   set(_INSTALL_LIBS "SDL2" ${_INSTALL_LIBS})
  1656   target_link_libraries(SDL2 ${EXTRA_LIBS} ${EXTRA_LDFLAGS})
  1657 endif()
  1658 
  1659 if(SDL_STATIC)
  1660   set (BUILD_SHARED_LIBS FALSE)
  1661   add_library(SDL2-static STATIC ${SOURCE_FILES})
  1662   set_target_properties(SDL2-static PROPERTIES OUTPUT_NAME "SDL2")
  1663   set_target_properties(SDL2-static PROPERTIES POSITION_INDEPENDENT_CODE ${SDL_STATIC_PIC})
  1664   if(MSVC AND NOT LIBC)
  1665     set_target_properties(SDL2-static PROPERTIES LINK_FLAGS_RELEASE "/NODEFAULTLIB")
  1666     set_target_properties(SDL2-static PROPERTIES LINK_FLAGS_DEBUG "/NODEFAULTLIB")
  1667     set_target_properties(SDL2-static PROPERTIES STATIC_LIBRARY_FLAGS "/NODEFAULTLIB")
  1668   endif()
  1669   # TODO: Win32 platforms keep the same suffix .lib for import and static
  1670   # libraries - do we need to consider this?
  1671   set(_INSTALL_LIBS "SDL2-static" ${_INSTALL_LIBS})
  1672   target_link_libraries(SDL2-static ${EXTRA_LIBS} ${EXTRA_LDFLAGS})
  1673 endif()
  1674 
  1675 ##### Installation targets #####
  1676 install(TARGETS ${_INSTALL_LIBS}
  1677   LIBRARY DESTINATION "lib${LIB_SUFFIX}"
  1678   ARCHIVE DESTINATION "lib${LIB_SUFFIX}"
  1679   RUNTIME DESTINATION bin)
  1680 
  1681 file(GLOB INCLUDE_FILES ${SDL2_SOURCE_DIR}/include/*.h)
  1682 file(GLOB BIN_INCLUDE_FILES ${SDL2_BINARY_DIR}/include/*.h)
  1683 foreach(_FNAME ${BIN_INCLUDE_FILES})
  1684   get_filename_component(_INCNAME ${_FNAME} NAME)
  1685   list(REMOVE_ITEM INCLUDE_FILES ${SDL2_SOURCE_DIR}/include/${_INCNAME})
  1686 endforeach()
  1687 list(APPEND INCLUDE_FILES ${BIN_INCLUDE_FILES})
  1688 install(FILES ${INCLUDE_FILES} DESTINATION include/SDL2)
  1689 
  1690 if(NOT (WINDOWS OR CYGWIN))
  1691   if(SDL_SHARED)
  1692     if (APPLE)
  1693         set(SOEXT "dylib")
  1694     else()
  1695         set(SOEXT "so")
  1696     endif()
  1697     install(CODE "
  1698       execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink
  1699       \"libSDL2-2.0.${SOEXT}\" \"libSDL2.${SOEXT}\")")
  1700     install(FILES ${SDL2_BINARY_DIR}/libSDL2.${SOEXT} DESTINATION "lib${LIB_SUFFIX}")
  1701   endif()
  1702   if(FREEBSD)
  1703     # FreeBSD uses ${PREFIX}/libdata/pkgconfig
  1704     install(FILES ${SDL2_BINARY_DIR}/sdl2.pc DESTINATION "libdata/pkgconfig")
  1705   else()
  1706     install(FILES ${SDL2_BINARY_DIR}/sdl2.pc
  1707       DESTINATION "lib${LIB_SUFFIX}/pkgconfig")
  1708   endif()
  1709   install(PROGRAMS ${SDL2_BINARY_DIR}/sdl2-config DESTINATION bin)
  1710   # TODO: what about the .spec file? Is it only needed for RPM creation?
  1711   install(FILES "${SDL2_SOURCE_DIR}/sdl2.m4" DESTINATION "${CMAKE_INSTALL_FULL_DATAROOTDIR}/aclocal")
  1712 endif()
  1713 
  1714 ##### Uninstall target #####
  1715 
  1716 configure_file(
  1717     "${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
  1718     "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
  1719     IMMEDIATE @ONLY)
  1720 
  1721 add_custom_target(uninstall
  1722     COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)