11cmake_minimum_required (VERSION 3.21 )
2- project (saucer-bindings LANGUAGES CXX VERSION 8.0.2 )
2+ project (saucer-bindings LANGUAGES CXX VERSION 8.0.3 )
33
44# +-------------------------------------------------------------------------------------------------------+
55# | Library switches |
66# +-------------------------------------------------------------------------------------------------------+
77
8- option (saucer_desktop "Enable support for the desktop module" ON )
9- option (saucer_pdf "Enable support for the pdf module" ON )
10- option (saucer_loop "Enable support for the loop module" ON )
8+ option (saucer_bindings_static "Build saucer as a static library" OFF )
9+
10+ # +-------------------------------------------------------------------------------------------------------+
11+ # | Library options |
12+ # +-------------------------------------------------------------------------------------------------------+
13+
14+ set (saucer_bindings_modules "desktop;pdf;loop" CACHE STRING "A list of modules to build" )
15+ set (saucer_bindings_inline_modules "" CACHE STRING "A list of modules to inline into the built library" )
16+
17+ # +-------------------------------------------------------------------------------------------------------+
18+ # | Convenience wrapper over `message` |
19+ # +-------------------------------------------------------------------------------------------------------+
20+
21+ function (bindings_message LEVEL MESSAGE )
22+ message (${LEVEL} "saucer-bindings: ${MESSAGE} " )
23+ endfunction ()
24+
25+ # +-------------------------------------------------------------------------------------------------------+
26+ # | Ensure valid library options |
27+ # +-------------------------------------------------------------------------------------------------------+
28+
29+ set (saucer_bindings_valid_modules desktop pdf loop)
30+
31+ set_property (CACHE saucer_bindings_modules PROPERTY STRINGS ${saucer_bindings_valid_modules} )
32+ set_property (CACHE saucer_bindings_inline_modules PROPERTY STRINGS ${saucer_bindings_valid_modules} )
33+
34+ foreach (value IN LISTS saucer_bindings_modules)
35+ if (value IN_LIST saucer_bindings_valid_modules)
36+ continue ()
37+ endif ()
38+
39+ bindings_message (FATAL_ERROR "Bad module (${value} ) expected one or multiple of ${saucer_bindings_valid_modules} " )
40+ endforeach ()
41+
42+ foreach (value IN LISTS saucer_bindings_inline_modules)
43+ if (value IN_LIST saucer_bindings_valid_modules)
44+ continue ()
45+ endif ()
46+
47+ bindings_message (FATAL_ERROR "Bad inline module (${value} ) expected one or multiple of ${saucer_bindings_valid_modules} " )
48+ endforeach ()
49+
50+ if (saucer_bindings_static)
51+ bindings_message (WARNING "Building saucer as static library..." )
52+ bindings_message (WARNING "This is not recommended as it can lead to duplicated symbols!" )
53+ endif ()
1154
1255# +-------------------------------------------------------------------------------------------------------+
1356# | CMake options |
@@ -82,9 +125,9 @@ include("cmake/cpm.cmake")
82125
83126CPMFindPackage (
84127 NAME saucer
85- VERSION 8.0.2
128+ VERSION 8.0.3
86129 GIT_REPOSITORY "https://github.com/saucer/saucer"
87- OPTIONS "saucer_static OFF " "CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON"
130+ OPTIONS "saucer_static ${saucer_bindings_static} " "CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON"
88131)
89132
90133target_link_libraries (${PROJECT_NAME} PUBLIC saucer::saucer saucer::private )
@@ -107,14 +150,7 @@ endif()
107150
108151include ("cmake/module.cmake" )
109152
110- if (saucer_desktop )
111- add_subdirectory ("modules/desktop " )
112- endif ()
153+ foreach (module IN LISTS saucer_bindings_modules )
154+ add_subdirectory ("modules/${module} " )
155+ endforeach ()
113156
114- if (saucer_pdf)
115- add_subdirectory ("modules/pdf" )
116- endif ()
117-
118- if (saucer_loop)
119- add_subdirectory ("modules/loop" )
120- endif ()
0 commit comments