CMake:根据CMake生成的项目中的配置更改Visual Studio和Xcode exectuables的名称 [英] CMake : Changing name of Visual Studio and Xcode exectuables depending on configuration in a project generated by CMake
问题描述
我需要做的是设置我的excecutable名称为
What I need to do is to setup my excecutable name to be
program-debug for debug builds and
program-release(or whatever) for other builds
平台方式和什么也很重要 - 我想要定位XCode和VS2008 - 所以当我在一个下拉列表中更改配置时,它还必须有正确的名称输出!我不想再生成.vcproj或.xcodeproj与其他-D选项(但我会有如果不能找到一个解决方案)
I want to do it in a true cross-platform way and what is also very important - I want to target XCode and VS2008 - so when I change configuration in a kind of drop-down list, it must also have correct names for output! I do no want to regenerate .vcproj or .xcodeproj with other -D option (but I will have to if will not found a solution)
AFAIK cmake变量CMAKE_BUILD_TYPE应该工作对于基于make的生成器 - 在生成时进行 (如果我错了,请更正我)
AFAIK cmake variable CMAKE_BUILD_TYPE should work for make-based generators - in is evaluated at make time (Correct me if I am wrong)
基本上是如何设置目标选项(不是名称),取决于一些IDE /构建系统中的配置。
Basically it is how to setup target options (not nessesary name) depending on configuration in some IDEs/build system. It can be too specific for overall cmake goals, but maybe you can help.
非常感谢。
推荐答案
查看目标属性的列表:其中一个是 OUTPUT_NAME 和 OUTPUT_NAME_< CONFIG> 。最后一个可以为每个配置类型(Debug,Release,MinSizeRel等)设置。你可以在你的程序中设置 set_target_properties ,例如:
Take a look at the list of target properties: One of those is the OUTPUT_NAME and OUTPUT_NAME_<CONFIG>. The last one can be set for each config-type (Debug, Release, MinSizeRel, etc.) You can set them on your program with set_target_properties, e.g.:
project( YourProject )
add_executable( myprogram ${YourSources} )
set_target_properties( myprogram PROPERTIES OUTPUT_NAME_DEBUG program-debug )
set_target_properties( myprogram PROPERTIES OUTPUT_NAME_RELEASE program-release )
请注意,您需要设置 RUNTIME_OUTPUT_NAME_< CONFIG> 和/或 LIBRARY_OUTPUT_NAME_< CONFIG> 。
Take care that you need to set RUNTIME_OUTPUT_NAME_<CONFIG> and/or LIBRARY_OUTPUT_NAME_<CONFIG> as well in some cases.
这篇关于CMake:根据CMake生成的项目中的配置更改Visual Studio和Xcode exectuables的名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!