在CMake中基于Release / Debug构建类型创建一个目录 [英] Create a directory based on Release/Debug build type in CMake
问题描述
我正在进行后期构建,INSTALL命令。在我建立我的项目后,我建立INSTALL项目,它将目录复制到用户指定的位置。我使用
安装(TARGETS EXECTUABLE RUNTIME DESTINATION CMAKE_INSTALL_PREFIX / USERSPECIFIEDLOCATION )。
我想将其更改为
安装(TARGETS EXECTUABLE RUNTIME DESTINATION CMAKE_INSTALL_PREFIX / DEBUG或RELEASE )。
因此,如果我在VS2012中使用debug生成,它应该将可执行文件复制到CMAKE_INSTALL_PREFIX / DEBUG ,而不是CMAKE_INSTALL_PREFIX / USERSPECIFIEDLOCATION 。
提前感谢。
如果您靠近文档:
CONFIGURATIONS参数指定应用安装规则(Debug,Release等)的构建配置
的列表。
示例:
code> add_executable(boo boo.cpp)
install(
TARGETS
boo
CONFIGURATIONS
Debug
DESTINATION
bin / Debug
)
install(
TARGETS
boo
配置
发布
DESTINATION
bin /发布
)
DEBUG_POSTFIX
但我认为您所需要的只是 CONFIG _POSTFIX 目标属性:
add_executable(bar bar.cpp)
add_library baz.cpp)
set_target_properties(bar baz PROPERTIES DEBUG_POSTFIX d)
install(TARGETS bar DESTINATION bin)
install(TARGETS baz DESTINATION lib)
/ code>配置产生: bar.exe
和 baz.lib
。
构建安装
目标与调试
配置产生: bard.exe
和 bazd.lib
。
注意
请注意,对于图书馆,您可以使用 CMAKE_DEBUG_POSTFIX a>(我不知道为什么,但 CMAKE_DEBUG_POSTFIX
不适用于可执行文件):
set(CMAKE_DEBUG_POSTFIX d)
add_library(baz baz.cpp)
install(TARGETS baz DESTINATION lib)
相关
target_link_libraries 。请参阅 debug
和 optimized
。
I am working on post build, INSTALL command. After I build my project, I build INSTALL project,which copies directories to User Specified location. I have that working fine using
install(TARGETS EXECTUABLE RUNTIME DESTINATION CMAKE_INSTALL_PREFIX/USERSPECIFIEDLOCATION).
I would like to change this to
install(TARGETS EXECTUABLE RUNTIME DESTINATION CMAKE_INSTALL_PREFIX/DEBUG or RELEASE).
So, if I build using debug in VS2012, it should copy executable to CMAKE_INSTALL_PREFIX/DEBUG instead of CMAKE_INSTALL_PREFIX/USERSPECIFIEDLOCATION.
Thanks in advance.
解决方案 You'll find an answer to your question if you look closer to documentation:
The CONFIGURATIONS argument specifies a list of build configurations
for which the install rule applies (Debug, Release, etc.).
Example:
add_executable(boo boo.cpp)
install(
TARGETS
boo
CONFIGURATIONS
Debug
DESTINATION
bin/Debug
)
install(
TARGETS
boo
CONFIGURATIONS
Release
DESTINATION
bin/Release
)
DEBUG_POSTFIX
But I think that all you need is CONFIG_POSTFIX target property:
add_executable(bar bar.cpp)
add_library(baz baz.cpp)
set_target_properties(bar baz PROPERTIES DEBUG_POSTFIX d)
install(TARGETS bar DESTINATION bin)
install(TARGETS baz DESTINATION lib)
Building install
target with Release
configuration produce: bar.exe
and baz.lib
.
Building install
target with Debug
configuration produce: bard.exe
and bazd.lib
.
Note
Note that for libraries you can use CMAKE_DEBUG_POSTFIX (I don't know why, but CMAKE_DEBUG_POSTFIX
not applyed to executables):
set(CMAKE_DEBUG_POSTFIX d)
add_library(baz baz.cpp)
install(TARGETS baz DESTINATION lib)
Related
target_link_libraries. See debug
and optimized
.
这篇关于在CMake中基于Release / Debug构建类型创建一个目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!