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}
|
VERSION ${PROJECT_VERSION}
|
||||||
SOVERSION 1)
|
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
|
# 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
|
# 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
|
nlohmann_json_schema_validator
|
||||||
PUBLIC nlohmann_json::nlohmann_json)
|
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
|
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")
|
message(STATUS "Found nlohmann_json-target - linking with it")
|
||||||
target_link_libraries(
|
target_link_libraries(
|
||||||
nlohmann_json_schema_validator
|
nlohmann_json_schema_validator
|
||||||
PUBLIC nlohmann_json)
|
PUBLIC nlohmann_json)
|
||||||
|
set(JSON_VALIDATOR_INSTALL OFF)
|
||||||
|
|
||||||
else()
|
else()
|
||||||
if (NOT IS_ABSOLUTE ${nlohmann_json_DIR}) # make nlohmann_json_DIR absolute
|
if (NOT IS_ABSOLUTE ${nlohmann_json_DIR}) # make nlohmann_json_DIR absolute
|
||||||
get_filename_component(nlohmann_json_DIR
|
get_filename_component(nlohmann_json_DIR
|
||||||
@ -113,14 +121,16 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
|||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
install(TARGETS nlohmann_json_schema_validator
|
if(JSON_VALIDATOR_INSTALL)
|
||||||
EXPORT ${PROJECT_NAME}Targets
|
install(TARGETS nlohmann_json_schema_validator
|
||||||
LIBRARY DESTINATION lib
|
EXPORT ${PROJECT_NAME}Targets
|
||||||
ARCHIVE DESTINATION lib
|
LIBRARY DESTINATION lib
|
||||||
RUNTIME DESTINATION bin)
|
ARCHIVE DESTINATION lib
|
||||||
|
RUNTIME DESTINATION bin)
|
||||||
|
|
||||||
install(FILES src/nlohmann/json-schema.hpp
|
install(FILES src/nlohmann/json-schema.hpp
|
||||||
DESTINATION include/nlohmann)
|
DESTINATION include/nlohmann)
|
||||||
|
endif()
|
||||||
|
|
||||||
if (BUILD_EXAMPLES)
|
if (BUILD_EXAMPLES)
|
||||||
# simple nlohmann_json_schema_validator-executable
|
# simple nlohmann_json_schema_validator-executable
|
||||||
@ -139,35 +149,36 @@ if (BUILD_TESTS)
|
|||||||
enable_testing()
|
enable_testing()
|
||||||
add_subdirectory(test)
|
add_subdirectory(test)
|
||||||
endif()
|
endif()
|
||||||
#---------------------------------------------------------------------------##
|
|
||||||
# Set Up the Project Targets and Config Files for CMake
|
|
||||||
#---------------------------------------------------------------------------##
|
|
||||||
|
|
||||||
# Set the install path to the cmake config files
|
if(JSON_VALIDATOR_INSTALL)
|
||||||
set(INSTALL_CMAKE_DIR ${CMAKE_INSTALL_PREFIX}/lib/cmake/${PROJECT_NAME})
|
# Set Up the Project Targets and Config Files for CMake
|
||||||
|
|
||||||
# Create the ConfigVersion file
|
# Set the install path to the cmake config files
|
||||||
include(CMakePackageConfigHelpers) # write_basic_package_version_file
|
set(INSTALL_CMAKE_DIR ${CMAKE_INSTALL_PREFIX}/lib/cmake/${PROJECT_NAME})
|
||||||
write_basic_package_version_file( ${PROJECT_NAME}ConfigVersion.cmake
|
|
||||||
VERSION ${PACKAGE_VERSION}
|
|
||||||
COMPATIBILITY SameMajorVersion)
|
|
||||||
|
|
||||||
# Get the relative path from the INSTALL_CMAKE_DIR to the include directory
|
# Create the ConfigVersion file
|
||||||
file(RELATIVE_PATH REL_INCLUDE_DIR "${INSTALL_CMAKE_DIR}" "${CMAKE_INSTALL_PREFIX}/include")
|
include(CMakePackageConfigHelpers) # write_basic_package_version_file
|
||||||
|
write_basic_package_version_file( ${PROJECT_NAME}ConfigVersion.cmake
|
||||||
|
VERSION ${PACKAGE_VERSION}
|
||||||
|
COMPATIBILITY SameMajorVersion)
|
||||||
|
|
||||||
|
# Get the relative path from the INSTALL_CMAKE_DIR to the include directory
|
||||||
|
file(RELATIVE_PATH REL_INCLUDE_DIR "${INSTALL_CMAKE_DIR}" "${CMAKE_INSTALL_PREFIX}/include")
|
||||||
|
|
||||||
|
|
||||||
# Configure the Config.cmake file with the proper include directory
|
# Configure the Config.cmake file with the proper include directory
|
||||||
set(CONF_INCLUDE_DIRS "\${JSON_SCHEMA_VALIDATOR_CMAKE_DIR}/${REL_INCLUDE_DIR}")
|
set(CONF_INCLUDE_DIRS "\${JSON_SCHEMA_VALIDATOR_CMAKE_DIR}/${REL_INCLUDE_DIR}")
|
||||||
configure_file(${PROJECT_NAME}Config.cmake.in
|
configure_file(${PROJECT_NAME}Config.cmake.in
|
||||||
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake" @ONLY)
|
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake" @ONLY)
|
||||||
|
|
||||||
# Install the Config.cmake and ConfigVersion.cmake files
|
# Install the Config.cmake and ConfigVersion.cmake files
|
||||||
install(FILES
|
install(FILES
|
||||||
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
|
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
|
||||||
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
|
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
|
||||||
DESTINATION "${INSTALL_CMAKE_DIR}")
|
DESTINATION "${INSTALL_CMAKE_DIR}")
|
||||||
|
|
||||||
# Install Targets
|
# Install Targets
|
||||||
install(EXPORT ${PROJECT_NAME}Targets
|
install(EXPORT ${PROJECT_NAME}Targets
|
||||||
FILE ${PROJECT_NAME}Targets.cmake
|
FILE ${PROJECT_NAME}Targets.cmake
|
||||||
DESTINATION "${INSTALL_CMAKE_DIR}")
|
DESTINATION "${INSTALL_CMAKE_DIR}")
|
||||||
|
endif()
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user