CMake add_executable在另一个目录中 [英] CMake add_executable in another directory
问题描述
我正在做一堆测试,以验证每个库是否正确链接,然后对我的代码的功能进行一些测试。
I am making a bunch of tests in order to verify that each library are correctly linked, and then some tests for the functionalities of my code.
我想在目录project / build / tests
中有X个不同的可执行文件,我希望将程序构建在project / build中
I would like to have X different executable in the directory project/build/tests and I want my program to be build in project/build
cmake_minimum_required(VERSION 3.0)
project(ProjectName)
# Linking library ...
add_executable(${PROJECT_NAME} ${SRC_LIST} ${INCLUDE_LIST})
直到这里一切都很好并且可以按需工作,但是我不知道如何告诉cmake在其中创建测试另一个目录,因为它不起作用
until here, everything is fine and works as wanted but then I don't know how to tell cmake to create my tests in another directory as this does not work
add_executable(tests/OpenMP_Check tests/openmp.cpp)
我的项目具有以下架构:
my project has this architecture :
项目:
- src
- include
- lib
- build
-
- 测试
- src
- include
- lib
- build
- tests
简而言之:我如何要求CMake在另一个目录中创建测试?
To put it in a nutshell : How do I ask CMake to create my tests in another directory ?
推荐答案
使用 set_target_properties ,将其
RUNTIME_OUTPUT_DIRECTORY
设置为$ {CMAKE_BINARY_DIR}
。这篇关于CMake add_executable在另一个目录中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!