cmake: gate all preseeding behind SDL_PRESEED option

This commit is contained in:
Anonymous Maarten 2024-07-25 18:13:31 +02:00 committed by Anonymous Maarten
parent 546cd3ac83
commit 2aad26abb0
3 changed files with 12 additions and 13 deletions

View File

@ -57,10 +57,6 @@ include("${SDL3_SOURCE_DIR}/cmake/PreseedEmscriptenCache.cmake")
SDL_DetectCompiler()
SDL_DetectTargetCPUArchitectures(SDL_CPUS)
if (SDL_PRESEED_FUNCTION_DEFINED)
SDL_Preseed_CMakeCache()
endif()
# Increment this if there is an incompatible change - but if that happens,
# we should rename the library from SDL3 to SDL4, at which point this would
# reset to 0 anyway.
@ -257,11 +253,17 @@ else()
set(SDL_RPATH_DEFAULT OFF)
endif()
set(SDL_PRESEED_AVAILABLE OFF)
if(COMMAND SDL_Preseed_CMakeCache)
set(SDL_PRESEED_AVAILABLE ON)
endif()
# Allow some projects to be built conditionally.
set_option(SDL_DISABLE_INSTALL "Disable installation of SDL3" ${SDL3_SUBPROJECT})
cmake_dependent_option(SDL_DISABLE_INSTALL_CPACK "Create binary SDL3 archive using CPack" ${SDL3_SUBPROJECT} "NOT SDL_DISABLE_INSTALL" ON)
cmake_dependent_option(SDL_DISABLE_INSTALL_DOCS "Install docs for SDL3" ON "NOT SDL_DISABLE_INSTALL;NOT SDL_FRAMEWORK" ON)
set_option(SDL_DISABLE_UNINSTALL "Disable uninstallation of SDL3" OFF)
cmake_dependent_option(SDL_PRESEED "Preseed CMake cache to speed up configuration" ON "${SDL_PRESEED_AVAILABLE}" OFF)
cmake_dependent_option(SDL_DISABLE_ANDROID_JAR "Disable creation of SDL3.jar" ${SDL3_SUBPROJECT} "ANDROID" ON)
@ -370,6 +372,10 @@ if(NOT (SDL_SHARED OR SDL_STATIC))
message(FATAL_ERROR "SDL_SHARED and SDL_STATIC cannot both be disabled")
endif()
if(SDL_PRESEED)
SDL_Preseed_CMakeCache()
endif()
if(SDL_SHARED)
add_library(SDL3-shared SHARED)
add_library(SDL3::SDL3-shared ALIAS SDL3-shared)

View File

@ -1,7 +1,4 @@
cmake_dependent_option(SDL_EMSCRIPTEN_PRESEED "Preseed CMake cache for Emscripten to speed up configuration" ON "EMSCRIPTEN" OFF)
if(SDL_EMSCRIPTEN_PRESEED)
set(SDL_PRESEED_FUNCTION_DEFINED TRUE)
if(EMSCRIPTEN)
function(SDL_Preseed_CMakeCache)
set(COMPILER_SUPPORTS_FDIAGNOSTICS_COLOR_ALWAYS "1" CACHE INTERNAL "Test COMPILER_SUPPORTS_FDIAGNOSTICS_COLOR_ALWAYS")
set(HAVE_ALLOCA_H "1" CACHE INTERNAL "Have include alloca.h")
@ -177,4 +174,3 @@ if(SDL_EMSCRIPTEN_PRESEED)
set(HAVE_DLOPEN_IN_LIBC "1" CACHE INTERNAL "Have symbol dlopen")
endfunction()
endif()

View File

@ -1,7 +1,4 @@
cmake_dependent_option(SDL_MSVC_PRESEED "Preseed CMake cache for MSVC to speed up configuration" ON "MSVC;NOT WINDOWS_STORE" OFF)
if(SDL_MSVC_PRESEED)
set(SDL_PRESEED_FUNCTION_DEFINED TRUE)
if(MSVC)
function(SDL_Preseed_CMakeCache)
set(COMPILER_SUPPORTS_FDIAGNOSTICS_COLOR_ALWAYS "" CACHE INTERNAL "Test COMPILER_SUPPORTS_FDIAGNOSTICS_COLOR_ALWAYS")
set(HAVE_ALLOCA_H "" CACHE INTERNAL "Have include alloca.h")