Adding header-only dependencies with CMake

后端 未结 1 1282
鱼传尺愫
鱼传尺愫 2021-02-02 17:43

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:

相关标签:
1条回答
  • 2021-02-02 18:06

    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.

    0 讨论(0)
提交回复
热议问题