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
。