How to have CMake show headers-that are not part of any binary target-in the IDE?

前端 未结 2 993
借酒劲吻你
借酒劲吻你 2020-12-25 10:46

In our workflow, we can have a module A that is composed of several header files, module A not producing any binary (side note: it will obviously be used b

2条回答
  •  一整个雨季
    2020-12-25 11:08

    You can use the new target_sources command in CMake 3.1.

    add_library(moduleA INTERFACE)
    target_include_directories(moduleA INTERFACE ...)
    target_sources(moduleA INTERFACE 
      ${CMAKE_CURRENT_SOURCE_DIR}/utility.h
      ${CMAKE_CURRENT_SOURCE_DIR}/moreUtilities.h
    )
    

    It is also transitive.

    http://www.cmake.org/cmake/help/v3.1/command/target_sources.html#command:target_sources

    The limitation of not being able to export targets which have INTERFACE_SOURCES has been lifted for CMake 3.3.

提交回复
热议问题