[CMake] Renaming output of EXECUTABLE

Gregor Berginc gregor.berginc at gmail.com
Thu Dec 1 07:36:30 EST 2005


Dear Reggie,

> Our project has several binaries some of which have different names based on
> project settings.
>
> <basename>-debug, <basename>-pro, for example.  Since I want to use the same
> source file list how would I go about renaming the output?

Don't know if I understand you correctly, but this is how I use
different build configurations (release, debug). My directory
structure is as follows:

VisualCortex/
    .debug
    .release
    src
    ...

In the src/CMakelists.txt, I have the following custom command:

ADD_CUSTOM_COMMAND(
		TARGET VisualCortex
		POST_BUILD
		COMMAND ${CMAKE_COMMAND}
		ARGS -E copy ${TARGET_DIR}/VisualCortex ${CMAKE_SOURCE_DIR})

Here, VisualCortex is the name of the target built by the cmake. The
result of this command is that the target from
VisualCortex/<current_build_type>/src is copied to VisualCortex/.

If you wish to rename the target, you might first use the copy and
then the remove command, i.e., put one more command in the
CMakelists.txt and replace the "copy" with "remove" cmake command:

ADD_CUSTOM_COMMAND(
		TARGET VisualCortex
		POST_BUILD
		COMMAND ${CMAKE_COMMAND}
		ARGS -E remove ${TARGET_DIR}/VisualCortex)

Just make sure, you put them in the right order ;)

Best,
Gregor
--
Gregor Berginc, Ph.D. Student
University of Ljubljana, Faculty of CIS
Trzaska 25, SI-1001 Ljubljana, Slovenia
tel: +386 1 4776630, fax: +386 1 4264647
www: http://vicos.fri.uni-lj.si/gregor


More information about the CMake mailing list