@@ -8,6 +8,16 @@ cmake_minimum_required(VERSION 3.2)
8
8
option (BUILD_TESTS "Build tests" ON )
9
9
option (BUILD_EXAMPLES "Build examples" ON )
10
10
11
+ option (HUNTER_ENABLED "Enable Hunter package manager support" OFF )
12
+ if (HUNTER_ENABLED)
13
+ include (cmake/HunterGate.cmake)
14
+ HunterGate(URL https://github.com/cpp-pm/hunter/archive/v0.23.253.tar.gz
15
+ SHA1 88ea6d37c897a81a080eb9ae0f69d7807bbb3c73)
16
+
17
+ # Add nlohmann_json::nlohmann_json (if HUNTER_ENABLED=ON, otherwise command is ignored)
18
+ hunter_add_package(nlohmann_json)
19
+ endif ()
20
+
11
21
# the library
12
22
add_library (nlohmann_json_schema_validator
13
23
src/json-schema-draft7.json.cpp
@@ -158,8 +168,8 @@ endif()
158
168
if (JSON_VALIDATOR_INSTALL)
159
169
# Set Up the Project Targets and Config Files for CMake
160
170
161
- # Set the install path to the cmake config files
162
- set (INSTALL_CMAKE_DIR ${CMAKE_INSTALL_PREFIX} / lib/cmake/${PROJECT_NAME} )
171
+ # Set the install path to the cmake config files (Relative, so install works correctly under Hunter as well)
172
+ set (INSTALL_CMAKE_DIR " lib/cmake/${PROJECT_NAME} " )
163
173
164
174
# Create the ConfigVersion file
165
175
include (CMakePackageConfigHelpers) # write_basic_package_version_file
@@ -168,7 +178,7 @@ if(JSON_VALIDATOR_INSTALL)
168
178
COMPATIBILITY SameMajorVersion)
169
179
170
180
# Get the relative path from the INSTALL_CMAKE_DIR to the include directory
171
- file (RELATIVE_PATH REL_INCLUDE_DIR "${INSTALL_CMAKE_DIR} " "${CMAKE_INSTALL_PREFIX} /include" )
181
+ file (RELATIVE_PATH REL_INCLUDE_DIR "${CMAKE_INSTALL_PREFIX} / ${ INSTALL_CMAKE_DIR} " "${CMAKE_INSTALL_PREFIX} /include" )
172
182
173
183
174
184
# Configure the Config.cmake file with the proper include directory
0 commit comments