@@ -35,8 +35,6 @@ option(skyr_BUILD_WITHOUT_EXCEPTIONS "Build without exceptions." OFF)
3535option (skyr_BUILD_WITHOUT_RTTI "Build without RTTI." OFF )
3636option (skyr_USE_STATIC_CRT "Use static C Runtime library (/MT or MTd)." ON )
3737option (skyr_BUILD_WITH_LLVM_LIBCXX "Instruct Clang to use LLVM's implementation of C++ standard library" OFF )
38- option (skyr_ENABLE_FILESYSTEM_FUNCTIONS "Enable functions to convert URL to std::filesystem::path" ON )
39- option (skyr_ENABLE_JSON_FUNCTIONS "Enable functions to convert URL components to JSON" ON )
4038option (skyr_ENABLE_SANITIZERS "Enable sanitizers (address, undefined, etc.) for tests and examples" OFF )
4139option (skyr_CXX_STANDARD_LIBRARY "Path to non-system C++ standard library" "" )
4240
@@ -51,13 +49,14 @@ if (skyr_IS_TOP_LEVEL_PROJECT)
5149 set (CMAKE_CXX_STANDARD_REQUIRED ON )
5250endif ()
5351
54- if (skyr_ENABLE_JSON_FUNCTIONS)
55- find_package (nlohmann_json CONFIG )
56- if (NOT nlohmann_json_FOUND)
57- message (WARNING "nlohmann_json not found. Install with: vcpkg install nlohmann-json" )
58- message (WARNING "JSON functions will be disabled." )
59- set (skyr_ENABLE_JSON_FUNCTIONS OFF )
60- endif ()
52+ # JSON functions are optional and only available if nlohmann_json is found
53+ find_package (nlohmann_json CONFIG )
54+ if (NOT nlohmann_json_FOUND)
55+ message (WARNING "nlohmann_json not found. Install with: vcpkg install nlohmann-json" )
56+ message (WARNING "JSON functions will be disabled." )
57+ set (skyr_HAS_JSON_SUPPORT OFF )
58+ else ()
59+ set (skyr_HAS_JSON_SUPPORT ON )
6160endif ()
6261
6362if (skyr_USE_STATIC_CRT AND (CMAKE_CXX_COMPILER_ID MATCHES "MSVC" OR CMAKE_CXX_SIMULATE_ID MATCHES "MSVC" ))
@@ -129,11 +128,8 @@ write_basic_package_version_file(
129128 COMPATIBILITY SameMajorVersion
130129 ARCH_INDEPENDENT )
131130
132- set (skyr_TARGETS skyr-url)
133- if (skyr_ENABLE_FILESYSTEM_FUNCTIONS)
134- list (APPEND skyr_TARGETS skyr-filesystem)
135- endif ()
136- if (skyr_ENABLE_JSON_FUNCTIONS)
131+ set (skyr_TARGETS skyr-url skyr-filesystem)
132+ if (skyr_HAS_JSON_SUPPORT)
137133 list (APPEND skyr_TARGETS skyr-json)
138134endif ()
139135
@@ -177,10 +173,10 @@ install(
177173 include/skyr
178174)
179175
180- if (skyr_ENABLE_FILESYSTEM_FUNCTIONS)
181- install (DIRECTORY "${PROJECT_SOURCE_DIR} /include/skyr/filesystem" DESTINATION include/skyr)
182- endif ()
176+ # Filesystem functions are always installed (C++23 guarantees std::filesystem)
177+ install (DIRECTORY "${PROJECT_SOURCE_DIR} /include/skyr/filesystem" DESTINATION include/skyr)
183178
184- if (skyr_ENABLE_JSON_FUNCTIONS)
179+ # JSON functions are only installed if nlohmann_json is available
180+ if (skyr_HAS_JSON_SUPPORT)
185181 install (DIRECTORY "${PROJECT_SOURCE_DIR} /include/skyr/json" DESTINATION include/skyr)
186182endif ()
0 commit comments