给定一个递归构建结构。如何将目标从较低级别导入到较高级别?这是一个简化的示例:
顶级CMakeLists.txt:
cmake_minimum_required(VERSION 2.8)
add_subdirectory(sub1)
Run Code Online (Sandbox Code Playgroud)
sub1/CMakeLists.txt:
add_subdirectory(subdir)
add_executable(foo EXCLUDE_FROM_ALL
foo.cpp)
add_custom_target(both)
add_dependencies(both DEPENDS foo bar)
Run Code Online (Sandbox Code Playgroud)
sub1/subdir/CMakeLists.txt:
add_executable(bar EXCLUDE_FROM_ALL
bar.cpp)
Run Code Online (Sandbox Code Playgroud)
在顶层,所有目标都是可见的:
在底层(sub1/subdir)只有栏是可见的:
在中间层,只有foo作为目标可见:
制作帮助显示:
以下是此 Makefile 的一些有效目标: ...全部(如果未提供目标,则为默认值) ... 干净的 ... 依靠 ... edit_cache ...重建缓存 ... 两个都 ... foo ... foo.o ... foo.i ... foo.s
如何添加栏在不将构建指令上移的情况下到此列表中?
小智 -1
如果我改变
add_dependencies(both DEPENDS foo bar)
Run Code Online (Sandbox Code Playgroud)
到
add_dependencies(both foo bar)
Run Code Online (Sandbox Code Playgroud)
我收到以下响应以在顶部文件夹中提供帮助:
The following are some of the valid targets for this Makefile:
... all (the default if no target is provided)
... clean
... depend
... edit_cache
... rebuild_cache
... both
... foo
... bar
Run Code Online (Sandbox Code Playgroud)
查看文档: https://cmake.org/cmake/help/v3.3/command/add_dependency.html
| 归档时间: |
|
| 查看次数: |
1689 次 |
| 最近记录: |