Update CMakeLists.txt
This commit is contained in:
parent
44adcb14f1
commit
2dd0790cb2
@ -1,7 +1,15 @@
|
||||
cmake_minimum_required(VERSION 3.2)
|
||||
|
||||
option(JSON_VALIDATOR_BUILD_TESTS "Build tests" ON)
|
||||
option(JSON_VALIDATOR_BUILD_EXAMPLES "Build examples" ON)
|
||||
# disable tests and examples if project is not super project
|
||||
set(JSON_VALIDATOR_IS_TOP_LEVEL OFF)
|
||||
if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
|
||||
# I am top-level project.
|
||||
set(JSON_VALIDATOR_IS_TOP_LEVEL ON)
|
||||
endif()
|
||||
|
||||
option(JSON_VALIDATOR_BUILD_TESTS "Build tests" ${JSON_VALIDATOR_IS_TOP_LEVEL})
|
||||
option(JSON_VALIDATOR_BUILD_EXAMPLES "Build examples" ${JSON_VALIDATOR_IS_TOP_LEVEL})
|
||||
option(JSON_VALIDATOR_INSTALL "Install CMake targets during install step." ${JSON_VALIDATOR_IS_TOP_LEVEL})
|
||||
option(JSON_VALIDATOR_HUNTER "Enable Hunter package manager support" OFF)
|
||||
|
||||
if(JSON_VALIDATOR_HUNTER)
|
||||
@ -44,20 +52,6 @@ set_target_properties(nlohmann_json_schema_validator
|
||||
VERSION ${PROJECT_VERSION}
|
||||
SOVERSION 1)
|
||||
|
||||
# disable tests and examples if project is not super project
|
||||
if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
|
||||
# I am top-level project.
|
||||
set(JSON_VALIDATOR_IS_TOP_LEVEL TRUE)
|
||||
endif()
|
||||
|
||||
if(JSON_VALIDATOR_IS_TOP_LEVEL)
|
||||
set(JSON_VALIDATOR_BUILD_TESTS ON)
|
||||
set(JSON_VALIDATOR_BUILD_EXAMPLES ON)
|
||||
else()
|
||||
set(JSON_VALIDATOR_BUILD_TESTS OFF)
|
||||
set(JSON_VALIDATOR_BUILD_EXAMPLES OFF)
|
||||
endif()
|
||||
|
||||
if(NOT TARGET nlohmann_json::nlohmann_json)
|
||||
find_package(nlohmann_json REQUIRED)
|
||||
endif()
|
||||
@ -95,15 +89,6 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
install(TARGETS nlohmann_json_schema_validator
|
||||
EXPORT ${PROJECT_NAME}Targets
|
||||
LIBRARY DESTINATION lib
|
||||
ARCHIVE DESTINATION lib
|
||||
RUNTIME DESTINATION bin)
|
||||
|
||||
install(FILES src/nlohmann/json-schema.hpp
|
||||
DESTINATION include/nlohmann)
|
||||
|
||||
if (JSON_VALIDATOR_BUILD_EXAMPLES)
|
||||
# simple nlohmann_json_schema_validator-executable
|
||||
add_executable(json-schema-validate app/json-schema-validate.cpp)
|
||||
@ -114,9 +99,6 @@ if (JSON_VALIDATOR_BUILD_EXAMPLES)
|
||||
|
||||
add_executable(format-json-schema app/format.cpp)
|
||||
target_link_libraries(format-json-schema nlohmann_json_schema_validator)
|
||||
|
||||
install(TARGETS json-schema-validate readme-json-schema
|
||||
DESTINATION bin)
|
||||
endif()
|
||||
|
||||
if (JSON_VALIDATOR_BUILD_TESTS)
|
||||
@ -125,6 +107,21 @@ if (JSON_VALIDATOR_BUILD_TESTS)
|
||||
add_subdirectory(test)
|
||||
endif()
|
||||
|
||||
if(JSON_VALIDATOR_INSTALL)
|
||||
install(TARGETS nlohmann_json_schema_validator
|
||||
EXPORT ${PROJECT_NAME}Targets
|
||||
LIBRARY DESTINATION lib
|
||||
ARCHIVE DESTINATION lib
|
||||
RUNTIME DESTINATION bin)
|
||||
|
||||
install(FILES src/nlohmann/json-schema.hpp
|
||||
DESTINATION include/nlohmann)
|
||||
|
||||
if (JSON_VALIDATOR_BUILD_EXAMPLES)
|
||||
install(TARGETS json-schema-validate readme-json-schema
|
||||
DESTINATION bin)
|
||||
endif()
|
||||
|
||||
# Set Up the Project Targets and Config Files for CMake
|
||||
|
||||
# Set the install path to the cmake config files (Relative, so install works correctly under Hunter as well)
|
||||
@ -156,3 +153,4 @@ install(
|
||||
DESTINATION
|
||||
${INSTALL_CMAKE_DIR}
|
||||
)
|
||||
endif()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user