Skip to content

Commit

Permalink
cmake: rename SDL_DISABLE_* CMake options to SDL_xxx
Browse files Browse the repository at this point in the history
  • Loading branch information
madebr committed Jan 10, 2025
1 parent 90aff30 commit bda90c3
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 20 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/generic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,9 @@ jobs:
-DSDLTEST_TRACKMEM=ON \
-DSDL_INSTALL_TESTS=${{ matrix.platform.build-tests }} \
-DSDL_CLANG_TIDY=${{ matrix.platform.clang-tidy }} \
-DSDL_DISABLE_INSTALL_DOCS=OFF \
-DSDL_DISABLE_INSTALL_CPACK=OFF \
-DSDL_DISABLE_INSTALL_DOCS=OFF \
-DSDL_INSTALL_DOCS=ON \
-DSDL_INSTALL_CPACK=ON \
-DSDL_INSTALL_DOCS=ON \
${{ matrix.platform.cmake-arguments }} \
-DSDL_SHARED=${{ matrix.platform.shared }} \
-DSDL_STATIC=${{ matrix.platform.static }} \
Expand Down Expand Up @@ -293,7 +293,7 @@ jobs:
${{ matrix.platform.cmake-toolchain-file != '' && format('-DCMAKE_TOOLCHAIN_FILE={0}', matrix.platform.cmake-toolchain-file) || '' }} \
-Wdeprecated -Wdev -Werror \
-DSDL_WERROR=${{ matrix.platform.werror }} \
-DSDL_DISABLE_INSTALL_DOCS=OFF \
-DSDL_INSTALL_DOCS=ON \
${{ matrix.platform.cmake-arguments }} \
-DSDL_SHARED=${{ matrix.platform.shared }} \
-DSDL_STATIC=${{ matrix.platform.static }} \
Expand Down
32 changes: 16 additions & 16 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ endif()
project(SDL3 LANGUAGES C VERSION "3.1.9")

if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
set(SDL3_SUBPROJECT OFF)
set(SDL3_MAINPROJECT ON)
else()
set(SDL3_SUBPROJECT ON)
set(SDL3_MAINPROJECT OFF)
endif()

# By default, configure SDL3 in RelWithDebInfo configuration
if(NOT SDL3_SUBPROJECT)
if(SDL3_MAINPROJECT)
get_property(is_multi_config GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
if(is_multi_config)
# The first item in CMAKE_CONFIGURATION_TYPES is the default configuration
Expand Down Expand Up @@ -287,14 +287,14 @@ if(SOLARIS)
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)
set_option(SDL_INSTALL "Enable installation of SDL3" ${SDL3_MAINPROJECT})
cmake_dependent_option(SDL_INSTALL_CPACK "Create binary SDL3 archive using CPack" ${SDL3_MAINPROJECT} "SDL_INSTALL" ON)
cmake_dependent_option(SDL_INSTALL_DOCS "Install docs for SDL3" OFF "SDL_INSTALL;NOT SDL_FRAMEWORK" ON)
set_option(SDL_UNINSTALL "Enable uninstallation of SDL3" ${SDL3_MAINPROJECT})
cmake_dependent_option(SDL_PRESEED "Preseed CMake cache to speed up configuration" ON "${SDL_PRESEED_AVAILABLE}" OFF)
cmake_dependent_option(SDL_RELOCATABLE "Create relocatable SDL package" ${SDL_RELOCATABLE_DEFAULT} "NOT SDL_DISABLE_INSTALL" OFF)
cmake_dependent_option(SDL_RELOCATABLE "Create relocatable SDL package" ${SDL_RELOCATABLE_DEFAULT} "SDL_INSTALL" OFF)

cmake_dependent_option(SDL_DISABLE_ANDROID_JAR "Disable creation of SDL3.jar" ${SDL3_SUBPROJECT} "ANDROID" ON)
cmake_dependent_option(SDL_ANDROID_JAR "Enable creation of SDL3.jar" ${SDL3_MAINPROJECT} "ANDROID" ON)

option_string(SDL_ASSERTIONS "Enable internal sanity checks (auto/disabled/release/enabled/paranoid)" "auto")
set_option(SDL_ASSEMBLY "Enable assembly routines" ${SDL_ASSEMBLY_DEFAULT})
Expand Down Expand Up @@ -394,7 +394,7 @@ cmake_dependent_option(SDL_STATIC "Build a static version of the library" ${SDL_
option(SDL_TEST_LIBRARY "Build the SDL3_test library" ON)

dep_option(SDL_TESTS "Build the test directory" OFF SDL_TEST_LIBRARY OFF)
dep_option(SDL_INSTALL_TESTS "Install test-cases" OFF "NOT SDL_DISABLE_INSTALL;NOT SDL_FRAMEWORK" OFF)
dep_option(SDL_INSTALL_TESTS "Install test-cases" OFF "SDL_INSTALL;NOT SDL_FRAMEWORK" OFF)
dep_option(SDL_TESTS_LINK_SHARED "link tests to shared SDL library" "${SDL_SHARED}" "SDL_SHARED;SDL_STATIC" "${SDL_SHARED}")
set(SDL_TESTS_TIMEOUT_MULTIPLIER "1" CACHE STRING "Timeout multiplier to account for really slow machines")

Expand Down Expand Up @@ -1419,7 +1419,7 @@ if(ANDROID)
set(HAVE_CLOCK_GETTIME 1)
endif()

if(NOT SDL_DISABLE_ANDROID_JAR)
if(SDL_ANDROID_JAR)
find_package(Java)
find_package(SdlAndroidPlatform MODULE)

Expand Down Expand Up @@ -1449,7 +1449,7 @@ if(ANDROID)
DEPENDS ${SDL_JAVA_SOURCES}
)
add_custom_target(SDL3-javasources ALL DEPENDS "${javasourcesjar}")
if(NOT SDL_DISABLE_INSTALL_DOCS)
if(SDL_INSTALL_DOCS)
set(javadocdir "${SDL3_BINARY_DIR}/docs/javadoc")
set(javadocjar "${SDL3_BINARY_DIR}/SDL3-${SDL3_VERSION}-javadoc.jar")
set(javadoc_index_html "${javadocdir}/index.html")
Expand Down Expand Up @@ -3609,7 +3609,7 @@ if(sdl_cmake_modules)
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different ${sdl_cmake_modules} "${SDL3_BINARY_DIR}")
endif()

if(NOT SDL_DISABLE_INSTALL)
if(SDL_INSTALL)

##### sdl3.pc #####
configure_sdl3_pc()
Expand Down Expand Up @@ -3709,7 +3709,7 @@ if(NOT SDL_DISABLE_INSTALL)
install(FILES "LICENSE.txt" DESTINATION "${SDL_INSTALL_LICENSEDIR}")
endif()

if(NOT SDL_DISABLE_INSTALL_CPACK)
if(SDL_INSTALL_CPACK)
if(SDL_FRAMEWORK)
set(CPACK_GENERATOR "DragNDrop")
elseif(MSVC)
Expand Down Expand Up @@ -3750,7 +3750,7 @@ if(NOT SDL_DISABLE_INSTALL)
endif()
endif()

if(NOT SDL_DISABLE_INSTALL_DOCS)
if(SDL_INSTALL_DOCS)
SDL_generate_manpages(
HEADERS_DIR "${PROJECT_SOURCE_DIR}/include/SDL3"
SYMBOL "SDL_Init"
Expand All @@ -3767,7 +3767,7 @@ endif()

##### Uninstall target #####

if(NOT SDL_DISABLE_UNINSTALL)
if(SDL_UNINSTALL)
if(NOT TARGET uninstall)
configure_file(cmake/cmake_uninstall.cmake.in cmake_uninstall.cmake IMMEDIATE @ONLY)

Expand Down
7 changes: 7 additions & 0 deletions docs/README-cmake.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,13 @@ Exceptions exist:
- some platforms don't support dynamic libraries, so only `-DSDL_STATIC=ON` makes sense.
- a static Apple framework is not supported

### Man pages

Configuring with `-DSDL_INSTALL_DOCS=TRUE` installs man pages.

We recommend package managers of unix distributions to install SDL3's man pages.
This adds an extra build-time dependency on Perl.

### Pass custom compile options to the compiler

- Use [`CMAKE_<LANG>_FLAGS`](https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_FLAGS.html) to pass extra
Expand Down

0 comments on commit bda90c3

Please sign in to comment.