I have a simple project which requires three header-only libraries in order to compile: websocketpp, spdlog and nlohmann/json.
The project structure looks like this:
Just as you're said: you didn't install your targets in the export set. In other words, you're missing an install(EXPORT ...
line for your header-only targets. For example, considering your header-only library websocketpp
, you should have:
add_library(websocketpp INTERFACE)
target_include_directories(websocketpp INTERFACE
$<BUILD_INTERFACE:${WEBSOCKETPP_INCLUDE_DIR}>
$<INSTALL_INTERFACE:include>)
install(TARGETS websocketpp EXPORT websocketpp-config DESTINATION include)
# here is the missing line:
install(EXPORT websocketpp-config DESTINATION share/websocketpp/cmake)
Same goes for the other libraries.