@@ -2,6 +2,7 @@ cmake_minimum_required(VERSION 3.2)
2
2
3
3
option (JSON_VALIDATOR_BUILD_TESTS "Build tests" ON )
4
4
option (JSON_VALIDATOR_BUILD_EXAMPLES "Build examples" ON )
5
+ option (JSON_VALIDATOR_INSTALL "Install target" ON )
5
6
option (JSON_VALIDATOR_HUNTER "Enable Hunter package manager support" OFF )
6
7
7
8
if (JSON_VALIDATOR_HUNTER)
@@ -95,14 +96,16 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
95
96
endif ()
96
97
endif ()
97
98
98
- install (TARGETS nlohmann_json_schema_validator
99
- EXPORT ${PROJECT_NAME} Targets
100
- LIBRARY DESTINATION lib
101
- ARCHIVE DESTINATION lib
102
- RUNTIME DESTINATION bin)
99
+ if (JSON_VALIDATOR_INSTALL)
100
+ install (TARGETS nlohmann_json_schema_validator
101
+ EXPORT ${PROJECT_NAME} Targets
102
+ LIBRARY DESTINATION lib
103
+ ARCHIVE DESTINATION lib
104
+ RUNTIME DESTINATION bin)
103
105
104
- install (FILES src/nlohmann/json-schema.hpp
105
- DESTINATION include /nlohmann)
106
+ install (FILES src/nlohmann/json-schema.hpp
107
+ DESTINATION include /nlohmann)
108
+ endif ()
106
109
107
110
if (JSON_VALIDATOR_BUILD_EXAMPLES)
108
111
# simple nlohmann_json_schema_validator-executable
@@ -127,32 +130,34 @@ endif()
127
130
128
131
# Set Up the Project Targets and Config Files for CMake
129
132
130
- # Set the install path to the cmake config files (Relative, so install works correctly under Hunter as well)
131
- set (INSTALL_CMAKE_DIR "lib/cmake/${PROJECT_NAME} " )
132
- set (INSTALL_CMAKEDIR_ROOT share/cmake)
133
-
134
- # Install Targets
135
- install (EXPORT ${PROJECT_NAME} Targets
136
- FILE ${PROJECT_NAME} Targets.cmake
137
- DESTINATION "${INSTALL_CMAKE_DIR} " )
133
+ if (JSON_VALIDATOR_INSTALL)
134
+ # Set the install path to the cmake config files (Relative, so install works correctly under Hunter as well)
135
+ set (INSTALL_CMAKE_DIR "lib/cmake/${PROJECT_NAME} " )
136
+ set (INSTALL_CMAKEDIR_ROOT share/cmake)
138
137
139
- include (CMakePackageConfigHelpers)
140
- write_basic_package_version_file(
141
- ${CMAKE_CURRENT_BINARY_DIR} /${PROJECT_NAME} ConfigVersion.cmake
142
- VERSION ${PROJECT_VERSION}
143
- COMPATIBILITY SameMajorVersion
144
- )
138
+ # Install Targets
139
+ install (EXPORT ${PROJECT_NAME} Targets
140
+ FILE ${PROJECT_NAME} Targets.cmake
141
+ DESTINATION "${INSTALL_CMAKE_DIR} " )
145
142
146
- configure_package_config_file(
147
- ${PROJECT_SOURCE_DIR} /${PROJECT_NAME} Config.cmake.in
148
- ${CMAKE_CURRENT_BINARY_DIR} /${PROJECT_NAME} Config.cmake
149
- INSTALL_DESTINATION ${INSTALL_CMAKEDIR_ROOT} /${PROJECT_NAME}
150
- )
143
+ include (CMakePackageConfigHelpers)
144
+ write_basic_package_version_file(
145
+ ${CMAKE_CURRENT_BINARY_DIR} /${PROJECT_NAME} ConfigVersion.cmake
146
+ VERSION ${PROJECT_VERSION}
147
+ COMPATIBILITY SameMajorVersion
148
+ )
151
149
152
- install (
153
- FILES
150
+ configure_package_config_file (
151
+ ${PROJECT_SOURCE_DIR} / ${PROJECT_NAME} Config.cmake.in
154
152
${CMAKE_CURRENT_BINARY_DIR} /${PROJECT_NAME} Config.cmake
155
- ${CMAKE_CURRENT_BINARY_DIR} /${PROJECT_NAME} ConfigVersion.cmake
156
- DESTINATION
157
- ${INSTALL_CMAKE_DIR}
158
- )
153
+ INSTALL_DESTINATION ${INSTALL_CMAKEDIR_ROOT} /${PROJECT_NAME}
154
+ )
155
+
156
+ install (
157
+ FILES
158
+ ${CMAKE_CURRENT_BINARY_DIR} /${PROJECT_NAME} Config.cmake
159
+ ${CMAKE_CURRENT_BINARY_DIR} /${PROJECT_NAME} ConfigVersion.cmake
160
+ DESTINATION
161
+ ${INSTALL_CMAKE_DIR}
162
+ )
163
+ endif ()
0 commit comments