CMakeLists.txt
author Philipp Wiesemann <philipp.wiesemann@arcor.de>
Sat, 06 Sep 2014 23:20:14 +0200
changeset 9125 e004bdb812ce
parent 9121 00d99eff96a6
child 9127 a8c38ed1a674
permissions -rw-r--r--
Fixed example in header file.

Did not compile because of typo in function name and missing argument.
     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 4)
    33 set(SDL_INTERFACE_AGE 0)
    34 set(SDL_BINARY_AGE 4)
    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     set(SDL_FRAMEWORK_COREVIDEO 1)
   974   else()
   975     message_error("SDL_FILE must be enabled to build on MacOS X")
   976   endif()
   977 
   978   if(SDL_AUDIO)
   979     set(MACOSX_COREAUDIO 1)
   980     file(GLOB AUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/coreaudio/*.c)
   981     set(SOURCE_FILES ${SOURCE_FILES} ${AUDIO_SOURCES})
   982     set(HAVE_SDL_AUDIO TRUE)
   983     set(SDL_FRAMEWORK_COREAUDIO 1)
   984     set(SDL_FRAMEWORK_AUDIOUNIT 1)
   985   endif()
   986 
   987   if(SDL_JOYSTICK)
   988     set(SDL_JOYSTICK_IOKIT 1)
   989     file(GLOB JOYSTICK_SOURCES ${SDL2_SOURCE_DIR}/src/joystick/darwin/*.c)
   990     set(SOURCE_FILES ${SOURCE_FILES} ${JOYSTICK_SOURCES})
   991     set(HAVE_SDL_JOYSTICK TRUE)
   992     set(SDL_FRAMEWORK_IOKIT 1)
   993     set(SDL_FRAMEWORK_FF 1)
   994   endif()
   995 
   996   if(SDL_HAPTIC)
   997     set(SDL_HAPTIC_IOKIT 1)
   998     file(GLOB HAPTIC_SOURCES ${SDL2_SOURCE_DIR}/src/haptic/darwin/*.c)
   999     set(SOURCE_FILES ${SOURCE_FILES} ${HAPTIC_SOURCES})
  1000     set(HAVE_SDL_HAPTIC TRUE)
  1001     set(SDL_FRAMEWORK_IOKIT 1)
  1002     set(SDL_FRAMEWORK_FF 1)
  1003     if(NOT SDL_JOYSTICK)
  1004       message(FATAL_ERROR "SDL_HAPTIC requires SDL_JOYSTICK to be enabled")
  1005     endif()
  1006   endif()
  1007 
  1008   if(SDL_POWER)
  1009     set(SDL_POWER_MACOSX 1)
  1010     file(GLOB POWER_SOURCES ${SDL2_SOURCE_DIR}/src/power/macosx/*.c)
  1011     set(SOURCE_FILES ${SOURCE_FILES} ${POWER_SOURCES})
  1012     set(HAVE_SDL_POWER TRUE)
  1013     set(SDL_FRAMEWORK_CARBON 1)
  1014     set(SDL_FRAMEWORK_IOKIT 1)
  1015   endif()
  1016 
  1017   if(SDL_TIMERS)
  1018     set(SDL_TIMER_UNIX 1)
  1019     file(GLOB TIMER_SOURCES ${SDL2_SOURCE_DIR}/src/timer/unix/*.c)
  1020     set(SOURCE_FILES ${SOURCE_FILES} ${TIMER_SOURCES})
  1021     set(HAVE_SDL_TIMERS TRUE)
  1022   endif(SDL_TIMERS)
  1023 
  1024   if(SDL_FILESYSTEM)
  1025     set(SDL_FILESYSTEM_COCOA 1)
  1026     file(GLOB FILESYSTEM_SOURCES ${SDL2_SOURCE_DIR}/src/filesystem/cocoa/*.m)
  1027     set_source_files_properties(${FILESYSTEM_SOURCES} PROPERTIES LANGUAGE C)
  1028     set(SOURCE_FILES ${SOURCE_FILES} ${FILESYSTEM_SOURCES})
  1029     set(HAVE_SDL_FILESYSTEM TRUE)
  1030   endif()
  1031 
  1032   # Actually load the frameworks at the end so we don't duplicate include.
  1033   if(SDL_FRAMEWORK_COREVIDEO)
  1034     find_library(COREVIDEO CoreVideo)
  1035     list(APPEND EXTRA_LIBS ${COREVIDEO})
  1036   endif()
  1037   if(SDL_FRAMEWORK_COCOA)
  1038     find_library(COCOA_LIBRARY Cocoa)
  1039     list(APPEND EXTRA_LIBS ${COCOA_LIBRARY})
  1040   endif()
  1041   if(SDL_FRAMEWORK_IOKIT)
  1042     find_library(IOKIT IOKit)
  1043     list(APPEND EXTRA_LIBS ${IOKIT})
  1044   endif()
  1045   if(SDL_FRAMEWORK_FF)
  1046     find_library(FORCEFEEDBACK ForceFeedback)
  1047     list(APPEND EXTRA_LIBS ${FORCEFEEDBACK})
  1048   endif()
  1049   if(SDL_FRAMEWORK_CARBON)
  1050     find_library(CARBON_LIBRARY Carbon)
  1051     list(APPEND EXTRA_LIBS ${CARBON_LIBRARY})
  1052   endif()
  1053   if(SDL_FRAMEWORK_COREAUDIO)
  1054     find_library(COREAUDIO CoreAudio)
  1055     list(APPEND EXTRA_LIBS ${COREAUDIO})
  1056   endif()
  1057   if(SDL_FRAMEWORK_AUDIOUNIT)
  1058     find_library(AUDIOUNIT AudioUnit)
  1059     list(APPEND EXTRA_LIBS ${AUDIOUNIT})
  1060   endif()
  1061 
  1062   # iOS hack needed - http://code.google.com/p/ios-cmake/ ?
  1063   if(SDL_VIDEO)
  1064     CheckCOCOA()
  1065     if(VIDEO_OPENGL)
  1066       set(SDL_VIDEO_OPENGL 1)
  1067       set(SDL_VIDEO_OPENGL_CGL 1)
  1068       set(SDL_VIDEO_RENDER_OGL 1)
  1069       if(DARWIN)
  1070         find_library(OpenGL_LIBRARY OpenGL)
  1071         list(APPEND EXTRA_LIBRARIES ${OpenGL_LIBRARY})
  1072       endif()
  1073       set(HAVE_VIDEO_OPENGL TRUE)
  1074     endif()
  1075   endif()
  1076 
  1077   CheckPTHREAD()
  1078 elseif(HAIKU)
  1079   if(SDL_VIDEO)
  1080     set(SDL_VIDEO_DRIVER_HAIKU 1)
  1081     file(GLOB HAIKUVIDEO_SOURCES ${SDL2_SOURCE_DIR}/src/video/haiku/*.c)
  1082     set(SOURCE_FILES ${SOURCE_FILES} ${HAIKUVIDEO_SOURCES})
  1083     set(HAVE_SDL_VIDEO TRUE)
  1084 
  1085     set(SDL_FILESYSTEM_HAIKU 1)
  1086     file(GLOB FILESYSTEM_SOURCES ${SDL2_SOURCE_DIR}/src/filesystem/haiku/*.cc)
  1087     set(SOURCE_FILES ${SOURCE_FILES} ${FILESYSTEM_SOURCES})
  1088     set(HAVE_SDL_FILESYSTEM TRUE)
  1089 
  1090     if(SDL_TIMERS)
  1091       set(SDL_TIMER_HAIKU 1)
  1092       file(GLOB TIMER_SOURCES ${SDL2_SOURCE_DIR}/src/timer/haiku/*.c)
  1093       set(SOURCE_FILES ${SOURCE_FILES} ${TIMER_SOURCES})
  1094       set(HAVE_SDL_TIMERS TRUE)
  1095     endif(SDL_TIMERS)
  1096 
  1097     if(VIDEO_OPENGL)
  1098       # TODO: Use FIND_PACKAGE(OpenGL) instead
  1099       set(SDL_VIDEO_OPENGL 1)
  1100       set(SDL_VIDEO_OPENGL_BGL 1)
  1101       set(SDL_VIDEO_RENDER_OGL 1)
  1102       list(APPEND EXTRA_LIBS GL)
  1103       set(HAVE_VIDEO_OPENGL TRUE)
  1104     endif()
  1105   endif()
  1106 
  1107   CheckPTHREAD()
  1108 endif()
  1109 
  1110 # Dummies
  1111 # configure.in does it differently:
  1112 # if not have X
  1113 #   if enable_X {  SDL_X_DISABLED = 1 }
  1114 #   [add dummy sources]
  1115 # so it always adds a dummy, without checking, if it was actually requested.
  1116 # This leads to missing internal references on building, since the
  1117 # src/X/*.c does not get included.
  1118 if(NOT HAVE_SDL_JOYSTICK)
  1119   set(SDL_JOYSTICK_DISABLED 1)
  1120   if(SDL_JOYSTICK AND NOT APPLE) # results in unresolved symbols on OSX
  1121 
  1122     file(GLOB JOYSTICK_SOURCES ${SDL2_SOURCE_DIR}/src/joystick/dummy/*.c)
  1123     set(SOURCE_FILES ${SOURCE_FILES} ${JOYSTICK_SOURCES})
  1124   endif()
  1125 endif()
  1126 if(NOT HAVE_SDL_HAPTIC)
  1127   set(SDL_HAPTIC_DISABLED 1)
  1128   file(GLOB HAPTIC_SOURCES ${SDL2_SOURCE_DIR}/src/haptic/dummy/*.c)
  1129   set(SOURCE_FILES ${SOURCE_FILES} ${HAPTIC_SOURCES})
  1130 endif()
  1131 if(NOT HAVE_SDL_LOADSO)
  1132   set(SDL_LOADSO_DISABLED 1)
  1133   file(GLOB LOADSO_SOURCES ${SDL2_SOURCE_DIR}/src/loadso/dummy/*.c)
  1134   set(SOURCE_FILES ${SOURCE_FILES} ${LOADSO_SOURCES})
  1135 endif()
  1136 if(NOT HAVE_SDL_FILESYSTEM)
  1137   set(SDL_FILESYSTEM_DISABLED 1)
  1138   file(GLOB FILESYSTEM_SOURCES ${SDL2_SOURCE_DIR}/src/filesystem/dummy/*.c)
  1139   set(SOURCE_FILES ${SOURCE_FILES} ${FILESYSTEM_SOURCES})
  1140 endif()
  1141 
  1142 # We always need to have threads and timers around
  1143 if(NOT HAVE_SDL_THREADS)
  1144   set(SDL_THREADS_DISABLED 1)
  1145   file(GLOB THREADS_SOURCES ${SDL2_SOURCE_DIR}/src/thread/generic/*.c)
  1146   set(SOURCE_FILES ${SOURCE_FILES} ${THREADS_SOURCES})
  1147 endif()
  1148 if(NOT HAVE_SDL_TIMERS)
  1149   set(SDL_TIMERS_DISABLED 1)
  1150   file(GLOB TIMER_SOURCES ${SDL2_SOURCE_DIR}/src/timer/dummy/*.c)
  1151   set(SOURCE_FILES ${SOURCE_FILES} ${TIMER_SOURCES})
  1152 endif()
  1153 
  1154 if(NOT SDLMAIN_SOURCES)
  1155   file(GLOB SDLMAIN_SOURCES ${SDL2_SOURCE_DIR}/src/main/dummy/*.c)
  1156 endif()
  1157 
  1158 # Append the -MMD -MT flags
  1159 # if(DEPENDENCY_TRACKING)
  1160 #   if(COMPILER_IS_GNUCC)
  1161 #     set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -MMD -MT \$@")
  1162 #   endif()
  1163 # endif()
  1164 
  1165 configure_file("${SDL2_SOURCE_DIR}/include/SDL_config.h.cmake"
  1166   "${SDL2_BINARY_DIR}/include/SDL_config.h")
  1167 
  1168 # Prepare the flags and remove duplicates
  1169 if(EXTRA_LDFLAGS)
  1170   list(REMOVE_DUPLICATES EXTRA_LDFLAGS)
  1171 endif()
  1172 if(EXTRA_LIBS)
  1173   list(REMOVE_DUPLICATES EXTRA_LIBS)
  1174 endif()
  1175 if(EXTRA_CFLAGS)
  1176   list(REMOVE_DUPLICATES EXTRA_CFLAGS)
  1177 endif()
  1178 listtostr(EXTRA_CFLAGS _EXTRA_CFLAGS)
  1179 set(EXTRA_CFLAGS ${_EXTRA_CFLAGS})
  1180 
  1181 # Compat helpers for the configuration files
  1182 if(NOT WINDOWS OR CYGWIN)
  1183   # TODO: we need a Windows script, too
  1184   execute_process(COMMAND sh ${SDL2_SOURCE_DIR}/build-scripts/updaterev.sh)
  1185 
  1186   set(prefix ${CMAKE_INSTALL_PREFIX})
  1187   set(exec_prefix "\${prefix}")
  1188   set(libdir "\${exec_prefix}/lib${LIB_SUFFIX}")
  1189   set(bindir "\${exec_prefix}/bin")
  1190   set(includedir "\${prefix}/include")
  1191   if(SDL_STATIC)
  1192     set(ENABLE_STATIC_TRUE "")
  1193     set(ENABLE_STATIC_FALSE "#")
  1194   else(SDL_STATIC)
  1195     set(ENABLE_STATIC_TRUE "#")
  1196     set(ENABLE_STATIC_FALSE "")
  1197   endif()
  1198   if(SDL_SHARED)
  1199     set(ENABLE_SHARED_TRUE "")
  1200     set(ENABLE_SHARED_FALSE "#")
  1201   else(SDL_SHARED)
  1202     set(ENABLE_SHARED_TRUE "#")
  1203     set(ENABLE_SHARED_FALSE "")
  1204   endif()
  1205 
  1206   # Clean up the different lists
  1207   listtostr(EXTRA_LIBS _EXTRA_LIBS "-l")
  1208   set(SDL_STATIC_LIBS ${SDL_LIBS} ${EXTRA_LDFLAGS} ${_EXTRA_LIBS})
  1209   list(REMOVE_DUPLICATES SDL_STATIC_LIBS)
  1210   listtostr(SDL_STATIC_LIBS _SDL_STATIC_LIBS)
  1211   set(SDL_STATIC_LIBS ${_SDL_STATIC_LIBS})
  1212   listtostr(SDL_LIBS _SDL_LIBS)
  1213   set(SDL_LIBS ${_SDL_LIBS})
  1214 
  1215   # MESSAGE(STATUS "SDL_LIBS: ${SDL_LIBS}")
  1216   # MESSAGE(STATUS "SDL_STATIC_LIBS: ${SDL_STATIC_LIBS}")
  1217 
  1218   configure_file("${SDL2_SOURCE_DIR}/sdl2.pc.in"
  1219     "${SDL2_BINARY_DIR}/sdl2.pc" @ONLY)
  1220   configure_file("${SDL2_SOURCE_DIR}/sdl2-config.in"
  1221     "${SDL2_BINARY_DIR}/sdl2-config")
  1222   configure_file("${SDL2_SOURCE_DIR}/sdl2-config.in"
  1223     "${SDL2_BINARY_DIR}/sdl2-config" @ONLY)
  1224   configure_file("${SDL2_SOURCE_DIR}/SDL2.spec.in"
  1225     "${SDL2_BINARY_DIR}/SDL2.spec" @ONLY)
  1226 endif()
  1227 
  1228 ##### Info output #####
  1229 message(STATUS "")
  1230 message(STATUS "SDL2 was configured with the following options:")
  1231 message(STATUS "")
  1232 message(STATUS "Platform: ${CMAKE_SYSTEM}")
  1233 message(STATUS "64-bit:   ${ARCH_64}")
  1234 message(STATUS "Compiler: ${CMAKE_C_COMPILER}")
  1235 message(STATUS "")
  1236 message(STATUS "Subsystems:")
  1237 foreach(_SUB ${SDL_SUBSYSTEMS})
  1238   string(TOUPPER ${_SUB} _OPT)
  1239   message_bool_option(${_SUB} SDL_${_OPT})
  1240 endforeach()
  1241 message(STATUS "")
  1242 message(STATUS "Options:")
  1243 list(SORT ALLOPTIONS)
  1244 foreach(_OPT ${ALLOPTIONS})
  1245   # Longest option is VIDEO_X11_XSCREENSAVER = 22 characters
  1246   # Get the padding
  1247   string(LENGTH ${_OPT} _OPTLEN)
  1248   math(EXPR _PADLEN "23 - ${_OPTLEN}")
  1249   string(RANDOM LENGTH ${_PADLEN} ALPHABET " " _PADDING)
  1250   message_tested_option(${_OPT} ${_PADDING})
  1251 endforeach()
  1252 message(STATUS "")
  1253 message(STATUS " CFLAGS:        ${CMAKE_C_FLAGS}")
  1254 message(STATUS " EXTRA_CFLAGS:  ${EXTRA_CFLAGS}")
  1255 message(STATUS " EXTRA_LDFLAGS: ${EXTRA_LDFLAGS}")
  1256 message(STATUS " EXTRA_LIBS:    ${EXTRA_LIBS}")
  1257 message(STATUS "")
  1258 message(STATUS " Build Shared Library: ${SDL_SHARED}")
  1259 message(STATUS " Build Static Library: ${SDL_STATIC}")
  1260 message(STATUS "")
  1261 if(UNIX)
  1262   message(STATUS "If something was not detected, although the libraries")
  1263   message(STATUS "were installed, then make sure you have set the")
  1264   message(STATUS "CFLAGS and LDFLAGS environment variables correctly.")
  1265   message(STATUS "")
  1266 endif()
  1267 
  1268 # Ensure that the extra cflags are used at compile time
  1269 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
  1270 
  1271 # Always build SDLmain
  1272 add_library(SDL2main STATIC ${SDLMAIN_SOURCES})
  1273 set(_INSTALL_LIBS "SDL2main")
  1274 
  1275 if(SDL_SHARED)
  1276   add_library(SDL2 SHARED ${SOURCE_FILES})
  1277   if(UNIX)
  1278     set_target_properties(SDL2 PROPERTIES
  1279       VERSION ${LT_VERSION}
  1280       SOVERSION ${LT_REVISION}
  1281       OUTPUT_NAME "SDL2-${LT_RELEASE}")
  1282   else(UNIX)
  1283     set_target_properties(SDL2 PROPERTIES
  1284       VERSION ${SDL_VERSION}
  1285       SOVERSION ${LT_REVISION}
  1286       OUTPUT_NAME "SDL2")
  1287   endif()
  1288  set(_INSTALL_LIBS "SDL2" ${_INSTALL_LIBS})
  1289  target_link_libraries(SDL2 ${EXTRA_LIBS} ${EXTRA_LDFLAGS})
  1290 endif()
  1291 
  1292 if(SDL_STATIC)
  1293   set (BUILD_SHARED_LIBS FALSE)
  1294   add_library(SDL2-static STATIC ${SOURCE_FILES})
  1295   set_target_properties(SDL2-static PROPERTIES OUTPUT_NAME "SDL2")
  1296   if(MSVC)
  1297     set_target_properties(SDL2-static PROPERTIES LINK_FLAGS_RELEASE "/NODEFAULTLIB")
  1298     set_target_properties(SDL2-static PROPERTIES LINK_FLAGS_DEBUG "/NODEFAULTLIB")
  1299     set_target_properties(SDL2-static PROPERTIES STATIC_LIBRARY_FLAGS "/NODEFAULTLIB")
  1300   endif()
  1301   # TODO: Win32 platforms keep the same suffix .lib for import and static
  1302   # libraries - do we need to consider this?
  1303   set(_INSTALL_LIBS "SDL2-static" ${_INSTALL_LIBS})
  1304   target_link_libraries(SDL2-static ${EXTRA_LIBS} ${EXTRA_LDFLAGS})
  1305 endif()
  1306 
  1307 ##### Installation targets #####
  1308 install(TARGETS ${_INSTALL_LIBS}
  1309   LIBRARY DESTINATION "lib${LIB_SUFFIX}"
  1310   ARCHIVE DESTINATION "lib${LIB_SUFFIX}")
  1311 
  1312 file(GLOB INCLUDE_FILES ${SDL2_SOURCE_DIR}/include/*.h)
  1313 file(GLOB BIN_INCLUDE_FILES ${SDL2_BINARY_DIR}/include/*.h)
  1314 foreach(_FNAME ${BIN_INCLUDE_FILES})
  1315   get_filename_component(_INCNAME ${_FNAME} NAME)
  1316   list(REMOVE_ITEM INCLUDE_FILES ${SDL2_SOURCE_DIR}/include/${_INCNAME})
  1317 endforeach()
  1318 list(APPEND INCLUDE_FILES ${BIN_INCLUDE_FILES})
  1319 install(FILES ${INCLUDE_FILES} DESTINATION include/SDL2)
  1320 
  1321 if(NOT WINDOWS OR CYGWIN)
  1322   if(SDL_SHARED)
  1323     install(CODE "
  1324       execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink
  1325       \"libSDL2-2.0.so\" \"libSDL2.so\")")
  1326     install(FILES ${SDL2_BINARY_DIR}/libSDL2.so DESTINATION "lib${LIB_SUFFIX}")
  1327   endif()
  1328   if(FREEBSD)
  1329     # FreeBSD uses ${PREFIX}/libdata/pkgconfig
  1330     install(FILES ${SDL2_BINARY_DIR}/sdl2.pc DESTINATION "libdata/pkgconfig")
  1331   else(FREEBSD)
  1332     install(FILES ${SDL2_BINARY_DIR}/sdl2.pc
  1333       DESTINATION "lib${LIB_SUFFIX}/pkgconfig")
  1334   endif()
  1335   install(PROGRAMS ${SDL2_BINARY_DIR}/sdl2-config DESTINATION bin)
  1336   # TODO: what about the .spec file? Is it only needed for RPM creation?
  1337   install(FILES "${SDL2_SOURCE_DIR}/sdl2.m4" DESTINATION "share/aclocal")
  1338 else()
  1339   if(SDL_SHARED)
  1340     install(TARGETS SDL2 RUNTIME DESTINATION bin)
  1341   endif()
  1342 endif()
  1343 
  1344 ##### Uninstall target #####
  1345 
  1346 configure_file(
  1347     "${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
  1348     "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
  1349     IMMEDIATE @ONLY)
  1350 
  1351 add_custom_target(uninstall
  1352     COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)