# Create the library which represents all third-party libraries
add_library(third_party_libs INTERFACE)
target_include_directories(third_party_libs INTERFACE
<include-directory-1>
<include-directory-2>
...
)
target_link_libraries(third_party_libs INTERFACE
<external-lib-1>
<external-lib-2>
...
)
# Create executable in your project
add_executable(my_exe <sources...>)
# This will propagate to the executable all include directories and libraries from
# the INTERFACE library target.
target_link_libraries(my_exe third_party_libs)
2条答案
按热度按时间x9ybnkn61#
您可以创建
INTERFACE
库目标,并为其指定要链接的包含目录列表和库列表。只要链接该目标,这些包含目录和库就会传播到使用者。2w2cym1i2#
摄取不提供自己的CMake配置模块的第三方库的正确方法是为每个包编写自己的自定义查找模块,每个查找模块指定要用作
IMPORTED
目标的库集。参考编号: