cmake: use FetchContent for some dependencies (#6560)

this transition is _not_ complete, but we use FetchContent for
RapidJSON, PajladaSerialize, PajladaSettings, and PajladaSignals.

In the future, we can move towards providing as many of our dependencies
as possible through conan & vcpkg so submodule-less builds are possible.
This commit is contained in:
pajlada
2025-11-02 21:45:27 +01:00
committed by GitHub
parent 072bc897a0
commit e7668212bd
12 changed files with 49 additions and 83 deletions
+28 -14
View File
@@ -2,6 +2,7 @@ cmake_minimum_required(VERSION 3.15)
cmake_policy(SET CMP0087 NEW) # evaluates generator expressions in `install(CODE/SCRIPT)`
cmake_policy(SET CMP0091 NEW) # select MSVC runtime library through `CMAKE_MSVC_RUNTIME_LIBRARY`
include(FeatureSummary)
include(FetchContent)
list(APPEND CMAKE_MODULE_PATH
"${CMAKE_SOURCE_DIR}/cmake"
@@ -195,8 +196,6 @@ if (BUILD_WITH_QTKEYCHAIN)
endif()
endif()
find_package(RapidJSON REQUIRED)
find_package(Websocketpp REQUIRED)
if (BUILD_TESTS)
@@ -224,23 +223,38 @@ if (BUILD_BENCHMARKS)
find_package(benchmark REQUIRED)
endif ()
find_package(PajladaSerialize REQUIRED)
find_package(PajladaSignals REQUIRED)
FetchContent_Declare(
rapidjson
SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/lib/rapidjson
EXCLUDE_FROM_ALL
FIND_PACKAGE_ARGS NAMES RapidJSON
)
set(RAPIDJSON_BUILD_EXAMPLES Off CACHE INTERNAL "")
set(RAPIDJSON_BUILD_TESTS Off CACHE INTERNAL "")
FetchContent_Declare(
PajladaSignals
SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/lib/signals
EXCLUDE_FROM_ALL
)
FetchContent_Declare(
PajladaSerialize
SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/lib/serialize
EXCLUDE_FROM_ALL
)
FetchContent_Declare(
PajladaSettings
SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/lib/settings
EXCLUDE_FROM_ALL
)
FetchContent_MakeAvailable(rapidjson PajladaSignals PajladaSerialize PajladaSettings)
find_package(LRUCache REQUIRED)
find_package(MagicEnum REQUIRED)
find_package(Doxygen)
find_package(BoostCertify REQUIRED)
if (USE_SYSTEM_PAJLADA_SETTINGS)
find_package(PajladaSettings REQUIRED)
else()
if (NOT EXISTS "${CMAKE_SOURCE_DIR}/lib/settings/CMakeLists.txt")
message(FATAL_ERROR "Submodules probably not loaded, unable to find lib/settings/CMakeLists.txt")
endif()
add_subdirectory("${CMAKE_SOURCE_DIR}/lib/settings" EXCLUDE_FROM_ALL)
endif()
if (CHATTERINO_PLUGINS)
set(LUA_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/lib/lua/src")
add_subdirectory(lib/lua)