target_link_libraries and INCLUDE_DIRECTORIES property

前端 未结 2 988
半阙折子戏
半阙折子戏 2021-01-28 04:09

In this snippet:

cmake_minimum_required(VERSION 3.0)
project(hello LANGUAGES C VERSION 0.0.1)
add_library(a INTERFACE)
target_include_directories(a INTERFACE /us         


        
2条回答
  •  时光取名叫无心
    2021-01-28 04:48

    The problem is that the information you are seeking is only available after the generation step. You can get those only with e.g. add_custom_target() calls, which run during compile time. Your get_target_property() and message() calls run during CMake configuration step.

    Disclaimer: Taken with small modifications from the question linked below:

    add_custom_command(
        b_lists ALL
        ${CMAKE_COMMAND} -E echo "b INCLUDE_DIRECTORIES: $"
    )
    

    References

    • Recursive list of LINK_LIBRARIES in CMake
    • target_include_directories prior to 2.8.12?

提交回复
热议问题