Skip to content

Commit 2ec9764

Browse files
committed
Add options to select the modules to build
1 parent 8c02b89 commit 2ec9764

File tree

2 files changed

+34
-5
lines changed

2 files changed

+34
-5
lines changed

CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ include(GNUInstallDirs)
2323
# include the configuration file
2424
include(${PROJECT_SOURCE_DIR}/cmake/Config.cmake)
2525

26+
# add options to select which modules to build
27+
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.")
28+
csfml_set_option(CSFML_BUILD_GRAPHICS TRUE BOOL "TRUE to build CSFML's Graphics module.")
29+
csfml_set_option(CSFML_BUILD_AUDIO TRUE BOOL "TRUE to build CSFML's Audio module.")
30+
csfml_set_option(CSFML_BUILD_NETWORK TRUE BOOL "TRUE to build CSFML's Network module.")
31+
2632
# add an option for choosing the build type (shared or static)
2733
csfml_set_option(BUILD_SHARED_LIBS TRUE BOOL "TRUE to build CSFML as shared libraries, FALSE to build it as static libraries")
2834

src/SFML/CMakeLists.txt

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,37 @@ if(CSFML_LINK_SFML_STATICALLY)
2121
set(SFML_STATIC_LIBRARIES TRUE)
2222
add_definitions(-DSFML_STATIC)
2323
endif()
24-
find_package(SFML 2.6 COMPONENTS network graphics audio REQUIRED)
24+
set(SFML_MODULES "system")
25+
if(CSFML_BUILD_AUDIO)
26+
list(PREPEND SFML_MODULES "audio")
27+
endif()
28+
if(CSFML_BUILD_GRAPHICS)
29+
list(PREPEND SFML_MODULES "graphics")
30+
endif()
31+
if(CSFML_BUILD_NETWORK)
32+
list(PREPEND SFML_MODULES "network")
33+
endif()
34+
find_package(SFML 2.6 COMPONENTS ${SFML_MODULES} REQUIRED)
2535

2636
# add the modules subdirectories
2737
add_subdirectory(System)
28-
add_subdirectory(Window)
29-
add_subdirectory(Network)
30-
add_subdirectory(Graphics)
31-
add_subdirectory(Audio)
38+
39+
if(CSFML_BUILD_WINDOW OR SFML_BUILD_GRAPHICS)
40+
add_subdirectory(Window)
41+
endif()
42+
43+
if(CSFML_BUILD_NETWORK)
44+
add_subdirectory(Network)
45+
endif()
46+
47+
if(CSFML_BUILD_GRAPHICS)
48+
add_subdirectory(Graphics)
49+
endif()
50+
51+
if(CSFML_BUILD_AUDIO)
52+
add_subdirectory(Audio)
53+
endif()
54+
3255
if(SFML_OS_WINDOWS)
3356
add_subdirectory(Main)
3457
endif()

0 commit comments

Comments
 (0)