From 574c6afe0591e7fb9a683c6192efb1a3c24ca08c Mon Sep 17 00:00:00 2001 From: Chris Thrasher Date: Tue, 10 Sep 2024 11:28:06 -0600 Subject: [PATCH] Use `ON` and `OFF` for CMake booleans --- .github/workflows/ci.yml | 2 +- CMakeLists.txt | 32 ++++++++++++++++---------------- cmake/CompilerWarnings.cmake | 4 ++-- tools/BuildMacOS.sh | 24 ++++++++++++------------ 4 files changed, 31 insertions(+), 31 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a795a1b..6dd37b7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -105,7 +105,7 @@ jobs: path: SFML - name: Configure SFML CMake - run: cmake -S SFML -B SFML/build -GNinja -DCMAKE_INSTALL_PREFIX=SFML/install -DBUILD_SHARED_LIBS=TRUE -DCMAKE_BUILD_TYPE=Debug + run: cmake -S SFML -B SFML/build -GNinja -DCMAKE_INSTALL_PREFIX=SFML/install -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=Debug - name: Build SFML run: cmake --build SFML/build --target install diff --git a/CMakeLists.txt b/CMakeLists.txt index 72b7345..9f6def8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,34 +24,34 @@ include(GNUInstallDirs) include(${PROJECT_SOURCE_DIR}/cmake/Config.cmake) # add options to select which modules to build -csfml_set_option(CSFML_BUILD_WINDOW TRUE BOOL "TRUE to build CSFML's Window module. This setting is ignored, if the graphics module is built.") -csfml_set_option(CSFML_BUILD_GRAPHICS TRUE BOOL "TRUE to build CSFML's Graphics module.") -csfml_set_option(CSFML_BUILD_AUDIO TRUE BOOL "TRUE to build CSFML's Audio module.") -csfml_set_option(CSFML_BUILD_NETWORK TRUE BOOL "TRUE to build CSFML's Network module.") +csfml_set_option(CSFML_BUILD_WINDOW ON BOOL "ON to build CSFML's Window module. This setting is ignored, if the graphics module is built.") +csfml_set_option(CSFML_BUILD_GRAPHICS ON BOOL "ON to build CSFML's Graphics module.") +csfml_set_option(CSFML_BUILD_AUDIO ON BOOL "ON to build CSFML's Audio module.") +csfml_set_option(CSFML_BUILD_NETWORK ON BOOL "ON to build CSFML's Network module.") # add an option for choosing the build type (shared or static) -csfml_set_option(BUILD_SHARED_LIBS TRUE BOOL "TRUE to build CSFML as shared libraries, FALSE to build it as static libraries") +csfml_set_option(BUILD_SHARED_LIBS ON BOOL "ON to build CSFML as shared libraries, OFF to build it as static libraries") # add an option for building the API documentation -csfml_set_option(CSFML_BUILD_DOC FALSE BOOL "TRUE to generate the API documentation, FALSE to ignore it") +csfml_set_option(CSFML_BUILD_DOC OFF BOOL "ON to generate the API documentation, OFF to ignore it") # add an option for linking to sfml either statically or dynamically # default on windows to static and on other platforms to dynamic if(SFML_OS_WINDOWS) - set(LINK_STATICALLY_DEFAULT TRUE) + set(LINK_STATICALLY_DEFAULT ON) else() - set(LINK_STATICALLY_DEFAULT FALSE) + set(LINK_STATICALLY_DEFAULT OFF) endif() -csfml_set_option(CSFML_LINK_SFML_STATICALLY ${LINK_STATICALLY_DEFAULT} BOOL "TRUE to link to a static version of SFML, FALSE to link dynamically") +csfml_set_option(CSFML_LINK_SFML_STATICALLY ${LINK_STATICALLY_DEFAULT} BOOL "ON to link to a static version of SFML, OFF to link dynamically") # define an option for choosing between static and dynamic C runtime (Windows only) if(SFML_OS_WINDOWS) - set(STATIC_STD_LIBS FALSE CACHE BOOL "TRUE to statically link to the standard libraries, FALSE to use them as DLLs") + set(STATIC_STD_LIBS OFF CACHE BOOL "ON to statically link to the standard libraries, OFF to use them as DLLs") endif() # find SFML libraries (C++) if(CSFML_LINK_SFML_STATICALLY) - set(SFML_STATIC_LIBRARIES TRUE) + set(SFML_STATIC_LIBRARIES ON) add_definitions(-DSFML_STATIC) endif() set(SFML_MODULES "System") @@ -76,13 +76,13 @@ if(CSFML_BUILD_DOC) endif() # on Linux and BSD-like OS, install pkg-config files by default -set(CSFML_INSTALL_PKGCONFIG_DEFAULT FALSE) +set(CSFML_INSTALL_PKGCONFIG_DEFAULT OFF) if(SFML_OS_LINUX OR SFML_OS_FREEBSD OR SFML_OS_OPENBSD OR SFML_OS_NETBSD) - set(CSFML_INSTALL_PKGCONFIG_DEFAULT TRUE) + set(CSFML_INSTALL_PKGCONFIG_DEFAULT ON) endif() -csfml_set_option(CSFML_INSTALL_PKGCONFIG_FILES ${CSFML_INSTALL_PKGCONFIG_DEFAULT} BOOL "TRUE to automatically install pkg-config files so other projects can find SFML") +csfml_set_option(CSFML_INSTALL_PKGCONFIG_FILES ${CSFML_INSTALL_PKGCONFIG_DEFAULT} BOOL "ON to automatically install pkg-config files so other projects can find SFML") if(CSFML_INSTALL_PKGCONFIG_FILES) csfml_set_option(CSFML_PKGCONFIG_INSTALL_DIR "${CSFML_PKGCONFIG_DIR}" PATH "Install directory for CSFML's pkg-config .pc files") @@ -110,13 +110,13 @@ if(NOT PROJECT_IS_TOP_LEVEL) endif() # add an option for building the examples -csfml_set_option(CSFML_BUILD_EXAMPLES FALSE BOOL "TRUE to build the CSFML examples, FALSE to ignore them") +csfml_set_option(CSFML_BUILD_EXAMPLES OFF BOOL "ON to build the CSFML examples, OFF to ignore them") if(CSFML_BUILD_EXAMPLES) add_subdirectory(examples) endif() # add an option for building the tests -csfml_set_option(CSFML_BUILD_TEST_SUITE FALSE BOOL "TRUE to build the CSFML test suite, FALSE to ignore it") +csfml_set_option(CSFML_BUILD_TEST_SUITE OFF BOOL "ON to build the CSFML test suite, OFF to ignore it") if(CSFML_BUILD_TEST_SUITE) enable_testing() add_subdirectory(test) diff --git a/cmake/CompilerWarnings.cmake b/cmake/CompilerWarnings.cmake index 3b57e3f..38abd0d 100644 --- a/cmake/CompilerWarnings.cmake +++ b/cmake/CompilerWarnings.cmake @@ -4,7 +4,7 @@ # Helper function to enable compiler warnings for a specific target function(set_target_warnings target) - option(CSFML_WARNINGS_AS_ERRORS "Treat compiler warnings as errors" FALSE) + option(CSFML_WARNINGS_AS_ERRORS "Treat compiler warnings as errors" OFF) set(MSVC_WARNINGS /W4 # Baseline reasonable warnings @@ -55,7 +55,7 @@ function(set_target_warnings target) # Disable warnings as errors when using Clang on Windows to work around deprecation warnings in Windows APIs if(SFML_OS_WINDOWS AND (SFML_COMPILER_CLANG OR SFML_COMPILER_CLANG_CL)) - set(CSFML_WARNINGS_AS_ERRORS FALSE) + set(CSFML_WARNINGS_AS_ERRORS OFF) endif() if(CSFML_WARNINGS_AS_ERRORS) diff --git a/tools/BuildMacOS.sh b/tools/BuildMacOS.sh index e64a997..5e38ea4 100644 --- a/tools/BuildMacOS.sh +++ b/tools/BuildMacOS.sh @@ -220,11 +220,11 @@ build_sfml () # $1: 'clang' => clang & libc++ case "$2" in 'frameworks') - frameworks="TRUE" + frameworks="ON" installdir_adapted="$installdir/Library/Frameworks" ;; 'dylibs') - frameworks="FALSE" + frameworks="OFF" installdir_adapted="$installdir/usr/local" ;; *) @@ -234,10 +234,10 @@ build_sfml () # $1: 'clang' => clang & libc++ case "$3" in 'doc') - doc="TRUE" + doc="ON" ;; 'no doc') - doc="FALSE" + doc="OFF" ;; *) error "Unknown option for $3 in create_makefile" @@ -246,12 +246,12 @@ build_sfml () # $1: 'clang' => clang & libc++ case "$4" in 'examples') - examples="TRUE" + examples="ON" makeopts="" # NB: cannot use -j8 here because it bugs with cocoa example... ;; 'no examples') - examples="FALSE" + examples="OFF" makeopts="-j8" ;; *) @@ -261,10 +261,10 @@ build_sfml () # $1: 'clang' => clang & libc++ case "$5" in 'templates') - templates="TRUE" + templates="ON" ;; 'no templates') - templates="FALSE" + templates="OFF" ;; *) error "Unknown option for $5 in create_makefile" @@ -285,7 +285,7 @@ build_sfml () # $1: 'clang' => clang & libc++ push_pwd "$cmakedir" cmake -G "Unix Makefiles" \ - -D "BUILD_SHARED_LIBS:BOOL=TRUE" \ + -D "BUILD_SHARED_LIBS:BOOL=ON" \ -D "CMAKE_BUILD_TYPE:STRING=Release" \ -D "CMAKE_CXX_COMPILER:FILEPATH=/usr/bin/$cxx" \ -D "CMAKE_CXX_FLAGS:STRING=$cxx_flags" \ @@ -334,10 +334,10 @@ build_csfml () # $1: 'clang' => clang & libc++ case "$2" in 'doc') - doc="TRUE" + doc="ON" ;; 'no doc') - doc="FALSE" + doc="OFF" ;; *) error "Unknown option for $2 in create_makefile" @@ -360,7 +360,7 @@ build_csfml () # $1: 'clang' => clang & libc++ push_pwd "$cmakedir" cmake -G "Unix Makefiles" \ - -D "BUILD_SHARED_LIBS:BOOL=TRUE" \ + -D "BUILD_SHARED_LIBS:BOOL=ON" \ -D "CMAKE_BUILD_TYPE:STRING=Release" \ -D "CMAKE_CXX_COMPILER:FILEPATH=/usr/bin/$cxx" \ -D "CMAKE_CXX_FLAGS:STRING=$cxx_flags" \