diff --git a/CMakeLists.txt b/CMakeLists.txt index 025e652d7a..80e7fffdfd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -390,8 +390,17 @@ set_option(SDL_CLANG_TIDY "Run clang-tidy static analysis" OFF) set(SDL_VENDOR_INFO "" CACHE STRING "Vendor name and/or version to add to SDL_REVISION") -cmake_dependent_option(SDL_SHARED "Build a shared version of the library" ${SDL_SHARED_DEFAULT} ${SDL_SHARED_AVAILABLE} OFF) -cmake_dependent_option(SDL_STATIC "Build a static version of the library" ${SDL_STATIC_DEFAULT} ${SDL_STATIC_AVAILABLE} OFF) +if(DEFINED CACHE{SDL_SHARED} OR DEFINED CACHE{SDL_STATIC}) + cmake_dependent_option(SDL_SHARED "Build a shared version of the library" ${SDL_SHARED_DEFAULT} ${SDL_SHARED_AVAILABLE} OFF) + cmake_dependent_option(SDL_STATIC "Build a static version of the library" ${SDL_STATIC_DEFAULT} ${SDL_STATIC_AVAILABLE} OFF) +else() + if(NOT DEFINED SDL_SHARED) + set(SDL_SHARED ${SDL_SHARED_DEFAULT}) + endif() + if(NOT DEFINED SDL_STATIC) + set(SDL_STATIC ${SDL_STATIC_DEFAULT}) + endif() +endif() option(SDL_TEST_LIBRARY "Build the SDL3_test library" ON) dep_option(SDL_TESTS "Build the test directory" ${SDL3_MAINPROJECT} SDL_TEST_LIBRARY OFF)