CMakeLists.txt
author Sam Lantinga <slouken@libsdl.org>
Sat, 16 Aug 2014 23:28:40 -0700
changeset 9077 28e6de55eb07
parent 9075 257a6793aaf5
child 9080 2e4e71ec140f
permissions -rw-r--r--
Fixed bug 2683 - Raspberry PI support using CMake

Tobias Himmer

this patch adds a check to the CMake build script to detect whether the VideoCore API is available.
If it is found, it enables SDL_VIDEO_DRIVER_RPI and will also add the needed include/library directory flags to CMAKE_C_FLAGS so the subsequent check for GLES succeeds in picking up the headers.

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