[CMake] Different output files based on build_type

Clinton Stimpson clinton at elemtech.com
Thu May 14 18:51:46 EDT 2009


James Bigler wrote:
> I need to specify different output files for an add_custom_command for 
> different build types in VS.  The output file also needs to be added 
> to an add_executable command.
>
> I'm not sure how to go about this.
>
> Any pointers would be helpful.

How about something like this.

set(myoutput_file "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/out.txt")
add_custom_command(${myoutput_file}
  COMMAND mycommand ${myoutput_file} )

add_executable (app ${SOURCES} ${myoutput_file})


The same works with generators that don't have configuration types (such 
as a makefile).

Clint



More information about the CMake mailing list