message(FATAL_ERROR "Prevented in-tree built. Please create a build directory outside of the SDL source code and call cmake from there")
endif()
-cmake_minimum_required(VERSION 2.8)
+cmake_minimum_required(VERSION 2.8.11)
project(SDL2 C)
+
+# !!! FIXME: this should probably do "MACOSX_RPATH ON" as a target property
+# !!! FIXME: for the SDL2 shared library (so you get an
+# !!! FIXME: install_name ("soname") of "@rpath/libSDL-whatever.dylib"
+# !!! FIXME: instead of "/usr/local/lib/libSDL-whatever.dylib"), but I'm
+# !!! FIXME: punting for now and leaving the existing behavior. Until this
+# !!! FIXME: properly resolved, this line silences a warning in CMake 3.0+.
+# !!! FIXME: remove it and this comment entirely once the problem is
+# !!! FIXME: properly resolved.
+#cmake_policy(SET CMP0042 OLD)
+
include(CheckFunctionExists)
include(CheckLibraryExists)
include(CheckIncludeFiles)
include(CheckIncludeFile)
include(CheckSymbolExists)
+include(CheckCSourceCompiles)
include(CheckCSourceRuns)
include(CheckCCompilerFlag)
include(CheckTypeSize)
include(CheckStructHasMember)
include(CMakeDependentOption)
include(FindPkgConfig)
+include(GNUInstallDirs)
set(CMAKE_MODULE_PATH "${SDL2_SOURCE_DIR}/cmake")
include(${SDL2_SOURCE_DIR}/cmake/macros.cmake)
include(${SDL2_SOURCE_DIR}/cmake/sdlchecks.cmake)
# set SDL_BINARY_AGE and SDL_INTERFACE_AGE to 0.
set(SDL_MAJOR_VERSION 2)
set(SDL_MINOR_VERSION 0)
-set(SDL_MICRO_VERSION 4)
+set(SDL_MICRO_VERSION 8)
set(SDL_INTERFACE_AGE 0)
-set(SDL_BINARY_AGE 4)
+set(SDL_BINARY_AGE 8)
set(SDL_VERSION "${SDL_MAJOR_VERSION}.${SDL_MINOR_VERSION}.${SDL_MICRO_VERSION}")
+# Set defaults preventing destination file conflicts
+set(SDL_CMAKE_DEBUG_POSTFIX "d"
+ CACHE STRING "Name suffix for debug builds")
+
+mark_as_advanced(CMAKE_IMPORT_LIBRARY_SUFFIX SDL_CMAKE_DEBUG_POSTFIX)
+
# Calculate a libtool-like version number
math(EXPR LT_CURRENT "${SDL_MICRO_VERSION} - ${SDL_INTERFACE_AGE}")
math(EXPR LT_AGE "${SDL_BINARY_AGE} - ${SDL_INTERFACE_AGE}")
# Default option knobs
if(APPLE OR ARCH_64)
- set(OPT_DEF_SSEMATH ON)
+ if(NOT "${CMAKE_OSX_ARCHITECTURES}" MATCHES "arm")
+ set(OPT_DEF_SSEMATH ON)
+ endif()
endif()
if(UNIX OR MINGW OR MSYS)
set(OPT_DEF_LIBC ON)
set(OPT_DEF_ASM FALSE)
endif()
+if(USE_GCC OR USE_CLANG)
+ set(OPT_DEF_GCC_ATOMICS ON)
+endif()
+
# Default flags, if not set otherwise
if("$ENV{CFLAGS}" STREQUAL "")
- if(USE_GCC OR USE_CLANG)
- set(CMAKE_C_FLAGS "-g -O3")
+ if(CMAKE_BUILD_TYPE STREQUAL "")
+ if(USE_GCC OR USE_CLANG)
+ set(CMAKE_C_FLAGS "-g -O3")
+ endif()
endif()
else()
set(CMAKE_C_FLAGS "$ENV{CFLAGS}")
if(CYGWIN)
# We build SDL on cygwin without the UNIX emulation layer
include_directories("-I/usr/include/mingw")
- set(CMAKE_REQUIRED_FLAGS "-mno-cygwin")
+ set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -mno-cygwin")
check_c_source_compiles("int main(int argc, char **argv) {}"
HAVE_GCC_NO_CYGWIN)
set(CMAKE_REQUIRED_FLAGS ${ORIG_CMAKE_REQUIRED_FLAGS})
add_definitions(-DUSING_GENERATED_CONFIG_H)
# General includes
include_directories(${SDL2_BINARY_DIR}/include ${SDL2_SOURCE_DIR}/include)
+if(USE_GCC OR USE_CLANG)
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -idirafter ${SDL2_SOURCE_DIR}/src/video/khronos")
+else()
+ include_directories(${SDL2_SOURCE_DIR}/src/video/khronos)
+endif()
# All these ENABLED_BY_DEFAULT vars will default to ON if not specified, so
# you only need to have a platform override them if they are disabling.
option_string(ASSERTIONS "Enable internal sanity checks (auto/disabled/release/enabled/paranoid)" "auto")
#set_option(DEPENDENCY_TRACKING "Use gcc -MMD -MT dependency tracking" ON)
set_option(LIBC "Use the system C library" ${OPT_DEF_LIBC})
-set_option(GCC_ATOMICS "Use gcc builtin atomics" ${USE_GCC})
+set_option(GCC_ATOMICS "Use gcc builtin atomics" ${OPT_DEF_GCC_ATOMICS})
set_option(ASSEMBLY "Enable assembly routines" ${OPT_DEF_ASM})
set_option(SSEMATH "Allow GCC to use SSE floating point math" ${OPT_DEF_SSEMATH})
set_option(MMX "Use MMX assembly routines" ${OPT_DEF_ASM})
set_option(3DNOW "Use 3Dnow! MMX assembly routines" ${OPT_DEF_ASM})
set_option(SSE "Use SSE assembly routines" ${OPT_DEF_ASM})
set_option(SSE2 "Use SSE2 assembly routines" ${OPT_DEF_SSEMATH})
+set_option(SSE3 "Use SSE3 assembly routines" ${OPT_DEF_SSEMATH})
set_option(ALTIVEC "Use Altivec assembly routines" ${OPT_DEF_ASM})
set_option(DISKAUDIO "Support the disk writer audio driver" ON)
set_option(DUMMYAUDIO "Support the dummy audio driver" ON)
set_option(VIDEO_DIRECTFB "Use DirectFB video driver" OFF)
dep_option(DIRECTFB_SHARED "Dynamically load directfb support" ON "VIDEO_DIRECTFB" OFF)
-set_option(FUSIONSOUND "Use FusionSound audio driver" OFF)
-dep_option(FUSIONSOUND_SHARED "Dynamically load fusionsound audio support" ON "FUSIONSOUND" OFF)
set_option(VIDEO_DUMMY "Use dummy video driver" ON)
set_option(VIDEO_OPENGL "Include OpenGL support" ON)
set_option(VIDEO_OPENGLES "Include OpenGL ES support" ON)
-set_option(VIDEO_VULKAN "Include vulkan support" ON)
set_option(PTHREADS "Use POSIX threads for multi-threading" ${SDL_PTHREADS_ENABLED_BY_DEFAULT})
dep_option(PTHREADS_SEM "Use pthread semaphores" ON "PTHREADS" OFF)
set_option(SDL_DLOPEN "Use dlopen for shared object loading" ${SDL_DLOPEN_ENABLED_BY_DEFAULT})
set_option(OSS "Support the OSS audio API" ${UNIX_SYS})
set_option(ALSA "Support the ALSA audio API" ${UNIX_SYS})
dep_option(ALSA_SHARED "Dynamically load ALSA audio support" ON "ALSA" OFF)
+set_option(JACK "Support the JACK audio API" ${UNIX_SYS})
+dep_option(JACK_SHARED "Dynamically load JACK audio support" ON "JACK" OFF)
set_option(ESD "Support the Enlightened Sound Daemon" ${UNIX_SYS})
dep_option(ESD_SHARED "Dynamically load ESD audio support" ON "ESD" OFF)
set_option(PULSEAUDIO "Use PulseAudio" ${UNIX_SYS})
set_option(NAS "Support the NAS audio API" ${UNIX_SYS})
set_option(NAS_SHARED "Dynamically load NAS audio API" ${UNIX_SYS})
set_option(SNDIO "Support the sndio audio API" ${UNIX_SYS})
+set_option(FUSIONSOUND "Use FusionSound audio driver" OFF)
+dep_option(FUSIONSOUND_SHARED "Dynamically load fusionsound audio support" ON "FUSIONSOUND" OFF)
+set_option(LIBSAMPLERATE "Use libsamplerate for audio rate conversion" ${UNIX_SYS})
+dep_option(LIBSAMPLERATE_SHARED "Dynamically load libsamplerate" ON "LIBSAMPLERATE" OFF)
set_option(RPATH "Use an rpath when linking SDL" ${UNIX_SYS})
set_option(CLOCK_GETTIME "Use clock_gettime() instead of gettimeofday()" OFF)
set_option(INPUT_TSLIB "Use the Touchscreen library for input" ${UNIX_SYS})
set_option(DIRECTX "Use DirectX for Windows audio/video" ${WINDOWS})
set_option(RENDER_D3D "Enable the Direct3D render driver" ${WINDOWS})
set_option(VIDEO_VIVANTE "Use Vivante EGL video driver" ${UNIX_SYS})
+dep_option(VIDEO_VULKAN "Enable Vulkan support" ON "ANDROID OR APPLE OR LINUX OR WINDOWS" OFF)
+set_option(VIDEO_KMSDRM "Use KMS DRM video driver" ${UNIX_SYS})
+dep_option(KMSDRM_SHARED "Dynamically load KMS DRM support" ON "VIDEO_KMSDRM" OFF)
# TODO: We should (should we?) respect cmake's ${BUILD_SHARED_LIBS} flag here
# The options below are for compatibility to configure's default behaviour.
set(SDL_SHARED ${SDL_SHARED_ENABLED_BY_DEFAULT} CACHE BOOL "Build a shared version of the library")
set(SDL_STATIC ON CACHE BOOL "Build a static version of the library")
+dep_option(SDL_STATIC_PIC "Static version of the library should be built with Position Independent Code" OFF "SDL_STATIC" OFF)
+set_option(SDL_TEST "Build the test directory" OFF)
+
# General source files
file(GLOB SOURCE_FILES
${SDL2_SOURCE_DIR}/src/*.c
${SDL2_SOURCE_DIR}/src/stdlib/*.c
${SDL2_SOURCE_DIR}/src/thread/*.c
${SDL2_SOURCE_DIR}/src/timer/*.c
- ${SDL2_SOURCE_DIR}/src/video/*.c)
+ ${SDL2_SOURCE_DIR}/src/video/*.c
+ ${SDL2_SOURCE_DIR}/src/video/yuv2rgb/*.c)
if(ASSERTIONS STREQUAL "auto")
# Compiler option evaluation
if(USE_GCC OR USE_CLANG)
+ # Check for -Wall first, so later things can override pieces of it.
+ check_c_compiler_flag(-Wall HAVE_GCC_WALL)
+ if(HAVE_GCC_WALL)
+ list(APPEND EXTRA_CFLAGS "-Wall")
+ if(HAIKU)
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-multichar")
+ endif()
+ endif()
+
+ check_c_compiler_flag(-Wdeclaration-after-statement HAVE_GCC_WDECLARATION_AFTER_STATEMENT)
+ if(HAVE_GCC_WDECLARATION_AFTER_STATEMENT)
+ check_c_compiler_flag(-Werror=declaration-after-statement HAVE_GCC_WERROR_DECLARATION_AFTER_STATEMENT)
+ if(HAVE_GCC_WERROR_DECLARATION_AFTER_STATEMENT)
+ list(APPEND EXTRA_CFLAGS "-Werror=declaration-after-statement")
+ endif()
+ list(APPEND EXTRA_CFLAGS "-Wdeclaration-after-statement")
+ endif()
+
if(DEPENDENCY_TRACKING)
check_c_source_compiles("
#if !defined(__GNUC__) || __GNUC__ < 3
endif()
set(CMAKE_REQUIRED_FLAGS ${ORIG_CMAKE_REQUIRED_FLAGS})
- check_c_compiler_flag(-Wall HAVE_GCC_WALL)
- if(HAVE_GCC_WALL)
- list(APPEND EXTRA_CFLAGS "-Wall")
- if(HAIKU)
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-multichar")
- endif()
- endif()
check_c_compiler_flag(-Wshadow HAVE_GCC_WSHADOW)
if(HAVE_GCC_WSHADOW)
list(APPEND EXTRA_CFLAGS "-Wshadow")
endif()
- set(CMAKE_REQUIRED_FLAGS "-Wl,--no-undefined")
- check_c_compiler_flag("" HAVE_NO_UNDEFINED)
- set(CMAKE_REQUIRED_FLAGS ${ORIG_CMAKE_REQUIRED_FLAGS})
- if(HAVE_NO_UNDEFINED)
- list(APPEND EXTRA_LDFLAGS "-Wl,--no-undefined")
+ if(APPLE)
+ list(APPEND EXTRA_LDFLAGS "-Wl,-undefined,error")
+ else()
+ set(CMAKE_REQUIRED_FLAGS "-Wl,--no-undefined")
+ check_c_compiler_flag("" HAVE_NO_UNDEFINED)
+ set(CMAKE_REQUIRED_FLAGS ${ORIG_CMAKE_REQUIRED_FLAGS})
+ if(HAVE_NO_UNDEFINED)
+ list(APPEND EXTRA_LDFLAGS "-Wl,--no-undefined")
+ endif()
endif()
endif()
set(CMAKE_REQUIRED_FLAGS ${ORIG_CMAKE_REQUIRED_FLAGS})
endif()
- if(SSEMATH)
- if(SSE OR SSE2)
+ if(SSE3)
+ set(CMAKE_REQUIRED_FLAGS "-msse3")
+ check_c_source_compiles("
+ #ifdef __MINGW32__
+ #include <_mingw.h>
+ #ifdef __MINGW64_VERSION_MAJOR
+ #include <intrin.h>
+ #else
+ #include <pmmintrin.h>
+ #endif
+ #else
+ #include <pmmintrin.h>
+ #endif
+ #ifndef __SSE3__
+ #error Assembler CPP flag not enabled
+ #endif
+ int main(int argc, char **argv) { }" HAVE_SSE3)
+ if(HAVE_SSE3)
+ list(APPEND EXTRA_CFLAGS "-msse3")
+ endif()
+ set(CMAKE_REQUIRED_FLAGS ${ORIG_CMAKE_REQUIRED_FLAGS})
+ endif()
+
+ if(NOT SSEMATH)
+ if(SSE OR SSE2 OR SSE3)
if(USE_GCC)
- list(APPEND EXTRA_CFLAGS "-mfpmath=387")
+ check_c_compiler_flag(-mfpmath=387 HAVE_FP_387)
+ if(HAVE_FP_387)
+ list(APPEND EXTRA_CFLAGS "-mfpmath=387")
+ endif()
endif()
set(HAVE_SSEMATH TRUE)
endif()
endif()
+ check_include_file("immintrin.h" HAVE_IMMINTRIN_H)
+
if(ALTIVEC)
set(CMAKE_REQUIRED_FLAGS "-maltivec")
check_c_source_compiles("
endif()
set(HAVE_SSE TRUE)
set(HAVE_SSE2 TRUE)
+ set(HAVE_SSE3 TRUE)
set(SDL_ASSEMBLY_ROUTINES 1)
endif()
# TODO:
#else()
# if(USE_GCC OR USE_CLANG)
-# list(APPEND EXTRA_CFLAGS "-mno-sse" "-mno-sse2" "-mno-mmx")
+# list(APPEND EXTRA_CFLAGS "-mno-sse" "-mno-sse2" "-mno-sse3" "-mno-mmx")
# endif()
endif()
if(LIBC)
if(WINDOWS AND NOT MINGW)
set(HAVE_LIBC TRUE)
- foreach(_HEADER stdio.h string.h ctype.h math.h)
+ foreach(_HEADER stdio.h string.h wchar.h ctype.h math.h limits.h)
string(TOUPPER "HAVE_${_HEADER}" _UPPER)
string(REPLACE "." "_" _HAVE_H ${_UPPER})
set(${_HAVE_H} 1)
set(HAVE_SIGNAL_H 1)
foreach(_FN
malloc calloc realloc free qsort abs memset memcpy memmove memcmp
+ wcslen wcscmp
strlen _strrev _strupr _strlwr strchr strrchr strstr itoa _ltoa
_ultoa strtol strtoul strtoll strtod atoi atof strcmp strncmp
- _stricmp _strnicmp sscanf atan atan2 acos asin ceil copysign cos
- cosf fabs floor log pow scalbn sin sinf sqrt sqrtf tan tanf)
+ _stricmp _strnicmp sscanf
+ acos acosf asin asinf atan atanf atan2 atan2f ceil ceilf
+ copysign copysignf cos cosf fabs fabsf floor floorf fmod fmodf
+ log logf log10 log10f pow powf scalbn scalbnf sin sinf sqrt sqrtf tan tanf)
string(TOUPPER ${_FN} _UPPER)
set(HAVE_${_UPPER} 1)
endforeach()
set(HAVE_LIBC TRUE)
check_include_file(sys/types.h HAVE_SYS_TYPES_H)
foreach(_HEADER
- stdio.h stdlib.h stddef.h stdarg.h malloc.h memory.h string.h
- strings.h inttypes.h stdint.h ctype.h math.h iconv.h signal.h)
+ stdio.h stdlib.h stddef.h stdarg.h malloc.h memory.h string.h limits.h
+ strings.h wchar.h inttypes.h stdint.h ctype.h math.h iconv.h signal.h libunwind.h)
string(TOUPPER "HAVE_${_HEADER}" _UPPER)
string(REPLACE "." "_" _HAVE_H ${_UPPER})
check_include_file("${_HEADER}" ${_HAVE_H})
foreach(_FN
strtod malloc calloc realloc free getenv setenv putenv unsetenv
qsort abs bcopy memset memcpy memmove memcmp strlen strlcpy strlcat
- strdup _strrev _strupr _strlwr strchr strrchr strstr itoa _ltoa
+ _strrev _strupr _strlwr strchr strrchr strstr itoa _ltoa
_uitoa _ultoa strtol strtoul _i64toa _ui64toa strtoll strtoull
atoi atof strcmp strncmp _stricmp strcasecmp _strnicmp strncasecmp
- vsscanf vsnprintf fseeko fseeko64 sigaction setjmp
- nanosleep sysconf sysctlbyname
+ vsscanf vsnprintf fopen64 fseeko fseeko64 sigaction setjmp
+ nanosleep sysconf sysctlbyname getauxval poll
)
string(TOUPPER ${_FN} _UPPER)
set(_HAVEVAR "HAVE_${_UPPER}")
if(ANDROID)
file(GLOB ANDROID_CORE_SOURCES ${SDL2_SOURCE_DIR}/src/core/android/*.c)
set(SOURCE_FILES ${SOURCE_FILES} ${ANDROID_CORE_SOURCES})
+
+ # SDL_spinlock.c Needs to be compiled in ARM mode.
+ # There seems to be no better way currently to set the ARM mode.
+ # see: https://issuetracker.google.com/issues/62264618
+ # Another option would be to set ARM mode to all compiled files
+ check_c_compiler_flag(-marm HAVE_ARM_MODE)
+ if(HAVE_ARM_MODE)
+ set_source_files_properties(${SDL2_SOURCE_DIR}/src/atomic/SDL_spinlock.c PROPERTIES COMPILE_FLAGS -marm)
+ endif()
+
file(GLOB ANDROID_MAIN_SOURCES ${SDL2_SOURCE_DIR}/src/main/android/*.c)
- set(SOURCE_FILES ${SOURCE_FILES} ${ANDROID_MAIN_SOURCES})
+ set(SDLMAIN_SOURCES ${SDLMAIN_SOURCES} ${ANDROID_MAIN_SOURCES})
+
if(SDL_AUDIO)
set(SDL_AUDIO_DRIVER_ANDROID 1)
file(GLOB ANDROID_AUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/android/*.c)
set(SOURCE_FILES ${SOURCE_FILES} ${ANDROID_FILESYSTEM_SOURCES})
set(HAVE_SDL_FILESYSTEM TRUE)
endif()
+ if(SDL_HAPTIC)
+ set(SDL_HAPTIC_ANDROID 1)
+ file(GLOB ANDROID_HAPTIC_SOURCES ${SDL2_SOURCE_DIR}/src/haptic/android/*.c)
+ set(SOURCE_FILES ${SOURCE_FILES} ${ANDROID_HAPTIC_SOURCES})
+ set(HAVE_SDL_HAPTIC TRUE)
+ endif()
if(SDL_JOYSTICK)
set(SDL_JOYSTICK_ANDROID 1)
- file(GLOB ANDROID_JOYSTICK_SOURCES ${SDL2_SOURCE_DIR}/src/joystick/android/*.c)
+ file(GLOB ANDROID_JOYSTICK_SOURCES ${SDL2_SOURCE_DIR}/src/joystick/android/*.c ${SDL2_SOURCE_DIR}/src/joystick/steam/*.c)
set(SOURCE_FILES ${SOURCE_FILES} ${ANDROID_JOYSTICK_SOURCES})
set(HAVE_SDL_JOYSTICK TRUE)
endif()
+ if(SDL_LOADSO)
+ set(SDL_LOADSO_DLOPEN 1)
+ file(GLOB LOADSO_SOURCES ${SDL2_SOURCE_DIR}/src/loadso/dlopen/*.c)
+ set(SOURCE_FILES ${SOURCE_FILES} ${LOADSO_SOURCES})
+ set(HAVE_SDL_LOADSO TRUE)
+ endif()
if(SDL_POWER)
set(SDL_POWER_ANDROID 1)
file(GLOB ANDROID_POWER_SOURCES ${SDL2_SOURCE_DIR}/src/power/android/*.c)
set(SOURCE_FILES ${SOURCE_FILES} ${ANDROID_POWER_SOURCES})
set(HAVE_SDL_POWER TRUE)
endif()
+ if(SDL_TIMERS)
+ set(SDL_TIMER_UNIX 1)
+ file(GLOB TIMER_SOURCES ${SDL2_SOURCE_DIR}/src/timer/unix/*.c)
+ set(SOURCE_FILES ${SOURCE_FILES} ${TIMER_SOURCES})
+ set(HAVE_SDL_TIMERS TRUE)
+ endif()
if(SDL_VIDEO)
set(SDL_VIDEO_DRIVER_ANDROID 1)
file(GLOB ANDROID_VIDEO_SOURCES ${SDL2_SOURCE_DIR}/src/video/android/*.c)
set(SOURCE_FILES ${SOURCE_FILES} ${ANDROID_VIDEO_SOURCES})
set(HAVE_SDL_VIDEO TRUE)
+ # Core stuff
+ find_library(ANDROID_DL_LIBRARY dl)
+ find_library(ANDROID_LOG_LIBRARY log)
+ find_library(ANDROID_LIBRARY_LIBRARY android)
+ list(APPEND EXTRA_LIBS ${ANDROID_DL_LIBRARY} ${ANDROID_LOG_LIBRARY} ${ANDROID_LIBRARY_LIBRARY})
+ add_definitions(-DGL_GLEXT_PROTOTYPES)
+
#enable gles
if(VIDEO_OPENGLES)
set(SDL_VIDEO_OPENGL_EGL 1)
set(HAVE_VIDEO_OPENGLES TRUE)
set(SDL_VIDEO_OPENGL_ES2 1)
set(SDL_VIDEO_RENDER_OGL_ES2 1)
+
+ find_library(OpenGLES1_LIBRARY GLESv1_CM)
+ find_library(OpenGLES2_LIBRARY GLESv2)
+ list(APPEND EXTRA_LIBS ${OpenGLES1_LIBRARY} ${OpenGLES2_LIBRARY})
+ endif()
+
+ CHECK_C_SOURCE_COMPILES("
+ #if defined(__ARM_ARCH) && __ARM_ARCH < 7
+ #error Vulkan doesn't work on this configuration
+ #endif
+ int main()
+ {
+ return 0;
+ }
+ " VULKAN_PASSED_ANDROID_CHECKS)
+ if(NOT VULKAN_PASSED_ANDROID_CHECKS)
+ set(VIDEO_VULKAN OFF)
+ message(STATUS "Vulkan doesn't work on this configuration")
endif()
endif()
- list(APPEND EXTRA_LDFLAGS "-Wl,--undefined=Java_org_libsdl_app_SDLActivity_nativeInit")
+
+ CheckPTHREAD()
+
endif()
# Platform-specific options and settings
set(SOURCE_FILES ${SOURCE_FILES} ${EM_POWER_SOURCES})
set(HAVE_SDL_POWER TRUE)
endif()
+ if(SDL_TIMERS)
+ set(SDL_TIMER_UNIX 1)
+ file(GLOB TIMER_SOURCES ${SDL2_SOURCE_DIR}/src/timer/unix/*.c)
+ set(SOURCE_FILES ${SOURCE_FILES} ${TIMER_SOURCES})
+ set(HAVE_SDL_TIMERS TRUE)
+
+ if(CLOCK_GETTIME)
+ set(HAVE_CLOCK_GETTIME 1)
+ endif()
+ endif()
if(SDL_VIDEO)
set(SDL_VIDEO_DRIVER_EMSCRIPTEN 1)
file(GLOB EM_VIDEO_SOURCES ${SDL2_SOURCE_DIR}/src/video/emscripten/*.c)
set(SDL_VIDEO_RENDER_OGL_ES2 1)
endif()
endif()
-elseif(UNIX AND NOT APPLE)
+elseif(UNIX AND NOT APPLE AND NOT ANDROID)
if(SDL_AUDIO)
if(SYSV5 OR SOLARIS OR HPUX)
set(SDL_AUDIO_DRIVER_SUNAUDIO 1)
file(GLOB SUN_AUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/sun/*.c)
set(SOURCE_FILES ${SOURCE_FILES} ${SUN_AUDIO_SOURCES})
set(HAVE_SDL_AUDIO TRUE)
- elseif(NETBSD OR OPENBSD)
- set(SDL_AUDIO_DRIVER_BSD 1)
- file(GLOB BSD_AUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/bsd/*.c)
- set(SOURCE_FILES ${SOURCE_FILES} ${BSD_AUDIO_SOURCES})
+ elseif(NETBSD)
+ set(SDL_AUDIO_DRIVER_NETBSD 1)
+ file(GLOB NETBSD_AUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/netbsd/*.c)
+ set(SOURCE_FILES ${SOURCE_FILES} ${NETBSD_AUDIO_SOURCES})
set(HAVE_SDL_AUDIO TRUE)
elseif(AIX)
set(SDL_AUDIO_DRIVER_PAUDIO 1)
endif()
CheckOSS()
CheckALSA()
+ CheckJACK()
CheckPulseAudio()
CheckESD()
CheckARTS()
CheckNAS()
CheckSNDIO()
CheckFusionSound()
+ CheckLibSampleRate()
endif()
if(SDL_VIDEO)
CheckWayland()
CheckTizen()
CheckVivante()
+ CheckKMSDRM()
+ endif()
+
+ if(UNIX)
+ file(GLOB CORE_UNIX_SOURCES ${SDL2_SOURCE_DIR}/src/core/unix/*.c)
+ set(SOURCE_FILES ${SOURCE_FILES} ${CORE_UNIX_SOURCES})
endif()
if(LINUX)
ioctl(0, KDGKBENT, &kbe);
}" HAVE_INPUT_KD)
- file(GLOB CORE_SOURCES ${SDL2_SOURCE_DIR}/src/core/linux/*.c)
- set(SOURCE_FILES ${SOURCE_FILES} ${CORE_SOURCES})
+ file(GLOB CORE_LINUX_SOURCES ${SDL2_SOURCE_DIR}/src/core/linux/*.c)
+ set(SOURCE_FILES ${SOURCE_FILES} ${CORE_LINUX_SOURCES})
if(HAVE_INPUT_EVENTS)
set(SDL_INPUT_LINUXEV 1)
check_include_file("libudev.h" HAVE_LIBUDEV_H)
- # !!! FIXME: this needs pkg-config to find the include path, I think.
- check_include_file("dbus/dbus.h" HAVE_DBUS_DBUS_H)
+ if(PKG_CONFIG_FOUND)
+ pkg_search_module(DBUS dbus-1 dbus)
+ if(DBUS_FOUND)
+ set(HAVE_DBUS_DBUS_H TRUE)
+ include_directories(${DBUS_INCLUDE_DIRS})
+ list(APPEND EXTRA_LIBS ${DBUS_LIBRARIES})
+ endif()
+
+ pkg_search_module(IBUS ibus-1.0 ibus)
+ if(IBUS_FOUND)
+ set(HAVE_IBUS_IBUS_H TRUE)
+ include_directories(${IBUS_INCLUDE_DIRS})
+ list(APPEND EXTRA_LIBS ${IBUS_LIBRARIES})
+ endif()
+ endif()
+
+ check_include_file("fcitx/frontend.h" HAVE_FCITX_FRONTEND_H)
endif()
if(INPUT_TSLIB)
CheckUSBHID() # seems to be BSD specific - limit the test to BSD only?
if(LINUX AND NOT ANDROID)
set(SDL_JOYSTICK_LINUX 1)
- file(GLOB JOYSTICK_SOURCES ${SDL2_SOURCE_DIR}/src/joystick/linux/*.c)
+ file(GLOB JOYSTICK_SOURCES ${SDL2_SOURCE_DIR}/src/joystick/linux/*.c ${SDL2_SOURCE_DIR}/src/joystick/steam/*.c)
set(SOURCE_FILES ${SOURCE_FILES} ${JOYSTICK_SOURCES})
set(HAVE_SDL_JOYSTICK TRUE)
endif()
if(RPATH)
set(SDL_RLD_FLAGS "")
if(BSDI OR FREEBSD OR LINUX OR NETBSD)
- set(SDL_RLD_FLAGS "-Wl,-rpath,\${libdir}")
+ set(CMAKE_REQUIRED_FLAGS "-Wl,--enable-new-dtags")
+ check_c_compiler_flag("" HAVE_ENABLE_NEW_DTAGS)
+ set(CMAKE_REQUIRED_FLAGS ${ORIG_CMAKE_REQUIRED_FLAGS})
+ if(HAVE_ENABLE_NEW_DTAGS)
+ set(SDL_RLD_FLAGS "-Wl,-rpath,\${libdir} -Wl,--enable-new-dtags")
+ else()
+ set(SDL_RLD_FLAGS "-Wl,-rpath,\${libdir}")
+ endif()
elseif(SOLARIS)
set(SDL_RLD_FLAGS "-R\${libdir}")
endif()
if(MSVC)
# Prevent codegen that would use the VC runtime libraries.
- add_definitions(/GS-)
+ set_property(DIRECTORY . APPEND PROPERTY COMPILE_OPTIONS "/GS-")
if(NOT ARCH_64)
- add_definitions(/arch:SSE)
+ set_property(DIRECTORY . APPEND PROPERTY COMPILE_OPTIONS "/arch:SSE")
endif()
endif()
#include <windows.h>
#include <xinput.h>
int main(int argc, char **argv) { }" HAVE_XINPUT_H)
+ check_c_source_compiles("
+ #include <windows.h>
+ #include <xinput.h>
+ XINPUT_GAMEPAD_EX x1;
+ int main(int argc, char **argv) { }" HAVE_XINPUT_GAMEPAD_EX)
+ check_c_source_compiles("
+ #include <windows.h>
+ #include <xinput.h>
+ XINPUT_STATE_EX s1;
+ int main(int argc, char **argv) { }" HAVE_XINPUT_STATE_EX)
else()
check_include_file(xinput.h HAVE_XINPUT_H)
endif()
check_include_file(ddraw.h HAVE_DDRAW_H)
check_include_file(dsound.h HAVE_DSOUND_H)
check_include_file(dinput.h HAVE_DINPUT_H)
- check_include_file(xaudio2.h HAVE_XAUDIO2_H)
+ check_include_file(mmdeviceapi.h HAVE_MMDEVICEAPI_H)
+ check_include_file(audioclient.h HAVE_AUDIOCLIENT_H)
check_include_file(dxgi.h HAVE_DXGI_H)
- if(HAVE_D3D_H OR HAVE_D3D11_H OR HAVE_DDRAW_H OR HAVE_DSOUND_H OR HAVE_DINPUT_H OR HAVE_XAUDIO2_H)
+ if(HAVE_D3D_H OR HAVE_D3D11_H OR HAVE_DDRAW_H OR HAVE_DSOUND_H OR HAVE_DINPUT_H)
set(HAVE_DIRECTX TRUE)
if(NOT CMAKE_COMPILER_IS_MINGW AND NOT USE_WINSDK_DIRECTX)
# TODO: change $ENV{DXSDL_DIR} to get the path from the include checks
set(SOURCE_FILES ${SOURCE_FILES} ${DSOUND_AUDIO_SOURCES})
endif()
- if(HAVE_XAUDIO2_H)
- set(SDL_AUDIO_DRIVER_XAUDIO2 1)
- file(GLOB XAUDIO2_AUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/xaudio2/*.c)
- set(SOURCE_FILES ${SOURCE_FILES} ${XAUDIO2_AUDIO_SOURCES})
+ if(HAVE_AUDIOCLIENT_H AND HAVE_MMDEVICEAPI_H)
+ set(SDL_AUDIO_DRIVER_WASAPI 1)
+ file(GLOB WASAPI_AUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/wasapi/*.c)
+ set(SOURCE_FILES ${SOURCE_FILES} ${WASAPI_AUDIO_SOURCES})
endif()
endif()
set(SOURCE_FILES ${SOURCE_FILES} ${JOYSTICK_SOURCES})
if(HAVE_DINPUT_H)
set(SDL_JOYSTICK_DINPUT 1)
- list(APPEND EXTRA_LIBS dinput8 dxguid)
+ list(APPEND EXTRA_LIBS dinput8)
if(CMAKE_COMPILER_IS_MINGW)
list(APPEND EXTRA_LIBS dxerr8)
elseif (NOT USE_WINSDK_DIRECTX)
list(APPEND SDL_LIBS "-lmingw32" "-lSDL2main" "-mwindows")
endif()
elseif(APPLE)
- # TODO: rework this for proper MacOS X, iOS and Darwin support
+ # TODO: rework this all for proper MacOS X, iOS and Darwin support
+
+ # We always need these libs on macOS at the moment.
+ # !!! FIXME: we need Carbon for some very old API calls in
+ # !!! FIXME: src/video/cocoa/SDL_cocoakeyboard.c, but we should figure out
+ # !!! FIXME: how to dump those.
+ if(NOT IOS)
+ set(SDL_FRAMEWORK_COCOA 1)
+ set(SDL_FRAMEWORK_CARBON 1)
+ endif()
# Requires the darwin file implementation
if(SDL_FILE)
file(GLOB EXTRA_SOURCES ${SDL2_SOURCE_DIR}/src/file/cocoa/*.m)
set(SOURCE_FILES ${EXTRA_SOURCES} ${SOURCE_FILES})
+ # !!! FIXME: modern CMake doesn't need "LANGUAGE C" for Objective-C.
set_source_files_properties(${EXTRA_SOURCES} PROPERTIES LANGUAGE C)
set(HAVE_SDL_FILE TRUE)
- set(SDL_FRAMEWORK_COCOA 1)
+ # !!! FIXME: why is COREVIDEO inside this if() block?
set(SDL_FRAMEWORK_COREVIDEO 1)
else()
message_error("SDL_FILE must be enabled to build on MacOS X")
if(SDL_AUDIO)
set(SDL_AUDIO_DRIVER_COREAUDIO 1)
- file(GLOB AUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/coreaudio/*.c)
+ file(GLOB AUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/coreaudio/*.m)
+ # !!! FIXME: modern CMake doesn't need "LANGUAGE C" for Objective-C.
+ set_source_files_properties(${AUDIO_SOURCES} PROPERTIES LANGUAGE C)
set(SOURCE_FILES ${SOURCE_FILES} ${AUDIO_SOURCES})
set(HAVE_SDL_AUDIO TRUE)
set(SDL_FRAMEWORK_COREAUDIO 1)
- set(SDL_FRAMEWORK_AUDIOUNIT 1)
+ set(SDL_FRAMEWORK_AUDIOTOOLBOX 1)
endif()
if(SDL_JOYSTICK)
set(SDL_JOYSTICK_IOKIT 1)
- file(GLOB JOYSTICK_SOURCES ${SDL2_SOURCE_DIR}/src/joystick/darwin/*.c)
+ if (IOS)
+ file(GLOB JOYSTICK_SOURCES ${SDL2_SOURCE_DIR}/src/joystick/iphoneos/*.m ${SDL2_SOURCE_DIR}/src/joystick/steam/*.c)
+ else()
+ file(GLOB JOYSTICK_SOURCES ${SDL2_SOURCE_DIR}/src/joystick/darwin/*.c)
+ endif()
set(SOURCE_FILES ${SOURCE_FILES} ${JOYSTICK_SOURCES})
set(HAVE_SDL_JOYSTICK TRUE)
set(SDL_FRAMEWORK_IOKIT 1)
if(SDL_HAPTIC)
set(SDL_HAPTIC_IOKIT 1)
- file(GLOB HAPTIC_SOURCES ${SDL2_SOURCE_DIR}/src/haptic/darwin/*.c)
+ if (IOS)
+ file(GLOB HAPTIC_SOURCES ${SDL2_SOURCE_DIR}/src/haptic/dummy/*.c)
+ set(SDL_HAPTIC_DUMMY 1)
+ else()
+ file(GLOB HAPTIC_SOURCES ${SDL2_SOURCE_DIR}/src/haptic/darwin/*.c)
+ endif()
set(SOURCE_FILES ${SOURCE_FILES} ${HAPTIC_SOURCES})
set(HAVE_SDL_HAPTIC TRUE)
set(SDL_FRAMEWORK_IOKIT 1)
if(SDL_POWER)
set(SDL_POWER_MACOSX 1)
- file(GLOB POWER_SOURCES ${SDL2_SOURCE_DIR}/src/power/macosx/*.c)
+ if (IOS)
+ file(GLOB POWER_SOURCES ${SDL2_SOURCE_DIR}/src/power/uikit/*.m)
+ else()
+ file(GLOB POWER_SOURCES ${SDL2_SOURCE_DIR}/src/power/macosx/*.c)
+ endif()
set(SOURCE_FILES ${SOURCE_FILES} ${POWER_SOURCES})
set(HAVE_SDL_POWER TRUE)
- set(SDL_FRAMEWORK_CARBON 1)
set(SDL_FRAMEWORK_IOKIT 1)
endif()
if(SDL_FILESYSTEM)
set(SDL_FILESYSTEM_COCOA 1)
file(GLOB FILESYSTEM_SOURCES ${SDL2_SOURCE_DIR}/src/filesystem/cocoa/*.m)
+ # !!! FIXME: modern CMake doesn't need "LANGUAGE C" for Objective-C.
set_source_files_properties(${FILESYSTEM_SOURCES} PROPERTIES LANGUAGE C)
set(SOURCE_FILES ${SOURCE_FILES} ${FILESYSTEM_SOURCES})
set(HAVE_SDL_FILESYSTEM TRUE)
find_library(COREAUDIO CoreAudio)
list(APPEND EXTRA_LIBS ${COREAUDIO})
endif()
- if(SDL_FRAMEWORK_AUDIOUNIT)
- find_library(AUDIOUNIT AudioUnit)
- list(APPEND EXTRA_LIBS ${AUDIOUNIT})
+ if(SDL_FRAMEWORK_AUDIOTOOLBOX)
+ find_library(AUDIOTOOLBOX AudioToolbox)
+ list(APPEND EXTRA_LIBS ${AUDIOTOOLBOX})
endif()
# iOS hack needed - http://code.google.com/p/ios-cmake/ ?
if(SDL_VIDEO)
- CheckCOCOA()
- if(VIDEO_OPENGL)
- set(SDL_VIDEO_OPENGL 1)
- set(SDL_VIDEO_OPENGL_CGL 1)
- set(SDL_VIDEO_RENDER_OGL 1)
- set(HAVE_VIDEO_OPENGL TRUE)
+ if (IOS)
+ set(SDL_VIDEO_DRIVER_UIKIT 1)
+ file(GLOB UIKITVIDEO_SOURCES ${SDL2_SOURCE_DIR}/src/video/uikit/*.m)
+ set(SOURCE_FILES ${SOURCE_FILES} ${UIKITVIDEO_SOURCES})
+ else()
+ CheckCOCOA()
+ if(VIDEO_OPENGL)
+ set(SDL_VIDEO_OPENGL 1)
+ set(SDL_VIDEO_OPENGL_CGL 1)
+ set(SDL_VIDEO_RENDER_OGL 1)
+ set(HAVE_VIDEO_OPENGL TRUE)
+ endif()
+
+ if(VIDEO_OPENGLES)
+ set(SDL_VIDEO_OPENGL_EGL 1)
+ set(SDL_VIDEO_OPENGL_ES2 1)
+ set(SDL_VIDEO_RENDER_OGL_ES2 1)
+ set(HAVE_VIDEO_OPENGLES TRUE)
+ endif()
endif()
endif()
endif()
endif()
+if(VIDEO_VULKAN)
+ set(SDL_VIDEO_VULKAN 1)
+endif()
+
# Dummies
# configure.in does it differently:
# if not have X
message(STATUS "")
message(STATUS " Build Shared Library: ${SDL_SHARED}")
message(STATUS " Build Static Library: ${SDL_STATIC}")
+if(SDL_STATIC)
+ message(STATUS " Build Static Library with Position Independent Code: ${SDL_STATIC_PIC}")
+endif()
message(STATUS "")
if(UNIX)
message(STATUS "If something was not detected, although the libraries")
# Always build SDLmain
add_library(SDL2main STATIC ${SDLMAIN_SOURCES})
+target_include_directories(SDL2main PUBLIC $<INSTALL_INTERFACE:include>)
set(_INSTALL_LIBS "SDL2main")
+if (NOT ANDROID)
+ set_target_properties(SDL2main PROPERTIES DEBUG_POSTFIX ${SDL_CMAKE_DEBUG_POSTFIX})
+endif()
if(SDL_SHARED)
- add_library(SDL2 SHARED ${SOURCE_FILES})
- if(UNIX)
+ add_library(SDL2 SHARED ${SOURCE_FILES} ${VERSION_SOURCES})
+ if(APPLE)
+ set_target_properties(SDL2 PROPERTIES MACOSX_RPATH 1)
+ elseif(UNIX AND NOT ANDROID)
set_target_properties(SDL2 PROPERTIES
VERSION ${LT_VERSION}
SOVERSION ${LT_REVISION}
SOVERSION ${LT_REVISION}
OUTPUT_NAME "SDL2")
endif()
- if(MSVC)
+ if(MSVC AND NOT LIBC)
# Don't try to link with the default set of libraries.
set_target_properties(SDL2 PROPERTIES LINK_FLAGS_RELEASE "/NODEFAULTLIB")
set_target_properties(SDL2 PROPERTIES LINK_FLAGS_DEBUG "/NODEFAULTLIB")
endif()
set(_INSTALL_LIBS "SDL2" ${_INSTALL_LIBS})
target_link_libraries(SDL2 ${EXTRA_LIBS} ${EXTRA_LDFLAGS})
+ target_include_directories(SDL2 PUBLIC $<INSTALL_INTERFACE:include>)
+ if (NOT ANDROID)
+ set_target_properties(SDL2 PROPERTIES DEBUG_POSTFIX ${SDL_CMAKE_DEBUG_POSTFIX})
+ endif()
endif()
if(SDL_STATIC)
set (BUILD_SHARED_LIBS FALSE)
add_library(SDL2-static STATIC ${SOURCE_FILES})
- set_target_properties(SDL2-static PROPERTIES OUTPUT_NAME "SDL2")
- if(MSVC)
+ if (NOT SDL_SHARED OR NOT WIN32)
+ set_target_properties(SDL2-static PROPERTIES OUTPUT_NAME "SDL2")
+ # Note: Apparently, OUTPUT_NAME must really be unique; even when
+ # CMAKE_IMPORT_LIBRARY_SUFFIX or the like are given. Otherwise
+ # the static build may race with the import lib and one will get
+ # clobbered, when the suffix is realized via subsequent rename.
+ endif()
+ set_target_properties(SDL2-static PROPERTIES POSITION_INDEPENDENT_CODE ${SDL_STATIC_PIC})
+ if(MSVC AND NOT LIBC)
set_target_properties(SDL2-static PROPERTIES LINK_FLAGS_RELEASE "/NODEFAULTLIB")
set_target_properties(SDL2-static PROPERTIES LINK_FLAGS_DEBUG "/NODEFAULTLIB")
set_target_properties(SDL2-static PROPERTIES STATIC_LIBRARY_FLAGS "/NODEFAULTLIB")
# libraries - do we need to consider this?
set(_INSTALL_LIBS "SDL2-static" ${_INSTALL_LIBS})
target_link_libraries(SDL2-static ${EXTRA_LIBS} ${EXTRA_LDFLAGS})
+ target_include_directories(SDL2-static PUBLIC $<INSTALL_INTERFACE:include>)
+ if (NOT ANDROID)
+ set_target_properties(SDL2-static PROPERTIES DEBUG_POSTFIX ${SDL_CMAKE_DEBUG_POSTFIX})
+ endif()
+endif()
+
+##### Tests #####
+
+if(SDL_TEST)
+ file(GLOB TEST_SOURCES ${SDL2_SOURCE_DIR}/src/test/*.c)
+ add_library(SDL2_test STATIC ${TEST_SOURCES})
+
+ add_subdirectory(test)
endif()
##### Installation targets #####
-install(TARGETS ${_INSTALL_LIBS}
+install(TARGETS ${_INSTALL_LIBS} EXPORT SDL2Targets
LIBRARY DESTINATION "lib${LIB_SUFFIX}"
ARCHIVE DESTINATION "lib${LIB_SUFFIX}"
RUNTIME DESTINATION bin)
+##### Export files #####
+if (APPLE)
+ set(PKG_PREFIX "SDL2.framework/Resources")
+elseif (WINDOWS)
+ set(PKG_PREFIX "cmake")
+else ()
+ set(PKG_PREFIX "lib/cmake/SDL2")
+endif ()
+
+include(CMakePackageConfigHelpers)
+write_basic_package_version_file("${CMAKE_BINARY_DIR}/SDL2ConfigVersion.cmake"
+ VERSION ${SDL_VERSION}
+ COMPATIBILITY AnyNewerVersion
+)
+
+install(EXPORT SDL2Targets
+ FILE SDL2Targets.cmake
+ NAMESPACE SDL2::
+ DESTINATION ${PKG_PREFIX}
+)
+install(
+ FILES
+ ${CMAKE_CURRENT_SOURCE_DIR}/SDL2Config.cmake
+ ${CMAKE_BINARY_DIR}/SDL2ConfigVersion.cmake
+ DESTINATION ${PKG_PREFIX}
+ COMPONENT Devel
+)
+
file(GLOB INCLUDE_FILES ${SDL2_SOURCE_DIR}/include/*.h)
file(GLOB BIN_INCLUDE_FILES ${SDL2_BINARY_DIR}/include/*.h)
foreach(_FNAME ${BIN_INCLUDE_FILES})
list(APPEND INCLUDE_FILES ${BIN_INCLUDE_FILES})
install(FILES ${INCLUDE_FILES} DESTINATION include/SDL2)
-if(NOT WINDOWS OR CYGWIN)
+if(NOT (WINDOWS OR CYGWIN))
if(SDL_SHARED)
- install(CODE "
- execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink
- \"libSDL2-2.0.so\" \"libSDL2.so\")")
- install(FILES ${SDL2_BINARY_DIR}/libSDL2.so DESTINATION "lib${LIB_SUFFIX}")
+ if (APPLE)
+ set(SOEXT "dylib")
+ else()
+ set(SOEXT "so")
+ endif()
+ if(NOT ANDROID)
+ install(CODE "
+ execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink
+ \"libSDL2-2.0.${SOEXT}\" \"libSDL2.${SOEXT}\")")
+ install(FILES ${SDL2_BINARY_DIR}/libSDL2.${SOEXT} DESTINATION "lib${LIB_SUFFIX}")
+ endif()
endif()
if(FREEBSD)
# FreeBSD uses ${PREFIX}/libdata/pkgconfig
endif()
install(PROGRAMS ${SDL2_BINARY_DIR}/sdl2-config DESTINATION bin)
# TODO: what about the .spec file? Is it only needed for RPM creation?
- install(FILES "${SDL2_SOURCE_DIR}/sdl2.m4" DESTINATION "share/aclocal")
+ install(FILES "${SDL2_SOURCE_DIR}/sdl2.m4" DESTINATION "${CMAKE_INSTALL_FULL_DATAROOTDIR}/aclocal")
endif()
##### Uninstall target #####
-configure_file(
- "${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
- "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
- IMMEDIATE @ONLY)
+if(NOT TARGET uninstall)
+ configure_file(
+ "${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
+ "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
+ IMMEDIATE @ONLY)
-add_custom_target(uninstall
- COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
+ add_custom_target(uninstall
+ COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
+endif()