@@ -46,6 +46,7 @@ target_include_directories(vix_json INTERFACE
4646)
4747
4848set (_VIX_JSON_PROVIDER "none" )
49+ set (_VIX_JSON_INSTALL_FALLBACK OFF )
4950
5051find_package (nlohmann_json QUIET CONFIG )
5152if (nlohmann_json_FOUND)
@@ -67,15 +68,14 @@ else()
6768 )
6869 FetchContent_MakeAvailable (nlohmann_json_fallback)
6970
70- if (NOT TARGET nlohmann_json::nlohmann_json)
71- add_library (nlohmann_json::nlohmann_json INTERFACE IMPORTED )
72- target_include_directories (nlohmann_json::nlohmann_json INTERFACE
73- $<BUILD_INTERFACE :${nlohmann_json_fallback_SOURCE_DIR} /single_include >
74- )
75- endif ()
71+ # Do NOT link fetched nlohmann target into exported install interface.
72+ # Just expose its headers during the build.
73+ target_include_directories (vix_json INTERFACE
74+ $<BUILD_INTERFACE :${nlohmann_json_fallback_SOURCE_DIR} /single_include >
75+ )
7676
77- target_link_libraries (vix_json INTERFACE nlohmann_json::nlohmann_json )
7877 set (_VIX_JSON_PROVIDER "nlohmann_json (fetched header-only)" )
78+ set (_VIX_JSON_INSTALL_FALLBACK ON )
7979 endif ()
8080endif ()
8181
@@ -107,8 +107,17 @@ install(DIRECTORY include/
107107 FILES_MATCHING PATTERN "*.hpp" PATTERN "*.h"
108108)
109109
110+ # If using fetched fallback, install nlohmann headers too.
111+ if (_VIX_JSON_INSTALL_FALLBACK)
112+ install (
113+ DIRECTORY "${nlohmann_json_fallback_SOURCE_DIR} /single_include/nlohmann"
114+ DESTINATION "${CMAKE_INSTALL_INCLUDEDIR} "
115+ FILES_MATCHING PATTERN "*.hpp"
116+ )
117+ endif ()
118+
110119install (TARGETS vix_json
111- EXPORT VixTargets # <- join umbrella export-set
120+ EXPORT VixTargets
112121)
113122
114123# Status
0 commit comments