CMakeLists.txt 常用指令说用

add_dependencies

add_dependencies(<target> [<target-dependency>]...)

Makes a top-level <target> depend on other top-level targets to ensure that they build before <target> does. 
A top-level target is one created by one of the add_executable(), add_library(), or add_custom_target() commands (but not targets generated by CMake like install).

add_dependencies必须在add_executable之后,可以在target_link_libraries之前或之后。 这样在编译target的时候,会出现一句scanning dependencies,这时编译器就会注意到A的依赖项,等依赖项完成后再编译target

参考

CMakeLists.txt编写常用命令

posted @ 2021-04-30 15:09  采男孩的小蘑菇  阅读(176)  评论(0编辑  收藏  举报