fix / workaround for #79
This commit is contained in:
parent
5976915897
commit
2969393afa
@ -29,6 +29,10 @@ set_target_properties(nlohmann_json_schema_validator
|
||||
VERSION ${PROJECT_VERSION}
|
||||
SOVERSION 1)
|
||||
|
||||
# if used as a sub-directory, do not create install-rules -
|
||||
# because of the dependency to nlohmann_json.
|
||||
set(JSON_VALIDATOR_INSTALL ON)
|
||||
|
||||
# here we decice how nlohmann::json is found and used to build this project
|
||||
|
||||
# first, check whether a nlohmann_json::nlohmann_json target exists already
|
||||
@ -39,11 +43,15 @@ if(TARGET nlohmann_json::nlohmann_json)
|
||||
nlohmann_json_schema_validator
|
||||
PUBLIC nlohmann_json::nlohmann_json)
|
||||
|
||||
set(JSON_VALIDATOR_INSTALL OFF)
|
||||
|
||||
elseif(TARGET nlohmann_json) # or nlohmann_json, we are used a sub-project next to nlohmann-json's git repo
|
||||
message(STATUS "Found nlohmann_json-target - linking with it")
|
||||
target_link_libraries(
|
||||
nlohmann_json_schema_validator
|
||||
PUBLIC nlohmann_json)
|
||||
set(JSON_VALIDATOR_INSTALL OFF)
|
||||
|
||||
else()
|
||||
if (NOT IS_ABSOLUTE ${nlohmann_json_DIR}) # make nlohmann_json_DIR absolute
|
||||
get_filename_component(nlohmann_json_DIR
|
||||
@ -113,6 +121,7 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(JSON_VALIDATOR_INSTALL)
|
||||
install(TARGETS nlohmann_json_schema_validator
|
||||
EXPORT ${PROJECT_NAME}Targets
|
||||
LIBRARY DESTINATION lib
|
||||
@ -121,6 +130,7 @@ install(TARGETS nlohmann_json_schema_validator
|
||||
|
||||
install(FILES src/nlohmann/json-schema.hpp
|
||||
DESTINATION include/nlohmann)
|
||||
endif()
|
||||
|
||||
if (BUILD_EXAMPLES)
|
||||
# simple nlohmann_json_schema_validator-executable
|
||||
@ -139,9 +149,9 @@ if (BUILD_TESTS)
|
||||
enable_testing()
|
||||
add_subdirectory(test)
|
||||
endif()
|
||||
#---------------------------------------------------------------------------##
|
||||
|
||||
if(JSON_VALIDATOR_INSTALL)
|
||||
# Set Up the Project Targets and Config Files for CMake
|
||||
#---------------------------------------------------------------------------##
|
||||
|
||||
# Set the install path to the cmake config files
|
||||
set(INSTALL_CMAKE_DIR ${CMAKE_INSTALL_PREFIX}/lib/cmake/${PROJECT_NAME})
|
||||
@ -171,3 +181,4 @@ install(FILES
|
||||
install(EXPORT ${PROJECT_NAME}Targets
|
||||
FILE ${PROJECT_NAME}Targets.cmake
|
||||
DESTINATION "${INSTALL_CMAKE_DIR}")
|
||||
endif()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user