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

Ben Medina ben.medina at gmail.com
Tue Aug 10 12:17:14 EDT 2010


CMake has explicit support for this, rather than using a prefix (which
doesn't work in VS2010):

http://www.cmake.org/Bug/view.php?id=9163

- Ben

On Mon, Aug 9, 2010 at 12:50 PM, Keith Gardner
<kgardner at zebraimaging.com> wrote:
> 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
>
>
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake
>


More information about the CMake mailing list