CMake: changing the name of Visual Studio and Xcode exectuables depending on the configuration in the project created by CMake

What I need to do is set up my excecutable name

program-debug for debug builds and program-release(or whatever) for other builds 

I want to do this in a real cross-platform way, and which is also very important - I want to target Xcode and VS2008 - so when I change the configuration as a drop-down list, it must also have the correct names for the output! I do not want to regenerate .vcproj or .xcodeproj with another -D option (but I will need it if I cannot find a solution)

the cmake AFAIK CMAKE_BUILD_TYPE variable should work for make-in generators evaluated at make time (correct me if I'm wrong)

Basically, how to configure the target parameters (optional name) depending on the configuration in some IDE / build systems. This may be too specific for general cmake purposes, but maybe you can help.

Thank you so much!

+7
cmake
Jul 03 2018-11-11T00:
source share
1 answer

Take a look at the list of target properties : one of them is OUTPUT_NAME and OUTPUT_NAME_ <CONFIG> . The latter can be set for each configuration type (Debug, Release, MinSizeRel, etc.). You can set them in your program using set_target_properties , for example:

 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 ) 

Make sure that you need to set RUNTIME_OUTPUT_NAME_ <CONFIG> and / or LIBRARY_OUTPUT_NAME_ <CONFIG> , as well as in some cases.

+15
Jul 03 2018-11-11T00:
source share



All Articles