[CMake] Eliminate Debug/Release directories and name executables based on configuration

Keith Gardner kgardner at zebraimaging.com
Mon Aug 9 15:50:46 EDT 2010


What you need to do to get rid of the Debug/Release directories is set the prefix property for your target with "../".

Eg.          set_target_properties( target_name PROPERTIES PREFIX "../" )

To get a postfix for different configuration types you need to set the postfix property for the build type.

Eg.          set_target_properties( target_name PROPERTIES DEBUG_POSTFIX "_d" )
set_target_properties( target_name PROPERTIES RELWITHDEBINFO_POSTFIX "_rd" )

From: cmake-bounces at cmake.org [mailto:cmake-bounces at cmake.org] On Behalf Of James Ihrig
Sent: Monday, August 09, 2010 1:23 PM
To: cmake at cmake.org
Subject: [CMake] Eliminate Debug/Release directories and name executables based on configuration

Hello,

I'm using CMake for Visual Studio as well as Makefiles for Linux. In windows, debug and release directories seem to be added for the executables.

I actually would like to do three things:

1) Test for a debug or release build
2) Name the executable created based on it's build. (myProgram_d.exe for debug, myProgram.exe for release.)
3) Place the output executables into the bin directory without debug and release directories.

I have not found a way to test for the build type but I have tried these together, and in various combinations:

set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/../Demo/bin)
set(RUNTIME_OUTPUT_BINARY ${PROJECT_BINARY_DIR}/../Demo/bin)
set(RUNTIME_OUTPUT_DIRECTORY_DEBUG ${PROJECT_BINARY_DIR}/../Demo/bin)
set(RUNTIME_OUTPUT_DIRECTORY_RELEASE ${PROJECT_BINARY_DIR}/../Demo/bin)
set(RUNTIME_OUTPUT_NAME_DEBUG demo_d.exe)
set(RUNTIME_OUTPUT_NAME_RELEASE demo.exe)

The closest I can come are these executables:
Demo\bin\Debug\helloDemo.exe
Demo\bin\Release\helloDemo.exe

What I want is:
Demo\bin\demo_d.exe
Demo\bin\demo.exe

Any help or suggestions would be greatly appreciated!
-Jim


P.S.
For anyone curious what my main CMakeLists.txt looks like, here it is:
http://codepad.org/Yuev7TWJ

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20100809/6a691d7d/attachment-0001.htm>


More information about the CMake mailing list