From 2ec9764ac4535fbdd38638981795e866fec36beb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20D=C3=BCrrenberger?= Date: Sat, 18 May 2024 12:04:06 +0200 Subject: [PATCH] Add options to select the modules to build --- CMakeLists.txt | 6 ++++++ src/SFML/CMakeLists.txt | 33 ++++++++++++++++++++++++++++----- 2 files changed, 34 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fdc21d0..a3d0a4f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,6 +23,12 @@ include(GNUInstallDirs) # include the configuration file 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.") + # 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") diff --git a/src/SFML/CMakeLists.txt b/src/SFML/CMakeLists.txt index 251204d..4ae2f42 100644 --- a/src/SFML/CMakeLists.txt +++ b/src/SFML/CMakeLists.txt @@ -21,14 +21,37 @@ if(CSFML_LINK_SFML_STATICALLY) set(SFML_STATIC_LIBRARIES TRUE) add_definitions(-DSFML_STATIC) endif() -find_package(SFML 2.6 COMPONENTS network graphics audio REQUIRED) +set(SFML_MODULES "system") +if(CSFML_BUILD_AUDIO) + list(PREPEND SFML_MODULES "audio") +endif() +if(CSFML_BUILD_GRAPHICS) + list(PREPEND SFML_MODULES "graphics") +endif() +if(CSFML_BUILD_NETWORK) + list(PREPEND SFML_MODULES "network") +endif() +find_package(SFML 2.6 COMPONENTS ${SFML_MODULES} REQUIRED) # add the modules subdirectories add_subdirectory(System) -add_subdirectory(Window) -add_subdirectory(Network) -add_subdirectory(Graphics) -add_subdirectory(Audio) + +if(CSFML_BUILD_WINDOW OR SFML_BUILD_GRAPHICS) + add_subdirectory(Window) +endif() + +if(CSFML_BUILD_NETWORK) + add_subdirectory(Network) +endif() + +if(CSFML_BUILD_GRAPHICS) + add_subdirectory(Graphics) +endif() + +if(CSFML_BUILD_AUDIO) + add_subdirectory(Audio) +endif() + if(SFML_OS_WINDOWS) add_subdirectory(Main) endif()