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