cmake: add option to disable installing targets

This commit is contained in:
res0nance 2022-08-26 20:19:38 +08:00 committed by Patrick Boettcher
parent c7325ae932
commit 5ec1961439

View File

@ -2,6 +2,7 @@ cmake_minimum_required(VERSION 3.2)
option(JSON_VALIDATOR_BUILD_TESTS "Build tests" ON)
option(JSON_VALIDATOR_BUILD_EXAMPLES "Build examples" ON)
option(JSON_VALIDATOR_INSTALL "Install target" ON)
option(JSON_VALIDATOR_HUNTER "Enable Hunter package manager support" OFF)
if(JSON_VALIDATOR_HUNTER)
@ -95,6 +96,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
@ -103,6 +105,7 @@ install(TARGETS nlohmann_json_schema_validator
install(FILES src/nlohmann/json-schema.hpp
DESTINATION include/nlohmann)
endif()
if (JSON_VALIDATOR_BUILD_EXAMPLES)
# simple nlohmann_json_schema_validator-executable
@ -127,6 +130,7 @@ endif()
# Set Up the Project Targets and Config Files for CMake
if(JSON_VALIDATOR_INSTALL)
# Set the install path to the cmake config files (Relative, so install works correctly under Hunter as well)
set(INSTALL_CMAKE_DIR "lib/cmake/${PROJECT_NAME}")
set(INSTALL_CMAKEDIR_ROOT share/cmake)
@ -156,3 +160,4 @@ install(
DESTINATION
${INSTALL_CMAKE_DIR}
)
endif()