Transitive target_include_directories on OBJECT libraries

后端 未结 4 1379
北恋
北恋 2021-01-01 12:18

Here is snippet from make CMakeLists.txt:

add_library(foo-object OBJECT src/foo.cpp)
target_include_directories(foo-object PUBLIC include)
add_library(foo SH         


        
4条回答
  •  醉酒成梦
    2021-01-01 12:41

    Hm, at the moment I came up with following:

    add_library(foo-object OBJECT src/foo.cpp)
    target_include_directories(foo-object PUBLIC include)
    
    get_property(object_include_dirs TARGET foo-object PROPERTY INCLUDE_DIRECTORIES)
    get_property(object_link_libs TARGET foo-object PROPERTY LINK_LIBRARIES)
    
    add_library(foo SHARED $)
    target_include_directories(foo PUBLIC ${object_include_dirs})
    target_link_libraries(foo PUBLIC ${object_link_libs})
    
    add_library(foo_static STATIC $)
    target_include_directories(foo_static PUBLIC ${object_include_dirs})
    target_link_libraries(foo_static PUBLIC ${object_link_libs})
    

    but come on, there must be better way :/

提交回复
热议问题