CMakeLists.txt
author Sam Lantinga <slouken@libsdl.org>
Tue, 19 Aug 2014 22:04:54 -0700
changeset 9099 5bbfdfa38bfc
parent 9093 61d1cd95698e
child 9112 345a7d41dda9
permissions -rw-r--r--
Better check for __has_feature
     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   set(CMAKE_REQUIRED_FLAGS)
   347   if(HAVE_NO_UNDEFINED)
   348     list(APPEND EXTRA_LDFLAGS "-Wl,--no-undefined")
   349   endif()
   350 endif()
   351 
   352 if(ASSEMBLY)
   353   if(USE_GCC OR USE_CLANG)
   354     set(SDL_ASSEMBLY_ROUTINES 1)
   355     # TODO: Those all seem to be quite GCC specific - needs to be
   356     # reworked for better compiler support
   357     set(HAVE_ASSEMBLY TRUE)
   358     if(MMX)
   359       set(CMAKE_REQUIRED_FLAGS "-mmmx")
   360       check_c_source_compiles("
   361           #ifdef __MINGW32__
   362           #include <_mingw.h>
   363           #ifdef __MINGW64_VERSION_MAJOR
   364           #include <intrin.h>
   365           #else
   366           #include <mmintrin.h>
   367           #endif
   368           #else
   369           #include <mmintrin.h>
   370           #endif
   371           #ifndef __MMX__
   372           #error Assembler CPP flag not enabled
   373           #endif
   374           int main(int argc, char **argv) { }" HAVE_MMX)
   375       if(HAVE_MMX)
   376         list(APPEND EXTRA_CFLAGS "-mmmx")
   377       endif()
   378       set(CMAKE_REQUIRED_FLAGS)
   379     endif()
   380 
   381     if(3DNOW)
   382       set(CMAKE_REQUIRED_FLAGS "-m3dnow")
   383       check_c_source_compiles("
   384           #include <mm3dnow.h>
   385           #ifndef __3dNOW__
   386           #error Assembler CPP flag not enabled
   387           #endif
   388           int main(int argc, char **argv) {
   389             void *p = 0;
   390             _m_prefetch(p);
   391           }" HAVE_3DNOW)
   392       if(HAVE_3DNOW)
   393         list(APPEND EXTRA_CFLAGS "-m3dnow")
   394       endif()
   395       set(CMAKE_REQUIRED_FLAGS)
   396     endif()
   397 
   398     if(SSE)
   399       set(CMAKE_REQUIRED_FLAGS "-msse")
   400       check_c_source_compiles("
   401           #ifdef __MINGW32__
   402           #include <_mingw.h>
   403           #ifdef __MINGW64_VERSION_MAJOR
   404           #include <intrin.h>
   405           #else
   406           #include <xmmintrin.h>
   407           #endif
   408           #else
   409           #include <xmmintrin.h>
   410           #endif
   411           #ifndef __SSE__
   412           #error Assembler CPP flag not enabled
   413           #endif
   414           int main(int argc, char **argv) { }" HAVE_SSE)
   415       if(HAVE_SSE)
   416         list(APPEND EXTRA_CFLAGS "-msse")
   417       endif()
   418       set(CMAKE_REQUIRED_FLAGS)
   419     endif()
   420 
   421     if(SSE2)
   422       set(CMAKE_REQUIRED_FLAGS "-msse2")
   423       check_c_source_compiles("
   424           #ifdef __MINGW32__
   425           #include <_mingw.h>
   426           #ifdef __MINGW64_VERSION_MAJOR
   427           #include <intrin.h>
   428           #else
   429           #include <emmintrin.h>
   430           #endif
   431           #else
   432           #include <emmintrin.h>
   433           #endif
   434           #ifndef __SSE2__
   435           #error Assembler CPP flag not enabled
   436           #endif
   437           int main(int argc, char **argv) { }" HAVE_SSE2)
   438       if(HAVE_SSE2)
   439         list(APPEND EXTRA_CFLAGS "-msse2")
   440       endif()
   441       set(CMAKE_REQUIRED_FLAGS)
   442     endif()
   443 
   444     if(SSEMATH)
   445       if(SSE OR SSE2)
   446         if(USE_GCC)
   447           list(APPEND EXTRA_CFLAGS "-mfpmath=387")
   448         endif()
   449         set(HAVE_SSEMATH TRUE)
   450       endif()
   451     endif()
   452 
   453     if(ALTIVEC)
   454       set(CMAKE_REQUIRED_FLAGS "-maltivec")
   455       check_c_source_compiles("
   456           #include <altivec.h>
   457           vector unsigned int vzero() {
   458               return vec_splat_u32(0);
   459           }
   460           int main(int argc, char **argv) { }" HAVE_ALTIVEC_H_HDR)
   461       check_c_source_compiles("
   462           vector unsigned int vzero() {
   463               return vec_splat_u32(0);
   464           }
   465           int main(int argc, char **argv) { }" HAVE_ALTIVEC)
   466       set(CMAKE_REQUIRED_FLAGS)
   467       if(HAVE_ALTIVEC OR HAVE_ALTIVEC_H_HDR)
   468         set(HAVE_ALTIVEC TRUE) # if only HAVE_ALTIVEC_H_HDR is set
   469         list(APPEND EXTRA_CFLAGS "-maltivec")
   470         set(SDL_ALTIVEC_BLITTERS 1)
   471         if(HAVE_ALTIVEC_H_HDR)
   472           set(HAVE_ALTIVEC_H 1)
   473         endif()
   474       endif()
   475     endif()
   476   elseif(MSVC_VERSION GREATER 1500)
   477     # TODO: SDL_cpuinfo.h needs to support the user's configuration wish
   478     # for MSVC - right now it is always activated
   479     if(NOT ARCH_64)
   480       set(HAVE_MMX TRUE)
   481       set(HAVE_3DNOW TRUE)
   482     endif()
   483     set(HAVE_SSE TRUE)
   484     set(HAVE_SSE2 TRUE)
   485     set(SDL_ASSEMBLY_ROUTINES 1)
   486   endif()
   487 # TODO:
   488 #else(ASSEMBLY)
   489 #  if(USE_GCC OR USE_CLANG)
   490 #    list(APPEND EXTRA_CFLAGS "-mno-sse" "-mno-sse2" "-mno-mmx")
   491 #  endif()
   492 endif()
   493 
   494 # TODO: Can't deactivate on FreeBSD? w/o LIBC, SDL_stdinc.h can't define
   495 # anything.
   496 if(LIBC)
   497   if(WINDOWS AND NOT MINGW)
   498     set(HAVE_LIBC TRUE)
   499     foreach(_HEADER stdio.h string.h ctype.h math.h)
   500       string(TOUPPER "HAVE_${_HEADER}" _UPPER)
   501       string(REPLACE "." "_" _HAVE_H ${_UPPER})
   502       set(${_HAVE_H} 1)
   503     endforeach()
   504     set(HAVE_SIGNAL_H 1)
   505     foreach(_FN
   506             malloc calloc realloc free qsort abs memset memcpy memmove memcmp
   507             strlen _strrev _strupr _strlwr strchr strrchr strstr itoa _ltoa
   508             _ultoa strtol strtoul strtoll strtod atoi atof strcmp strncmp
   509             _stricmp _strnicmp sscanf atan atan2 acos asin ceil copysign cos
   510             cosf fabs floor log pow scalbn sin sinf sqrt sqrtf tan tanf)
   511       string(TOUPPER ${_FN} _UPPER)
   512       set(HAVE_${_UPPER} 1)
   513     endforeach()
   514     if(NOT CYGWIN AND NOT MINGW)
   515       set(HAVE_ALLOCA 1)
   516     endif()
   517     set(HAVE_M_PI 1)
   518     add_definitions(-D_USE_MATH_DEFINES) # needed for M_PI
   519     set(STDC_HEADERS 1)
   520   else(WINDOWS AND NOT MINGW)
   521     set(HAVE_LIBC TRUE)
   522     check_include_file(sys/types.h HAVE_SYS_TYPES_H)
   523     foreach(_HEADER
   524             stdio.h stdlib.h stddef.h stdarg.h malloc.h memory.h string.h
   525             strings.h inttypes.h stdint.h ctype.h math.h iconv.h signal.h)
   526       string(TOUPPER "HAVE_${_HEADER}" _UPPER)
   527       string(REPLACE "." "_" _HAVE_H ${_UPPER})
   528       check_include_file("${_HEADER}" ${_HAVE_H})
   529     endforeach()
   530 
   531     check_include_files("dlfcn.h;stdint.h;stddef.h;inttypes.h;stdlib.h;strings.h;string.h;float.h" STDC_HEADERS)
   532     check_type_size("size_t" SIZEOF_SIZE_T)
   533     check_symbol_exists(M_PI math.h HAVE_M_PI)
   534     # TODO: refine the mprotect check
   535     check_c_source_compiles("#include <sys/types.h>
   536                              #include <sys/mman.h>
   537                              int main() { }" HAVE_MPROTECT)
   538     foreach(_FN
   539             strtod malloc calloc realloc free getenv setenv putenv unsetenv
   540             qsort abs bcopy memset memcpy memmove memcmp strlen strlcpy strlcat
   541             strdup _strrev _strupr _strlwr strchr strrchr strstr itoa _ltoa
   542             _uitoa _ultoa strtol strtoul _i64toa _ui64toa strtoll strtoull
   543             atoi atof strcmp strncmp _stricmp strcasecmp _strnicmp strncasecmp
   544             vsscanf vsnprintf fseeko fseeko64 sigaction setjmp
   545             nanosleep sysconf sysctlbyname
   546             )
   547       string(TOUPPER ${_FN} _UPPER)
   548       set(_HAVEVAR "HAVE_${_UPPER}")
   549       check_function_exists("${_FN}" ${_HAVEVAR})
   550     endforeach()
   551 
   552     check_library_exists(m pow "" HAVE_LIBM)
   553     if(HAVE_LIBM)
   554       set(CMAKE_REQUIRED_LIBRARIES m)
   555       foreach(_FN
   556               atan atan2 ceil copysign cos cosf fabs floor log pow scalbn sin
   557               sinf sqrt sqrtf tan tanf)
   558         string(TOUPPER ${_FN} _UPPER)
   559         set(_HAVEVAR "HAVE_${_UPPER}")
   560         check_function_exists("${_FN}" ${_HAVEVAR})
   561       endforeach()
   562       set(CMAKE_REQUIRED_LIBRARIES)
   563       list(APPEND EXTRA_LIBS m)
   564     endif()
   565 
   566     check_library_exists(iconv iconv_open "" HAVE_LIBICONV)
   567     if(HAVE_LIBICONV)
   568       list(APPEND EXTRA_LIBS iconv)
   569     endif()
   570 
   571     check_struct_has_member("struct sigaction" "sa_sigaction" "signal.h" HAVE_SA_SIGACTION)
   572   endif()
   573 else(LIBC)
   574   if(WINDOWS)
   575     set(HAVE_STDARG_H 1)
   576     set(HAVE_STDDEF_H 1)
   577   endif()
   578 endif()
   579 
   580 
   581 # Enable/disable various subsystems of the SDL library
   582 foreach(_SUB ${SDL_SUBSYSTEMS})
   583   string(TOUPPER ${_SUB} _OPT)
   584   if(NOT SDL_${_OPT})
   585     set(SDL_${_OPT}_DISABLED 1)
   586   endif()
   587 endforeach()
   588 if(SDL_JOYSTICK)
   589   file(GLOB JOYSTICK_SOURCES ${SDL2_SOURCE_DIR}/src/joystick/*.c)
   590   set(SOURCE_FILES ${SOURCE_FILES} ${JOYSTICK_SOURCES})
   591 endif()
   592 if(SDL_HAPTIC)
   593   if(NOT SDL_JOYSTICK)
   594     # Haptic requires some private functions from the joystick subsystem.
   595     message_error("SDL_HAPTIC requires SDL_JOYSTICK, which is not enabled")
   596   endif()
   597   file(GLOB HAPTIC_SOURCES ${SDL2_SOURCE_DIR}/src/haptic/*.c)
   598   set(SOURCE_FILES ${SOURCE_FILES} ${HAPTIC_SOURCES})
   599 endif()
   600 if(SDL_POWER)
   601   file(GLOB POWER_SOURCES ${SDL2_SOURCE_DIR}/src/power/*.c)
   602   set(SOURCE_FILES ${SOURCE_FILES} ${POWER_SOURCES})
   603 endif()
   604 # TODO: in configure.in, the test for LOADSO and SDL_DLOPEN is a bit weird:
   605 # if LOADSO is not wanted, SDL_LOADSO_DISABLED is set
   606 # If however on Unix or APPLE dlopen() is detected via CheckDLOPEN(),
   607 # SDL_LOADSO_DISABLED will not be set, regardless of the LOADSO settings
   608 
   609 # General SDL subsystem options, valid for all platforms
   610 if(SDL_AUDIO)
   611   # CheckDummyAudio/CheckDiskAudio - valid for all platforms
   612   if(DUMMYAUDIO)
   613     set(SDL_AUDIO_DRIVER_DUMMY 1)
   614     file(GLOB DUMMYAUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/dummy/*.c)
   615     set(SOURCE_FILES ${SOURCE_FILES} ${DUMMYAUDIO_SOURCES})
   616     set(HAVE_DUMMYAUDIO TRUE)
   617   endif()
   618   if(DISKAUDIO)
   619     set(SDL_AUDIO_DRIVER_DISK 1)
   620     file(GLOB DISKAUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/disk/*.c)
   621     set(SOURCE_FILES ${SOURCE_FILES} ${DISKAUDIO_SOURCES})
   622     set(HAVE_DISKAUDIO TRUE)
   623   endif()
   624 endif()
   625 
   626 if(SDL_DLOPEN)
   627   # Relevant for Unix/Darwin only
   628   if(UNIX OR APPLE)
   629     CheckDLOPEN()
   630   endif()
   631 endif()
   632 
   633 if(SDL_VIDEO)
   634   if(VIDEO_DUMMY)
   635     set(SDL_VIDEO_DRIVER_DUMMY 1)
   636     file(GLOB VIDEO_DUMMY_SOURCES ${SDL2_SOURCE_DIR}/src/video/dummy/*.c)
   637     set(SOURCE_FILES ${SOURCE_FILES} ${VIDEO_DUMMY_SOURCES})
   638     set(HAVE_VIDEO_DUMMY TRUE)
   639     set(HAVE_SDL_VIDEO TRUE)
   640   endif()
   641 endif()
   642 
   643 # Platform-specific options and settings
   644 if(UNIX AND NOT APPLE)
   645   if(SDL_AUDIO)
   646     if(SYSV5 OR SOLARIS OR HPUX)
   647         set(SDL_AUDIO_DRIVER_SUNAUDIO 1)
   648         file(GLOB SUN_AUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/sun/*.c)
   649         set(SOURCE_FILES ${SOURCE_FILES} ${SUN_AUDIO_SOURCES})
   650         set(HAVE_SDL_AUDIO TRUE)
   651     elseif(NETBSD OR OPENBSD)
   652         set(SDL_AUDIO_DRIVER_BSD 1)
   653         file(GLOB BSD_AUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/bsd/*.c)
   654         set(SOURCE_FILES ${SOURCE_FILES} ${BSD_AUDIO_SOURCES})
   655         set(HAVE_SDL_AUDIO TRUE)
   656     elseif(AIX)
   657         set(SDL_AUDIO_DRIVER_PAUDIO 1)
   658         file(GLOB AIX_AUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/paudio/*.c)
   659         set(SOURCE_FILES ${SOURCE_FILES} ${AIX_AUDIO_SOURCES})
   660         set(HAVE_SDL_AUDIO TRUE)
   661     endif()
   662     CheckOSS()
   663     CheckALSA()
   664     CheckPulseAudio()
   665     CheckESD()
   666     CheckARTS()
   667     CheckNAS()
   668     CheckSNDIO()
   669     CheckFusionSound()
   670   endif()
   671 
   672   if(SDL_VIDEO)
   673     # Need to check for Raspberry PI first and add platform specific compiler flags, otherwise the test for GLES fails!
   674     CheckRPI()
   675     CheckX11()
   676     CheckMir()
   677     CheckDirectFB()
   678     CheckOpenGLX11()
   679     CheckOpenGLESX11()
   680     CheckWayland()
   681   endif()
   682 
   683   if(LINUX)
   684     check_c_source_compiles("
   685         #include <linux/input.h>
   686         #ifndef EVIOCGNAME
   687         #error EVIOCGNAME() ioctl not available
   688         #endif
   689         int main(int argc, char** argv) {}" HAVE_INPUT_EVENTS)
   690 
   691     check_c_source_compiles("
   692         #include <linux/kd.h>
   693         #include <linux/keyboard.h>
   694 
   695         int main(int argc, char **argv) 
   696         {
   697             struct kbentry kbe;
   698             kbe.kb_table = KG_CTRL;
   699             ioctl(0, KDGKBENT, &kbe);
   700         }" HAVE_INPUT_KD)
   701 
   702     file(GLOB CORE_SOURCES ${SDL2_SOURCE_DIR}/src/core/linux/*.c)
   703     set(SOURCE_FILES ${SOURCE_FILES} ${CORE_SOURCES})
   704 
   705     if(HAVE_INPUT_EVENTS)
   706       set(SDL_INPUT_LINUXEV 1)
   707     endif()
   708 
   709     if(SDL_HAPTIC AND HAVE_INPUT_EVENTS)
   710       set(SDL_HAPTIC_LINUX 1)
   711       file(GLOB HAPTIC_SOURCES ${SDL2_SOURCE_DIR}/src/haptic/linux/*.c)
   712       set(SOURCE_FILES ${SOURCE_FILES} ${HAPTIC_SOURCES})
   713       set(HAVE_SDL_HAPTIC TRUE)
   714     endif()
   715 
   716     if(HAVE_INPUT_KD)
   717       set(SDL_INPUT_LINUXKD 1)
   718     endif()
   719 
   720     check_include_file("libudev.h" HAVE_LIBUDEV_H)
   721 
   722     # !!! FIXME: this needs pkg-config to find the include path, I think.
   723     check_include_file("dbus/dbus.h" HAVE_DBUS_DBUS_H)
   724   endif()
   725 
   726   if(INPUT_TSLIB)
   727     check_c_source_compiles("
   728         #include \"tslib.h\"
   729         int main(int argc, char** argv) { }" HAVE_INPUT_TSLIB)
   730     if(HAVE_INPUT_TSLIB)
   731       set(SDL_INPUT_TSLIB 1)
   732       list(APPEND EXTRA_LIBS ts)
   733     endif()
   734   endif()
   735 
   736   if(SDL_JOYSTICK)
   737     CheckUSBHID()   # seems to be BSD specific - limit the test to BSD only?
   738     if(LINUX)
   739       set(SDL_JOYSTICK_LINUX 1)
   740       file(GLOB JOYSTICK_SOURCES ${SDL2_SOURCE_DIR}/src/joystick/linux/*.c)
   741       set(SOURCE_FILES ${SOURCE_FILES} ${JOYSTICK_SOURCES})
   742       set(HAVE_SDL_JOYSTICK TRUE)
   743     endif()
   744   endif()
   745 
   746   CheckPTHREAD()
   747 
   748   if(CLOCK_GETTIME)
   749     check_library_exists(rt clock_gettime "" FOUND_CLOCK_GETTIME)
   750     if(FOUND_CLOCK_GETTIME)
   751       list(APPEND EXTRA_LIBS rt)
   752       set(HAVE_CLOCK_GETTIME 1)
   753     else(FOUND_CLOCK_GETTIME)
   754       check_library_exists(c clock_gettime "" FOUND_CLOCK_GETTIME)
   755       if(FOUND_CLOCK_GETTIME)
   756         set(HAVE_CLOCK_GETTIME 1)
   757       endif()
   758     endif()
   759   endif()
   760 
   761   check_include_file(linux/version.h HAVE_LINUX_VERSION_H)
   762   if(HAVE_LINUX_VERSION_H)
   763     set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DHAVE_LINUX_VERSION_H")
   764   endif()
   765 
   766   if(SDL_POWER)
   767     if(LINUX)
   768       set(SDL_POWER_LINUX 1)
   769       file(GLOB POWER_SOURCES ${SDL2_SOURCE_DIR}/src/power/linux/*.c)
   770       set(SOURCE_FILES ${SOURCE_FILES} ${POWER_SOURCES})
   771       set(HAVE_SDL_POWER TRUE)
   772     endif()
   773   endif()
   774 
   775   if(SDL_FILESYSTEM)
   776     set(SDL_FILESYSTEM_UNIX 1)
   777     file(GLOB FILESYSTEM_SOURCES ${SDL2_SOURCE_DIR}/src/filesystem/unix/*.c)
   778     set(SOURCE_FILES ${SOURCE_FILES} ${FILESYSTEM_SOURCES})
   779     set(HAVE_SDL_FILESYSTEM TRUE)
   780   endif()
   781 
   782   if(SDL_TIMERS)
   783     set(SDL_TIMER_UNIX 1)
   784     file(GLOB TIMER_SOURCES ${SDL2_SOURCE_DIR}/src/timer/unix/*.c)
   785     set(SOURCE_FILES ${SOURCE_FILES} ${TIMER_SOURCES})
   786     set(HAVE_SDL_TIMERS TRUE)
   787   endif()
   788 
   789   if(RPATH)
   790     set(SDL_RLD_FLAGS "")
   791     if(BSDI OR FREEBSD OR LINUX OR NETBSD)
   792       set(SDL_RLD_FLAGS "-Wl,-rpath,\${libdir}")
   793     elseif(SOLARIS)
   794       set(SDL_RLD_FLAGS "-R\${libdir}")
   795     endif()
   796     set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
   797     set(HAVE_RPATH TRUE)
   798   endif()
   799 
   800 elseif(WINDOWS)
   801   find_program(WINDRES windres)
   802 
   803   check_c_source_compiles("
   804     #include <windows.h>
   805     int main(int argc, char **argv) { }" HAVE_WIN32_CC)
   806 
   807   file(GLOB CORE_SOURCES ${SDL2_SOURCE_DIR}/src/core/windows/*.c)
   808   set(SOURCE_FILES ${SOURCE_FILES} ${CORE_SOURCES})
   809 
   810   # Check for DirectX
   811   if(DIRECTX)
   812     if("$ENV{DXSDK_DIR}" STREQUAL "")
   813       message_error("DIRECTX requires the \$DXSDK_DIR environment variable to be set")
   814     endif()
   815     set(CMAKE_REQUIRED_FLAGS "/I\"$ENV{DXSDK_DIR}\\Include\"")
   816     check_include_file(d3d9.h HAVE_D3D_H)
   817     check_include_file(d3d11_1.h HAVE_D3D11_H)
   818     check_include_file(ddraw.h HAVE_DDRAW_H)
   819     check_include_file(dsound.h HAVE_DSOUND_H)
   820     check_include_file(dinput.h HAVE_DINPUT_H)
   821     check_include_file(xaudio2.h HAVE_XAUDIO2_H)
   822     check_include_file(xinput.h HAVE_XINPUT_H)
   823     check_include_file(dxgi.h HAVE_DXGI_H)
   824     if(HAVE_D3D_H OR HAVE_D3D11_H OR HAVE_DDRAW_H OR HAVE_DSOUND_H OR HAVE_DINPUT_H OR HAVE_XAUDIO2_H)
   825       set(HAVE_DIRECTX TRUE)
   826       # TODO: change $ENV{DXSDL_DIR} to get the path from the include checks
   827       link_directories($ENV{DXSDK_DIR}\\lib\\${PROCESSOR_ARCH})
   828       include_directories($ENV{DXSDK_DIR}\\Include)
   829     endif()
   830     set(CMAKE_REQUIRED_FLAGS)
   831   endif()
   832 
   833   if(SDL_AUDIO)
   834     set(SDL_AUDIO_DRIVER_WINMM 1)
   835     file(GLOB WINMM_AUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/winmm/*.c)
   836     set(SOURCE_FILES ${SOURCE_FILES} ${WINMM_AUDIO_SOURCES})
   837     set(HAVE_SDL_AUDIO TRUE)
   838 
   839     if(HAVE_DSOUND_H)
   840       set(SDL_AUDIO_DRIVER_DSOUND 1)
   841       file(GLOB DSOUND_AUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/directsound/*.c)
   842       set(SOURCE_FILES ${SOURCE_FILES} ${DSOUND_AUDIO_SOURCES})
   843     endif()
   844 
   845     if(HAVE_XAUDIO2_H)
   846       set(SDL_AUDIO_DRIVER_XAUDIO2 1)
   847       file(GLOB XAUDIO2_AUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/xaudio2/*.c)
   848       set(SOURCE_FILES ${SOURCE_FILES} ${XAUDIO2_AUDIO_SOURCES})
   849     endif()
   850   endif()
   851 
   852   if(SDL_VIDEO)
   853     # requires SDL_LOADSO on Windows (IME, DX, etc.)
   854     if(NOT SDL_LOADSO)
   855       message_error("SDL_VIDEO requires SDL_LOADSO, which is not enabled")
   856     endif()
   857     set(SDL_VIDEO_DRIVER_WINDOWS 1)
   858     file(GLOB WIN_VIDEO_SOURCES ${SDL2_SOURCE_DIR}/src/video/windows/*.c)
   859     set(SOURCE_FILES ${SOURCE_FILES} ${WIN_VIDEO_SOURCES})
   860 
   861     if(RENDER_D3D AND HAVE_D3D_H)
   862       set(SDL_VIDEO_RENDER_D3D 1)
   863       set(HAVE_RENDER_D3D TRUE)
   864     endif()
   865     if(RENDER_D3D AND HAVE_D3D11_H)
   866       set(SDL_VIDEO_RENDER_D3D11 1)
   867       set(HAVE_RENDER_D3D TRUE)
   868     endif()
   869     set(HAVE_SDL_VIDEO TRUE)
   870   endif()
   871 
   872   if(SDL_THREADS)
   873     set(SDL_THREAD_WINDOWS 1)
   874     set(SOURCE_FILES ${SOURCE_FILES}
   875       ${SDL2_SOURCE_DIR}/src/thread/windows/SDL_sysmutex.c
   876       ${SDL2_SOURCE_DIR}/src/thread/windows/SDL_syssem.c
   877       ${SDL2_SOURCE_DIR}/src/thread/windows/SDL_systhread.c
   878       ${SDL2_SOURCE_DIR}/src/thread/windows/SDL_systls.c
   879       ${SDL2_SOURCE_DIR}/src/thread/generic/SDL_syscond.c)
   880     set(HAVE_SDL_THREADS TRUE)
   881   endif()
   882 
   883   if(SDL_POWER)
   884     set(SDL_POWER_WINDOWS 1)
   885     set(SOURCE_FILES ${SOURCE_FILES} ${SDL2_SOURCE_DIR}/src/power/windows/SDL_syspower.c)
   886     set(HAVE_SDL_POWER TRUE)
   887   endif()
   888 
   889   if(SDL_FILESYSTEM)
   890     set(SDL_FILESYSTEM_WINDOWS 1)
   891     file(GLOB FILESYSTEM_SOURCES ${SDL2_SOURCE_DIR}/src/filesystem/windows/*.c)
   892     set(SOURCE_FILES ${SOURCE_FILES} ${FILESYSTEM_SOURCES})
   893     set(HAVE_SDL_FILESYSTEM TRUE)
   894   endif()
   895 
   896   # Libraries for Win32 native and MinGW
   897   list(APPEND EXTRA_LIBS user32 gdi32 winmm imm32 ole32 oleaut32 version uuid)
   898 
   899   # TODO: in configure.in the check for timers is set on
   900   # cygwin | mingw32* - does this include mingw32CE?
   901   if(SDL_TIMERS)
   902     set(SDL_TIMER_WINDOWS 1)
   903     file(GLOB TIMER_SOURCES ${SDL2_SOURCE_DIR}/src/timer/windows/*.c)
   904     set(SOURCE_FILES ${SOURCE_FILES} ${TIMER_SOURCES})
   905     set(HAVE_SDL_TIMERS TRUE)
   906   endif()
   907 
   908   if(SDL_LOADSO)
   909     set(SDL_LOADSO_WINDOWS 1)
   910     file(GLOB LOADSO_SOURCES ${SDL2_SOURCE_DIR}/src/loadso/windows/*.c)
   911     set(SOURCE_FILES ${SOURCE_FILES} ${LOADSO_SOURCES})
   912     set(HAVE_SDL_LOADSO TRUE)
   913   endif()
   914 
   915   file(GLOB CORE_SOURCES ${SDL2_SOURCE_DIR}/src/core/windows/*.c)
   916   set(SOURCE_FILES ${SOURCE_FILES} ${CORE_SOURCES})
   917 
   918   if(SDL_VIDEO)
   919     if(VIDEO_OPENGL)
   920       set(SDL_VIDEO_OPENGL 1)
   921       set(SDL_VIDEO_OPENGL_WGL 1)
   922       set(SDL_VIDEO_RENDER_OGL 1)
   923       set(HAVE_VIDEO_OPENGL TRUE)
   924     endif()
   925   endif()
   926 
   927   if(SDL_JOYSTICK)
   928     file(GLOB JOYSTICK_SOURCES ${SDL2_SOURCE_DIR}/src/joystick/windows/*.c)
   929     set(SOURCE_FILES ${SOURCE_FILES} ${JOYSTICK_SOURCES})
   930     if(HAVE_DINPUT_H)
   931       set(SDL_JOYSTICK_DINPUT 1)
   932       list(APPEND EXTRA_LIBS dinput8 dxguid dxerr)
   933     endif()
   934     if(HAVE_XINPUT_H)
   935       set(SDL_JOYSTICK_XINPUT 1)
   936     endif()
   937     if(NOT HAVE_DINPUT_H AND NOT HAVE_XINPUT_H)
   938       set(SDL_JOYSTICK_WINMM 1)
   939     endif()
   940     set(HAVE_SDL_JOYSTICK TRUE)
   941 
   942     if(SDL_HAPTIC)
   943       file(GLOB HAPTIC_SOURCES ${SDL2_SOURCE_DIR}/src/haptic/windows/*.c)
   944       set(SOURCE_FILES ${SOURCE_FILES} ${HAPTIC_SOURCES})
   945       if(HAVE_DINPUT_H)
   946         set(SDL_HAPTIC_DINPUT 1)
   947       endif()
   948       if(HAVE_XINPUT_H)
   949         set(SDL_HAPTIC_XINPUT 1)
   950       endif()
   951       set(HAVE_SDL_HAPTIC TRUE)
   952     endif()
   953   endif()
   954 
   955   file(GLOB VERSION_SOURCES ${SDL2_SOURCE_DIR}/src/main/windows/*.rc)
   956   file(GLOB SDLMAIN_SOURCES ${SDL2_SOURCE_DIR}/src/main/windows/*.c)
   957   if(MINGW OR CYGWIN)
   958     list(APPEND EXTRA_LIBS mingw32)
   959     list(APPEND EXTRA_LDFLAGS "-mwindows")
   960     set(SDL_CFLAGS "${SDL_CFLAGS} -Dmain=SDL_main")
   961     list(APPEND SDL_LIBS "-lmingw32" "-lSDL2main" "-mwindows")
   962   endif()
   963 elseif(APPLE)
   964   # TODO: rework this for proper MacOS X, iOS and Darwin support
   965 
   966   # Requires the darwin file implementation
   967   if(SDL_FILE)
   968     file(GLOB EXTRA_SOURCES ${PROJECT_SOURCE_DIR}/src/file/cocoa/*.m)
   969     set(SOURCE_FILES ${EXTRA_SOURCES} ${SOURCE_FILES})
   970     set_source_files_properties(${EXTRA_SOURCES} PROPERTIES LANGUAGE C)
   971     set(HAVE_SDL_FILE TRUE)
   972     set(SDL_FRAMEWORK_COCOA 1)
   973   else()
   974     message_error("SDL_FILE must be enabled to build on MacOS X")
   975   endif()
   976 
   977   if(SDL_AUDIO)
   978     set(MACOSX_COREAUDIO 1)
   979     file(GLOB AUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/coreaudio/*.c)
   980     set(SOURCE_FILES ${SOURCE_FILES} ${AUDIO_SOURCES})
   981     set(HAVE_SDL_AUDIO TRUE)
   982     set(SDL_FRAMEWORK_COREAUDIO 1)
   983     set(SDL_FRAMEWORK_AUDIOUNIT 1)
   984   endif()
   985 
   986   if(SDL_JOYSTICK)
   987     set(SDL_JOYSTICK_IOKIT 1)
   988     file(GLOB JOYSTICK_SOURCES ${SDL2_SOURCE_DIR}/src/joystick/darwin/*.c)
   989     set(SOURCE_FILES ${SOURCE_FILES} ${JOYSTICK_SOURCES})
   990     set(HAVE_SDL_JOYSTICK TRUE)
   991     set(SDL_FRAMEWORK_IOKIT 1)
   992     set(SDL_FRAMEWORK_FF 1)
   993   endif()
   994 
   995   if(SDL_HAPTIC)
   996     set(SDL_HAPTIC_IOKIT 1)
   997     file(GLOB HAPTIC_SOURCES ${SDL2_SOURCE_DIR}/src/haptic/darwin/*.c)
   998     set(SOURCE_FILES ${SOURCE_FILES} ${HAPTIC_SOURCES})
   999     set(HAVE_SDL_HAPTIC TRUE)
  1000     set(SDL_FRAMEWORK_IOKIT 1)
  1001     set(SDL_FRAMEWORK_FF 1)
  1002     if(NOT SDL_JOYSTICK)
  1003       message(FATAL_ERROR "SDL_HAPTIC requires SDL_JOYSTICK to be enabled")
  1004     endif()
  1005   endif()
  1006 
  1007   if(SDL_POWER)
  1008     set(SDL_POWER_MACOSX 1)
  1009     file(GLOB POWER_SOURCES ${SDL2_SOURCE_DIR}/src/power/macosx/*.c)
  1010     set(SOURCE_FILES ${SOURCE_FILES} ${POWER_SOURCES})
  1011     set(HAVE_SDL_POWER TRUE)
  1012     set(SDL_FRAMEWORK_CARBON 1)
  1013     set(SDL_FRAMEWORK_IOKIT 1)
  1014   endif()
  1015 
  1016   if(SDL_TIMERS)
  1017     set(SDL_TIMER_UNIX 1)
  1018     file(GLOB TIMER_SOURCES ${SDL2_SOURCE_DIR}/src/timer/unix/*.c)
  1019     set(SOURCE_FILES ${SOURCE_FILES} ${TIMER_SOURCES})
  1020     set(HAVE_SDL_TIMERS TRUE)
  1021   endif(SDL_TIMERS)
  1022 
  1023   if(SDL_FILESYSTEM)
  1024     set(SDL_FILESYSTEM_COCOA 1)
  1025     file(GLOB FILESYSTEM_SOURCES ${SDL2_SOURCE_DIR}/src/filesystem/cocoa/*.m)
  1026     set_source_files_properties(${FILESYSTEM_SOURCES} PROPERTIES LANGUAGE C)
  1027     set(SOURCE_FILES ${SOURCE_FILES} ${FILESYSTEM_SOURCES})
  1028     set(HAVE_SDL_FILESYSTEM TRUE)
  1029   endif()
  1030 
  1031   # Actually load the frameworks at the end so we don't duplicate include.
  1032   if(SDL_FRAMEWORK_COCOA)
  1033     find_library(COCOA_LIBRARY Cocoa)
  1034     list(APPEND EXTRA_LIBS ${COCOA_LIBRARY})
  1035   endif()
  1036   if(SDL_FRAMEWORK_IOKIT)
  1037     find_library(IOKIT IOKit)
  1038     list(APPEND EXTRA_LIBS ${IOKIT})
  1039   endif()
  1040   if(SDL_FRAMEWORK_FF)
  1041     find_library(FORCEFEEDBACK ForceFeedback)
  1042     list(APPEND EXTRA_LIBS ${FORCEFEEDBACK})
  1043   endif()
  1044   if(SDL_FRAMEWORK_CARBON)
  1045     find_library(CARBON_LIBRARY Carbon)
  1046     list(APPEND EXTRA_LIBS ${CARBON_LIBRARY})
  1047   endif()
  1048   if(SDL_FRAMEWORK_COREAUDIO)
  1049     find_library(COREAUDIO CoreAudio)
  1050     list(APPEND EXTRA_LIBS ${COREAUDIO})
  1051   endif()
  1052   if(SDL_FRAMEWORK_AUDIOUNIT)
  1053     find_library(AUDIOUNIT AudioUnit)
  1054     list(APPEND EXTRA_LIBS ${AUDIOUNIT})
  1055   endif()
  1056 
  1057   # iOS hack needed - http://code.google.com/p/ios-cmake/ ?
  1058   if(SDL_VIDEO)
  1059     CheckCOCOA()
  1060     if(VIDEO_OPENGL)
  1061       set(SDL_VIDEO_OPENGL 1)
  1062       set(SDL_VIDEO_OPENGL_CGL 1)
  1063       set(SDL_VIDEO_RENDER_OGL 1)
  1064       if(DARWIN)
  1065         find_library(OpenGL_LIBRARY OpenGL)
  1066         list(APPEND EXTRA_LIBRARIES ${OpenGL_LIBRARY})
  1067       endif()
  1068       set(HAVE_VIDEO_OPENGL TRUE)
  1069     endif()
  1070   endif()
  1071 
  1072   CheckPTHREAD()
  1073 elseif(HAIKU)
  1074   if(SDL_VIDEO)
  1075     set(SDL_VIDEO_DRIVER_HAIKU 1)
  1076     file(GLOB HAIKUVIDEO_SOURCES ${SDL2_SOURCE_DIR}/src/video/haiku/*.c)
  1077     set(SOURCE_FILES ${SOURCE_FILES} ${HAIKUVIDEO_SOURCES})
  1078     set(HAVE_SDL_VIDEO TRUE)
  1079 
  1080     set(SDL_FILESYSTEM_HAIKU 1)
  1081     file(GLOB FILESYSTEM_SOURCES ${SDL2_SOURCE_DIR}/src/filesystem/haiku/*.cc)
  1082     set(SOURCE_FILES ${SOURCE_FILES} ${FILESYSTEM_SOURCES})
  1083     set(HAVE_SDL_FILESYSTEM TRUE)
  1084 
  1085     if(SDL_TIMERS)
  1086       set(SDL_TIMER_HAIKU 1)
  1087       file(GLOB TIMER_SOURCES ${SDL2_SOURCE_DIR}/src/timer/haiku/*.c)
  1088       set(SOURCE_FILES ${SOURCE_FILES} ${TIMER_SOURCES})
  1089       set(HAVE_SDL_TIMERS TRUE)
  1090     endif(SDL_TIMERS)
  1091 
  1092     if(VIDEO_OPENGL)
  1093       # TODO: Use FIND_PACKAGE(OpenGL) instead
  1094       set(SDL_VIDEO_OPENGL 1)
  1095       set(SDL_VIDEO_OPENGL_BGL 1)
  1096       set(SDL_VIDEO_RENDER_OGL 1)
  1097       list(APPEND EXTRA_LIBS GL)
  1098       set(HAVE_VIDEO_OPENGL TRUE)
  1099     endif()
  1100   endif()
  1101 
  1102   CheckPTHREAD()
  1103 endif()
  1104 
  1105 # Dummies
  1106 # configure.in does it differently:
  1107 # if not have X
  1108 #   if enable_X {  SDL_X_DISABLED = 1 }
  1109 #   [add dummy sources]
  1110 # so it always adds a dummy, without checking, if it was actually requested.
  1111 # This leads to missing internal references on building, since the
  1112 # src/X/*.c does not get included.
  1113 if(NOT HAVE_SDL_JOYSTICK)
  1114   set(SDL_JOYSTICK_DISABLED 1)
  1115   if(SDL_JOYSTICK AND NOT APPLE) # results in unresolved symbols on OSX
  1116 
  1117     file(GLOB JOYSTICK_SOURCES ${SDL2_SOURCE_DIR}/src/joystick/dummy/*.c)
  1118     set(SOURCE_FILES ${SOURCE_FILES} ${JOYSTICK_SOURCES})
  1119   endif()
  1120 endif()
  1121 if(NOT HAVE_SDL_HAPTIC)
  1122   set(SDL_HAPTIC_DISABLED 1)
  1123   file(GLOB HAPTIC_SOURCES ${SDL2_SOURCE_DIR}/src/haptic/dummy/*.c)
  1124   set(SOURCE_FILES ${SOURCE_FILES} ${HAPTIC_SOURCES})
  1125 endif()
  1126 if(NOT HAVE_SDL_LOADSO)
  1127   set(SDL_LOADSO_DISABLED 1)
  1128   file(GLOB LOADSO_SOURCES ${SDL2_SOURCE_DIR}/src/loadso/dummy/*.c)
  1129   set(SOURCE_FILES ${SOURCE_FILES} ${LOADSO_SOURCES})
  1130 endif()
  1131 if(NOT HAVE_SDL_FILESYSTEM)
  1132   set(SDL_FILESYSTEM_DISABLED 1)
  1133   file(GLOB FILESYSTEM_SOURCES ${SDL2_SOURCE_DIR}/src/filesystem/dummy/*.c)
  1134   set(SOURCE_FILES ${SOURCE_FILES} ${FILESYSTEM_SOURCES})
  1135 endif()
  1136 
  1137 # We always need to have threads and timers around
  1138 if(NOT HAVE_SDL_THREADS)
  1139   set(SDL_THREADS_DISABLED 1)
  1140   file(GLOB THREADS_SOURCES ${SDL2_SOURCE_DIR}/src/thread/generic/*.c)
  1141   set(SOURCE_FILES ${SOURCE_FILES} ${THREADS_SOURCES})
  1142 endif()
  1143 if(NOT HAVE_SDL_TIMERS)
  1144   set(SDL_TIMERS_DISABLED 1)
  1145   file(GLOB TIMER_SOURCES ${SDL2_SOURCE_DIR}/src/timer/dummy/*.c)
  1146   set(SOURCE_FILES ${SOURCE_FILES} ${TIMER_SOURCES})
  1147 endif()
  1148 
  1149 if(NOT SDLMAIN_SOURCES)
  1150   file(GLOB SDLMAIN_SOURCES ${SDL2_SOURCE_DIR}/src/main/dummy/*.c)
  1151 endif()
  1152 
  1153 # Append the -MMD -MT flags
  1154 # if(DEPENDENCY_TRACKING)
  1155 #   if(COMPILER_IS_GNUCC)
  1156 #     set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -MMD -MT \$@")
  1157 #   endif()
  1158 # endif()
  1159 
  1160 configure_file("${SDL2_SOURCE_DIR}/include/SDL_config.h.cmake"
  1161   "${SDL2_BINARY_DIR}/include/SDL_config.h")
  1162 
  1163 # Prepare the flags and remove duplicates
  1164 if(EXTRA_LDFLAGS)
  1165   list(REMOVE_DUPLICATES EXTRA_LDFLAGS)
  1166 endif()
  1167 if(EXTRA_LIBS)
  1168   list(REMOVE_DUPLICATES EXTRA_LIBS)
  1169 endif()
  1170 if(EXTRA_CFLAGS)
  1171   list(REMOVE_DUPLICATES EXTRA_CFLAGS)
  1172 endif()
  1173 listtostr(EXTRA_CFLAGS _EXTRA_CFLAGS)
  1174 set(EXTRA_CFLAGS ${_EXTRA_CFLAGS})
  1175 
  1176 # Compat helpers for the configuration files
  1177 if(NOT WINDOWS OR CYGWIN)
  1178   # TODO: we need a Windows script, too
  1179   execute_process(COMMAND sh ${SDL2_SOURCE_DIR}/build-scripts/updaterev.sh)
  1180 
  1181   set(prefix ${CMAKE_INSTALL_PREFIX})
  1182   set(exec_prefix "\${prefix}")
  1183   set(libdir "\${exec_prefix}/lib${LIB_SUFFIX}")
  1184   set(bindir "\${exec_prefix}/bin")
  1185   set(includedir "\${prefix}/include")
  1186   if(SDL_STATIC)
  1187     set(ENABLE_STATIC_TRUE "")
  1188     set(ENABLE_STATIC_FALSE "#")
  1189   else(SDL_STATIC)
  1190     set(ENABLE_STATIC_TRUE "#")
  1191     set(ENABLE_STATIC_FALSE "")
  1192   endif()
  1193   if(SDL_SHARED)
  1194     set(ENABLE_SHARED_TRUE "")
  1195     set(ENABLE_SHARED_FALSE "#")
  1196   else(SDL_SHARED)
  1197     set(ENABLE_SHARED_TRUE "#")
  1198     set(ENABLE_SHARED_FALSE "")
  1199   endif()
  1200 
  1201   # Clean up the different lists
  1202   listtostr(EXTRA_LIBS _EXTRA_LIBS "-l")
  1203   set(SDL_STATIC_LIBS ${SDL_LIBS} ${EXTRA_LDFLAGS} ${_EXTRA_LIBS})
  1204   list(REMOVE_DUPLICATES SDL_STATIC_LIBS)
  1205   listtostr(SDL_STATIC_LIBS _SDL_STATIC_LIBS)
  1206   set(SDL_STATIC_LIBS ${_SDL_STATIC_LIBS})
  1207   listtostr(SDL_LIBS _SDL_LIBS)
  1208   set(SDL_LIBS ${_SDL_LIBS})
  1209 
  1210   # MESSAGE(STATUS "SDL_LIBS: ${SDL_LIBS}")
  1211   # MESSAGE(STATUS "SDL_STATIC_LIBS: ${SDL_STATIC_LIBS}")
  1212 
  1213   configure_file("${SDL2_SOURCE_DIR}/sdl2.pc.in"
  1214     "${SDL2_BINARY_DIR}/sdl2.pc" @ONLY)
  1215   configure_file("${SDL2_SOURCE_DIR}/sdl2-config.in"
  1216     "${SDL2_BINARY_DIR}/sdl2-config")
  1217   configure_file("${SDL2_SOURCE_DIR}/sdl2-config.in"
  1218     "${SDL2_BINARY_DIR}/sdl2-config" @ONLY)
  1219   configure_file("${SDL2_SOURCE_DIR}/SDL2.spec.in"
  1220     "${SDL2_BINARY_DIR}/SDL2.spec" @ONLY)
  1221 endif()
  1222 
  1223 ##### Info output #####
  1224 message(STATUS "")
  1225 message(STATUS "SDL2 was configured with the following options:")
  1226 message(STATUS "")
  1227 message(STATUS "Platform: ${CMAKE_SYSTEM}")
  1228 message(STATUS "64-bit:   ${ARCH_64}")
  1229 message(STATUS "Compiler: ${CMAKE_C_COMPILER}")
  1230 message(STATUS "")
  1231 message(STATUS "Subsystems:")
  1232 foreach(_SUB ${SDL_SUBSYSTEMS})
  1233   string(TOUPPER ${_SUB} _OPT)
  1234   message_bool_option(${_SUB} SDL_${_OPT})
  1235 endforeach()
  1236 message(STATUS "")
  1237 message(STATUS "Options:")
  1238 list(SORT ALLOPTIONS)
  1239 foreach(_OPT ${ALLOPTIONS})
  1240   # Longest option is VIDEO_X11_XSCREENSAVER = 22 characters
  1241   # Get the padding
  1242   string(LENGTH ${_OPT} _OPTLEN)
  1243   math(EXPR _PADLEN "23 - ${_OPTLEN}")
  1244   string(RANDOM LENGTH ${_PADLEN} ALPHABET " " _PADDING)
  1245   message_tested_option(${_OPT} ${_PADDING})
  1246 endforeach()
  1247 message(STATUS "")
  1248 message(STATUS " CFLAGS:        ${CMAKE_C_FLAGS}")
  1249 message(STATUS " EXTRA_CFLAGS:  ${EXTRA_CFLAGS}")
  1250 message(STATUS " EXTRA_LDFLAGS: ${EXTRA_LDFLAGS}")
  1251 message(STATUS " EXTRA_LIBS:    ${EXTRA_LIBS}")
  1252 message(STATUS "")
  1253 message(STATUS " Build Shared Library: ${SDL_SHARED}")
  1254 message(STATUS " Build Static Library: ${SDL_STATIC}")
  1255 message(STATUS "")
  1256 if(UNIX)
  1257   message(STATUS "If something was not detected, although the libraries")
  1258   message(STATUS "were installed, then make sure you have set the")
  1259   message(STATUS "CFLAGS and LDFLAGS environment variables correctly.")
  1260   message(STATUS "")
  1261 endif()
  1262 
  1263 # Ensure that the extra cflags are used at compile time
  1264 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
  1265 
  1266 # Always build SDLmain
  1267 add_library(SDL2main STATIC ${SDLMAIN_SOURCES})
  1268 set(_INSTALL_LIBS "SDL2main")
  1269 
  1270 if(SDL_SHARED)
  1271   add_library(SDL2 SHARED ${SOURCE_FILES})
  1272   if(UNIX)
  1273     set_target_properties(SDL2 PROPERTIES
  1274       VERSION ${LT_VERSION}
  1275       SOVERSION ${LT_REVISION}
  1276       OUTPUT_NAME "SDL2-${LT_RELEASE}")
  1277   else(UNIX)
  1278     set_target_properties(SDL2 PROPERTIES
  1279       VERSION ${SDL_VERSION}
  1280       SOVERSION ${LT_REVISION}
  1281       OUTPUT_NAME "SDL2")
  1282   endif()
  1283  set(_INSTALL_LIBS "SDL2" ${_INSTALL_LIBS})
  1284  target_link_libraries(SDL2 ${EXTRA_LIBS} ${EXTRA_LDFLAGS})
  1285 endif()
  1286 
  1287 if(SDL_STATIC)
  1288   set (BUILD_SHARED_LIBS FALSE)
  1289   add_library(SDL2-static STATIC ${SOURCE_FILES})
  1290   set_target_properties(SDL2-static PROPERTIES OUTPUT_NAME "SDL2")
  1291   if(MSVC)
  1292     set_target_properties(SDL2-static PROPERTIES LINK_FLAGS_RELEASE "/NODEFAULTLIB")
  1293     set_target_properties(SDL2-static PROPERTIES LINK_FLAGS_DEBUG "/NODEFAULTLIB")
  1294     set_target_properties(SDL2-static PROPERTIES STATIC_LIBRARY_FLAGS "/NODEFAULTLIB")
  1295   endif()
  1296   # TODO: Win32 platforms keep the same suffix .lib for import and static
  1297   # libraries - do we need to consider this?
  1298   set(_INSTALL_LIBS "SDL2-static" ${_INSTALL_LIBS})
  1299   target_link_libraries(SDL2-static ${EXTRA_LIBS} ${EXTRA_LDFLAGS})
  1300 endif()
  1301 
  1302 ##### Installation targets #####
  1303 install(TARGETS ${_INSTALL_LIBS}
  1304   LIBRARY DESTINATION "lib${LIB_SUFFIX}"
  1305   ARCHIVE DESTINATION "lib${LIB_SUFFIX}")
  1306 
  1307 file(GLOB INCLUDE_FILES ${SDL2_SOURCE_DIR}/include/*.h)
  1308 file(GLOB BIN_INCLUDE_FILES ${SDL2_BINARY_DIR}/include/*.h)
  1309 foreach(_FNAME ${BIN_INCLUDE_FILES})
  1310   get_filename_component(_INCNAME ${_FNAME} NAME)
  1311   list(REMOVE_ITEM INCLUDE_FILES ${SDL2_SOURCE_DIR}/include/${_INCNAME})
  1312 endforeach()
  1313 list(APPEND INCLUDE_FILES ${BIN_INCLUDE_FILES})
  1314 install(FILES ${INCLUDE_FILES} DESTINATION include/SDL2)
  1315 
  1316 if(NOT WINDOWS OR CYGWIN)
  1317   if(SDL_SHARED)
  1318     install(CODE "
  1319       execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink
  1320       \"libSDL2-2.0.so\" \"libSDL2.so\")")
  1321     install(FILES ${SDL2_BINARY_DIR}/libSDL2.so DESTINATION "lib${LIB_SUFFIX}")
  1322   endif()
  1323   if(FREEBSD)
  1324     # FreeBSD uses ${PREFIX}/libdata/pkgconfig
  1325     install(FILES ${SDL2_BINARY_DIR}/sdl2.pc DESTINATION "libdata/pkgconfig")
  1326   else(FREEBSD)
  1327     install(FILES ${SDL2_BINARY_DIR}/sdl2.pc
  1328       DESTINATION "lib${LIB_SUFFIX}/pkgconfig")
  1329   endif()
  1330   install(PROGRAMS ${SDL2_BINARY_DIR}/sdl2-config DESTINATION bin)
  1331   # TODO: what about the .spec file? Is it only needed for RPM creation?
  1332   install(FILES "${SDL2_SOURCE_DIR}/sdl2.m4" DESTINATION "share/aclocal")
  1333 else()
  1334   if(SDL_SHARED)
  1335     install(TARGETS SDL2 RUNTIME DESTINATION bin)
  1336   endif()
  1337 endif()
  1338 
  1339 ##### Uninstall target #####
  1340 
  1341 configure_file(
  1342     "${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
  1343     "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
  1344     IMMEDIATE @ONLY)
  1345 
  1346 add_custom_target(uninstall
  1347     COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)