7

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!

Alexander K.
  • 1,649
  • 2
  • 15
  • 21

1 Answers1

15

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.

Mr Shark
  • 26,068
  • 5
  • 29
  • 37
André
  • 18,348
  • 6
  • 60
  • 74