diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2021-04-23 14:17:22 +0200 |
|---|---|---|
| committer | Even Rouault <even.rouault@spatialys.com> | 2021-04-30 13:27:25 +0200 |
| commit | 29ac85d55273e83a3ada19037959ae7c7823f5b7 (patch) | |
| tree | 060870053824413937ed2752e5b8f2c791e57530 /CMakeLists.txt | |
| parent | 36ac12c74210083ff3d699c9a57bf8b421939483 (diff) | |
| download | PROJ-29ac85d55273e83a3ada19037959ae7c7823f5b7.tar.gz PROJ-29ac85d55273e83a3ada19037959ae7c7823f5b7.zip | |
CMake build: add a NLOHMANN_JSON_ORIGIN=auto/external/internal setting allowing to choose which nlohmann/json to use
Co-authored-by: Mike Taves <mwtoews@gmail.com>
Diffstat (limited to 'CMakeLists.txt')
| -rw-r--r-- | CMakeLists.txt | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 66c5027f..67a8d2e1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -122,8 +122,48 @@ include(ProjMac) include(policies) ################################################################################ +# Check for nlohmann_json +################################################################################ + +set(NLOHMANN_JSON_ORIGIN "auto" CACHE STRING +"nlohmann/json origin. The default auto will try to use external \ +nlohmann/json if possible") +set_property(CACHE NLOHMANN_JSON_ORIGIN PROPERTY STRINGS auto internal external) + +# Probably not the strictest minimum, but known to work with it +set(MIN_NLOHMANN_JSON_VERSION 3.7.0) + +if(NLOHMANN_JSON_ORIGIN STREQUAL "external") + find_package(nlohmann_json REQUIRED) + set(NLOHMANN_JSON "external") +elseif(NLOHMANN_JSON_ORIGIN STREQUAL "internal") + set(NLOHMANN_JSON "internal") +else() + find_package(nlohmann_json QUIET) + if(nlohmann_json_FOUND) + set(NLOHMANN_JSON "external") + else() + set(NLOHMANN_JSON "internal") + endif() +endif() + +if(NLOHMANN_JSON STREQUAL "external") + # Check minimum version + if(nlohmann_json_VERSION VERSION_LESS MIN_NLOHMANN_JSON_VERSION) + message(STATUS "external nlohmann/json version ${nlohmann_json_VERSION} " + "is older than minimum requirement ${MIN_NLOHMANN_JSON_VERSION}") + set(NLOHMANN_JSON "internal") + else() + message(STATUS "found nlohmann/json version ${nlohmann_json_VERSION}") + endif() +endif() + +message(STATUS "nlohmann/json: ${NLOHMANN_JSON}") + +################################################################################ # Check for sqlite3 ################################################################################ + find_program(EXE_SQLITE3 sqlite3) if(NOT EXE_SQLITE3) message(SEND_ERROR "sqlite3 binary not found!") |
