CMakeLists.txt
author Sam Lantinga <slouken@libsdl.org>
Sun, 17 Aug 2014 13:15:45 -0700
changeset 9082 22232029f074
parent 9081 39eb61ccbc82
child 9083 029f8d643dbe
permissions -rw-r--r--
cmake: add -Wl,--no-undefined to GCC linker flags

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