本文介绍了CMake构建目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在为我自己的项目运行cmake/make之后,我注意到cmake将对象文件放入名为 CMakeFiles/myproject.dir/
的目录中.如何设置其他构建目录(例如 bin/)
?我知道变量 CMAKE_BINARY_DIR
或 CMAKE_CURRENT_BINARY_DIR
,但它们应该是只读的.
After running cmake/make for my own project, I noticed cmake puts object files into a directory named CMakeFiles/myproject.dir/
. How can I set a different build directory (e.g. bin/)
? I know of the variables CMAKE_BINARY_DIR
or CMAKE_CURRENT_BINARY_DIR
, but they are supposed to be read-only.
推荐答案
您已经注意到,您无法设置 CMAKE_BINARY_DIR
变量.
As you already note, you can't set CMAKE_BINARY_DIR
variable.
根据您的目的,您可以使用:
Depending on your purposes you can use:
add_executable(simple_bin ${SOURCES})
install(TARGETS simple_bin DESTINATION ${PROJECT_SOURCE_DIR}/bin)
add_executable(simple_bin ${SOURCES})
enable_testing()
add_test(test_name simple_bin --data-directory ${PROJECT_SOURCE_DIR}/bin)
这篇关于CMake构建目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!