Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CMake : Changing name of Visual Studio and Xcode exectuables depending on configuration in a project generated by CMake

Tags:

cmake

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

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 variable CMAKE_BUILD_TYPE should work for make-based generators - in is evaluated at make time (Correct me if I am wrong)

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.

Thanks a lot!

like image 712
Alexander K. Avatar asked Jul 03 '11 07:07

Alexander K.


1 Answers

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 )

Take care that you need to set RUNTIME_OUTPUT_NAME_<CONFIG> and/or LIBRARY_OUTPUT_NAME_<CONFIG> as well in some cases.

like image 86
André Avatar answered Jan 03 '23 19:01

André