CMake testing a library, header location issue

前端 未结 1 576
隐瞒了意图╮
隐瞒了意图╮ 2020-12-30 12:21

So, I\'m making part of a project a library with some headers that are the interface to the library, and the remaining are private to the library itself. So for my library t

相关标签:
1条回答
  • 2020-12-30 13:08

    Both PRIVATE and PUBLIC items populate the INCLUDE_DIRECTORIES property of an target, so you can try to use it in target_include_directories for the test project.

    add_executable(${TEST_NAME} ${TEST_SOURCES})
    add_test(NAME LibTest COMMAND ${TEST_NAME})
    
    target_link_libraries(${TEST_NAME} 
        PRIVATE ${Boost_LIBRARIES}
        PRIVATE my::lib
        )
    
    target_include_directories( ${TEST_NAME} PRIVATE $<TARGET_PROPERTY:my::lib,INCLUDE_DIRECTORIES>)
    
    0 讨论(0)
提交回复
热议问题