Findnlohmann_json.cmake

This commit is contained in:
Andrej730
2025-12-05 15:26:48 +05:00
parent c2a03eb658
commit 1ad1883f0e
5 changed files with 37 additions and 28 deletions
+4 -22
View File
@@ -213,28 +213,10 @@ if(BUILD_IFCGEOM AND WITH_OPENCASCADE)
list(APPEND GEOMETRY_KERNELS opencascade)
endif()
set(GLTF_LIBRARIES "")
if(GLTF_SUPPORT)
UNIFY_ENVVARS_AND_CACHE(JSON_INCLUDE_DIR)
if(NOT JSON_INCLUDE_DIR)
find_package(nlohmann_json CONFIG)
if(nlohmann_json_DIR)
link_libraries(nlohmann_json::nlohmann_json)
else()
message(STATUS "Unable to find nlohmann_json package, trying to find it as a header-only library.")
endif()
endif()
if(NOT nlohmann_json_DIR)
find_path(json_header_path "nlohmann/json.hpp" HINTS ${JSON_INCLUDE_DIR})
set(JSON_INCLUDE_DIR ${json_header_path})
if(json_header_path)
message(STATUS "JSON for Modern C++ header file found in '${JSON_INCLUDE_DIR}'.")
else()
message(FATAL_ERROR "Unable to find JSON for Modern C++ header file / package, aborting")
endif()
endif()
find_package(nlohmann_json REQUIRED)
set(GLTF_LIBRARIES nlohmann_json::nlohmann_json)
add_definitions(-DWITH_GLTF)
set(SWIG_DEFINES ${SWIG_DEFINES} -DWITH_GLTF)
endif()
@@ -449,7 +431,7 @@ else()
endif(MSVC)
include_directories(${OPENCOLLADA_INCLUDE_DIRS}
${Boost_INCLUDE_DIRS} ${JSON_INCLUDE_DIR} ${HDF5_INCLUDE_DIR}
${Boost_INCLUDE_DIRS} ${HDF5_INCLUDE_DIR}
${USD_INCLUDE_DIR}
${TBB_INCLUDE_DIR}
)
+28
View File
@@ -0,0 +1,28 @@
#
# Input variables:
# - `JSON_INCLUDE_DIR`
# If input variables are not specified, try to find nlohmann_json config.
# Input variables could also be provided as environment variables.
#
# Output targets:
# - `nlohmann_json::nlohmann_json`
UNIFY_ENVVARS_AND_CACHE(JSON_INCLUDE_DIR)
if(NOT JSON_INCLUDE_DIR)
find_package(nlohmann_json CONFIG)
if(nlohmann_json_DIR)
return()
endif()
endif()
find_path(json_header_path "nlohmann/json.hpp" HINTS "${JSON_INCLUDE_DIR}")
if(json_header_path)
message(STATUS "JSON for Modern C++ header file found in '${json_header_path}'.")
add_library(nlohmann_json::nlohmann_json INTERFACE IMPORTED)
target_include_directories(nlohmann_json::nlohmann_json INTERFACE ${json_header_path})
return()
endif()
message(FATAL_ERROR "Unable to find JSON for Modern C++ header file / package, aborting")
+1 -1
View File
@@ -13,7 +13,7 @@ target_link_libraries(IfcConvert
PRIVATE
IfcGeom IfcParse Serializers
${OpenCASCADE_LIBRARIES} ${Boost_LIBRARIES} ${HDF5_LIBRARIES} ${USD_LIBRARIES}
${CGAL_LIBRARIES}
${CGAL_LIBRARIES} ${GLTF_LIBRARIES}
)
install(TARGETS IfcConvert)
+1 -1
View File
@@ -19,7 +19,7 @@ endif()
target_link_libraries(Serializers
PRIVATE
${SERIALIZER_SCHEMA_LIBRARIES} ${OPENCOLLADA_LIBRARIES} ${USD_LIBRARIES}
${SERIALIZER_SCHEMA_LIBRARIES} ${OPENCOLLADA_LIBRARIES} ${USD_LIBRARIES} ${GLTF_LIBRARIES}
IfcGeom ${OpenCASCADE_LIBRARIES} ${kernel_libraries} IfcParse
)
@@ -6,10 +6,9 @@ foreach(schema ${SCHEMA_VERSIONS})
add_library(Serializers_ifc${schema} OBJECT ${SERIALIZERS_S_FILES})
set(SERIALIZER_SCHEMA_LIBRARIES ${SERIALIZER_SCHEMA_LIBRARIES} Serializers_ifc${schema})
set_target_properties(Serializers_ifc${schema} PROPERTIES COMPILE_FLAGS "-DIFC_GEOM_EXPORTS -DIfcSchema=Ifc${schema}")
if(WASM_BUILD)
target_link_libraries(Serializers_ifc${schema} ${HDF5_LIBRARIES})
else()
target_link_libraries(Serializers_ifc${schema} IfcGeom ${OpenCASCADE_LIBRARIES} ${HDF5_LIBRARIES})
target_link_libraries(Serializers_ifc${schema} ${HDF5_LIBRARIES} ${GLTF_LIBRARIES})
if(NOT WASM_BUILD)
target_link_libraries(Serializers_ifc${schema} IfcGeom ${OpenCASCADE_LIBRARIES})
endif()
endforeach()