【发布时间】:2019-08-08 12:27:49
【问题描述】:
我有一个大致如下结构的 CMake 项目:
.
|-- library1
| |-- CMakeLists.txt
|-- library2
| |-- CMakeLists.txt
|-- executables
| |-- CMakeLists.txt
我在名为executables 的文件夹中生成了两个可执行文件。我想知道是否有可能只生成一个可执行文件及其依赖项而不是全部。我听说过有关 cmake --target 选项的一些信息,但我无法让它与 cmake/3.13.4 一起使用。
【问题讨论】:
-
明确地说,您是否只想构建(即编译)一个可执行文件?还是您只想配置/生成(在 CMake 时)一个可执行文件?
-
@kamil 我在 stackoverflow 上阅读了它,但我丢失了链接。我试过
cmake --build .. --target target_name,但收到错误消息CMake Error: The source directory "/build/target_name" does not exist. -
@squareskittles 我想编译可执行文件,但只有我命名的那个及其依赖库。
-
您的命令行在语法上看起来是正确的,但您的构建文件夹实际上是否命名为
build? CMake 是否为名称为target_name的目标生成了? -
你是如何配置 cmake 的?
--build应该指向你配置 cmake 的文件夹。
标签: build cmake build-target