Skip to content

Commit 3d6d20d

Browse files
birardabifurcation
andauthored
use get_target_property hack for root nlohmann_json (#440)
Co-authored-by: Richard Barnes <[email protected]>
1 parent b4c3eab commit 3d6d20d

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

CMakeLists.txt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,18 +126,22 @@ file(GLOB_RECURSE LIB_HEADERS CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/inc
126126
file(GLOB_RECURSE LIB_GENERATED_HEADERS CONFIGURE_DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/include/*.h")
127127
file(GLOB_RECURSE LIB_SOURCES CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp")
128128

129+
# https://gitlab.kitware.com/cmake/cmake/-/issues/15415#note_334852
130+
# Warning: this will fail once nlohman_json stops being header-only!
131+
get_target_property(JSON_INCLUDE_INTERFACE nlohmann_json::nlohmann_json INTERFACE_INCLUDE_DIRECTORIES)
132+
129133
add_library(${LIB_NAME} ${LIB_HEADERS} ${LIB_GENERATED_HEADERS} ${LIB_SOURCES})
130134
add_dependencies(${LIB_NAME} bytes tls_syntax hpke)
131135
target_link_libraries(${LIB_NAME}
132-
PRIVATE
133-
nlohmann_json::nlohmann_json
134136
PUBLIC
135137
bytes tls_syntax hpke)
136138
target_include_directories(${LIB_NAME}
137139
PUBLIC
138140
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
139141
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>
140142
$<INSTALL_INTERFACE:include/${PROJECT_NAME}>
143+
PRIVATE
144+
${JSON_INCLUDE_INTERFACE}
141145
)
142146

143147
install(TARGETS ${LIB_NAME} EXPORT mlspp-targets)

0 commit comments

Comments
 (0)