mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-21 14:23:53 +00:00
cmake: add minimum required json version
This commit is contained in:
@@ -298,7 +298,9 @@ if(BUILD_IFCGEOM)
|
||||
endif()
|
||||
|
||||
if(GLTF_SUPPORT)
|
||||
find_package(nlohmann_json REQUIRED)
|
||||
# 3.6.1 is the version currently used on the Windows build.
|
||||
# 3.10.5 is the version shipped with Ubuntu 22.04.
|
||||
find_package(nlohmann_json 3.6.1 REQUIRED)
|
||||
endif()
|
||||
|
||||
# Add USD support to serializers
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
UNIFY_ENVVARS_AND_CACHE(JSON_INCLUDE_DIR)
|
||||
|
||||
if(NOT JSON_INCLUDE_DIR)
|
||||
find_package(nlohmann_json CONFIG)
|
||||
find_package(nlohmann_json ${nlohmann_json_FIND_VERSION} CONFIG)
|
||||
mark_as_advanced(nlohmann_json)
|
||||
if(nlohmann_json_DIR)
|
||||
return()
|
||||
@@ -21,7 +21,20 @@ find_path(json_header_path "nlohmann/json.hpp" HINTS "${JSON_INCLUDE_DIR}")
|
||||
mark_as_advanced(json_header_path)
|
||||
|
||||
if(json_header_path)
|
||||
message(STATUS "JSON for Modern C++ header file found in '${json_header_path}'.")
|
||||
file(STRINGS "${json_header_path}/nlohmann/json.hpp" json_version_major_line REGEX "^#define NLOHMANN_JSON_VERSION_MAJOR")
|
||||
file(STRINGS "${json_header_path}/nlohmann/json.hpp" json_version_minor_line REGEX "^#define NLOHMANN_JSON_VERSION_MINOR")
|
||||
file(STRINGS "${json_header_path}/nlohmann/json.hpp" json_version_patch_line REGEX "^#define NLOHMANN_JSON_VERSION_PATCH")
|
||||
string(REGEX REPLACE "^#define NLOHMANN_JSON_VERSION_MAJOR ([0-9]+)$" "\\1" json_version_major "${json_version_major_line}")
|
||||
string(REGEX REPLACE "^#define NLOHMANN_JSON_VERSION_MINOR ([0-9]+)$" "\\1" json_version_minor "${json_version_minor_line}")
|
||||
string(REGEX REPLACE "^#define NLOHMANN_JSON_VERSION_PATCH ([0-9]+)$" "\\1" json_version_patch "${json_version_patch_line}")
|
||||
set(nlohmann_json_VERSION "${json_version_major}.${json_version_minor}.${json_version_patch}")
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(nlohmann_json
|
||||
REQUIRED_VARS json_header_path
|
||||
VERSION_VAR nlohmann_json_VERSION
|
||||
)
|
||||
|
||||
add_library(nlohmann_json::nlohmann_json INTERFACE IMPORTED)
|
||||
target_include_directories(nlohmann_json::nlohmann_json INTERFACE ${json_header_path})
|
||||
return()
|
||||
|
||||
Reference in New Issue
Block a user