18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-11-27 21:45:16 +01:00

build: optionally use the system nlohmann_json (USE_SYSTEM_JSON) (#360)

USE_SYSTEM_JSON (default OFF) takes an installed nlohmann_json 3.9 or newer (ordered_json, used by the unit tests) with find_package instead of the ref/json submodule. Both give the nlohmann_json::nlohmann_json target linked to eu07_settings. Drop the include directory from the never defined NLOHMANN_JSON_INCLUDE_INSTALL_DIR. Fixes #54.
This commit is contained in:
jerrrrycho
2026-11-20 16:34:04 +01:00
committed by GitHub
parent 96bc3e6863
commit 8bff785886
2 changed files with 9 additions and 3 deletions

View File

@@ -86,6 +86,7 @@ option(ENABLE_MCC "Enable multicore compilation" ON)
option(WITHDUMPGEN "Enable generating DMP files on crash" ON)
option(ENABLE_AVX2 "Enable AVX2 instruction set (requires AVX2-capable CPU, Haswell/2013 or newer)" ON)
option(ADD_VERSION_SUFFIX "Add date and commit hash to the executable name" ON)
option(USE_SYSTEM_JSON "Use an installed nlohmann_json (3.9 or newer) instead of the ref/json submodule" OFF)
set(BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
# vcpkg init
@@ -698,10 +699,14 @@ target_link_libraries(eu07_settings INTERFACE Threads::Threads)
find_package(GLM REQUIRED)
target_include_directories(eu07_settings INTERFACE ${GLM_INCLUDE_DIR})
# JSON lib
add_subdirectory(ref/json)
# JSON lib: the ref/json submodule by default, or an installed package (e.g. nlohmann-json3-dev, vcpkg nlohmann-json).
# Both give the nlohmann_json::nlohmann_json target; 3.9 is the first release with ordered_json, used by the unit tests.
if (USE_SYSTEM_JSON)
find_package(nlohmann_json 3.9 REQUIRED)
else()
add_subdirectory(ref/json)
endif()
target_link_libraries(eu07_settings INTERFACE nlohmann_json::nlohmann_json)
target_include_directories(eu07_settings INTERFACE ${NLOHMANN_JSON_INCLUDE_INSTALL_DIR})

View File

@@ -101,6 +101,7 @@ MaSzyna compiles and runs natively on **Linux** and **Windows**. Other platforms
| `-DCMAKE_BUILD_TYPE=Release` | Release build |
| `-DCMAKE_BUILD_TYPE=RelWithDebInfo` | Release build with debug symbols |
| `-DWITH_BETTER_RENDERER=ON/OFF` | Enable/disable NVRHI-based renderer |
| `-DUSE_SYSTEM_JSON=ON/OFF` | Use an installed **nlohmann_json** 3.9 or newer (e.g. `nlohmann-json3-dev`, vcpkg `nlohmann-json`) instead of the `ref/json` submodule (default `OFF`) |
| `-DPython3_ROOT_DIR=<path>` | Root of the **Python 3.14** install on Windows (`python.exe`, `Lib`, `DLLs`) for embed/copy steps; on Linux, optional if CMake picks the wrong interpreter |
> **Linux note:** `WITH_BETTER_RENDERER` uses DirectX 12 through NVRHI and is **not supported on Linux**.