[英]Why EXECUTABLE_OUTPUT_PATH does not work?
I have such files我有这样的文件
.
├── CMakeLists.txt
└── src
├── CMakeLists.txt
└── main.c
And this is the content about this files这是关于这个文件的内容
$ cat CMakeLists.txt
cmake_minimum_required(VERSION 3.5)
PROJECT (HELLO)
ADD_SUBDIRECTORY(src bin)
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/binarydir)
$ cat src/CMakeLists.txt
ADD_EXECUTABLE(hello main.c)
$ cat src/main.c
#include <stdio.h>
int main()
{
printf("Hello World from t1 main().\n");
return 0;
}
Then I build it with following command然后我使用以下命令构建它
$ mkdir build
$ cd build
$ cmake ..
$ make
This is the result directory structure这是结果目录结构
Then the binary hello
will produced in directory build/bin
as the picture, but it should be in build/binarydir
since I have set
the value for EXECUTABLE_OUTPUT_PATH
, isn't it?然后二进制hello
将在目录build/bin
成为图片,但它应该在build/binarydir
因为我已经set
了EXECUTABLE_OUTPUT_PATH
的值,不是吗? What I have missed?我错过了什么?
You are creating executable target before setting EXECUTABLE_OUTPUT_PATH
.您正在设置EXECUTABLE_OUTPUT_PATH
之前创建可执行目标。 Move SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/binarydir)
line before ADD_SUBDIRECTORY(src bin)
.在ADD_SUBDIRECTORY(src bin)
之前移动SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/binarydir)
行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.