Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5775084

Browse files
committed
cmake: add option to use/install the non-amalgamated version
1 parent 84bffd5 commit 5775084

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

CMakeLists.txt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ include(ExternalProject)
1616
## OPTIONS
1717
##
1818
option(JSON_BuildTests "Build the unit tests when BUILD_TESTING is enabled." ON)
19+
option(JSON_MultipleHeaders "Use non-amalgamated version of the library." OFF)
1920

2021
##
2122
## CONFIGURATION
2223
##
2324
set(NLOHMANN_JSON_TARGET_NAME ${PROJECT_NAME})
24-
set(NLOHMANN_JSON_SOURCE_DIR "src/")
2525
set(NLOHMANN_JSON_CONFIG_INSTALL_DIR "lib/cmake/${PROJECT_NAME}")
2626
set(NLOHMANN_JSON_INCLUDE_INSTALL_DIR "include")
2727
set(NLOHMANN_JSON_HEADER_INSTALL_DIR "${NLOHMANN_JSON_INCLUDE_INSTALL_DIR}/nlohmann")
@@ -31,6 +31,12 @@ set(NLOHMANN_JSON_CMAKE_CONFIG_DIR "${CMAKE_CURRENT_BINARY_DIR}/cmake_c
3131
set(NLOHMANN_JSON_CMAKE_VERSION_CONFIG_FILE "${NLOHMANN_JSON_CMAKE_CONFIG_DIR}/${PROJECT_NAME}ConfigVersion.cmake")
3232
set(NLOHMANN_JSON_CMAKE_PROJECT_CONFIG_FILE "${NLOHMANN_JSON_CMAKE_CONFIG_DIR}/${PROJECT_NAME}Config.cmake")
3333

34+
if (JSON_MultipleHeaders)
35+
set(NLOHMANN_JSON_SOURCE_DIR "develop/")
36+
else()
37+
set(NLOHMANN_JSON_SOURCE_DIR "src/")
38+
endif()
39+
3440
##
3541
## TARGET
3642
## create target and add include path
@@ -40,7 +46,7 @@ add_library(${NLOHMANN_JSON_TARGET_NAME} INTERFACE)
4046
target_include_directories(
4147
${NLOHMANN_JSON_TARGET_NAME}
4248
INTERFACE
43-
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/src>
49+
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/${NLOHMANN_JSON_SOURCE_DIR}>
4450
$<INSTALL_INTERFACE:include>
4551
)
4652

0 commit comments

Comments
 (0)