Adding header-only dependencies with CMake

后端 未结 1 1283
鱼传尺愫
鱼传尺愫 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
      $
      $)
    
    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)
提交回复
热议问题