[CMake] Dealing with custom command outputs when using clean

Willy Lambert lambert.willy at gmail.com
Tue Jan 8 04:42:37 EST 2013


Hi all,

When I build my project I use the EXECUTABLE_OUTPUT_PATH to produce my
binaries. As I also want to split the binaries between the stripped
stuff and the debug stuff (so basically I have a exe and exe.debug).
This is done with objcopy, so I use a custom command :

	set( EXEC ${EXECUTABLE_OUTPUT_PATH}/${EXEC_NAME} )
	set( DBG_INFO "${EXECUTABLE_OUTPUT_PATH}/${EXEC_NAME}.debug" )
	add_custom_command(TARGET ${EXEC_NAME}
        	POST_BUILD
                COMMAND ${CMAKE_SPIE_OBJECT_COPY} --only-keep-debug
${EXEC} ${DBG_INFO}
		COMMAND ${CMAKE_SPIE_STRIP} --strip-debug --strip-unneeded ${EXEC}
		COMMAND ${CMAKE_SPIE_OBJECT_COPY} --add-gnu-debuglink=${DBG_INFO} ${EXEC}
	)

My problem comes when I use the "make clean" command from my cmake
root dir, because it doesn't clean the custom command output *.debug
(which is quite natural). So I tried to modify properties to specify
ADDITIONAL_MAKE_CLEAN_FILES, but this :

	set_property(DIRECTORY ${EXECUTABLE_OUTPUT_PATH}
		PROPERTY ADDITIONAL_MAKE_CLEAN_FILES ${EXEC_NAME}.debug)

results in :

CMake Error a tXXXXXXX/cle.cmake:42 (set_property):
  set_property DIRECTORY scope provided but requested directory was not
  found.  This could be because the directory argument was invalid or, it is
  valid but has not been processed yet.


If I'm correct it's due to the EXECUTABLE_OUTPUT_PATH dir management.

My questions are :
_ is EXECUTABLE_OUTPUT_PATH deprecated ? I read in docs :
"EXECUTABLE_OUTPUT_PATH: Old executable location variable." (so I
wonder about the "Old" point)
_ is my custom command correctly configured regarding the action
"modifying a compiled exec" ?
_ did I do something wrong with "make clean" properties ?

Have a nice day !


More information about the CMake mailing list