[CMake] add_dependencies behaviuor

Andrea Galeazzi Galeazzi at korg.it
Wed May 18 05:27:27 EDT 2011


I've multiple executable targets depending on a custom target that 
invokes another executable target:
add_executable(MyTool  ${MyTool_SOURCES})
add_custom_target(PreBuildCommands ALL COMMAND "java" "-jar"
                                        "../BuildNumberUpdater.jar"
                                        
${GENERATED_SOURCES}                                     
                                        COMMAND MyTool DEPENDS 
${SOURCES} ${LIB_TO_LINK}
                                        COMMENT "Changing the build number")

add_executable(${TARGET_NAME1} ${SOURCES} ${GENERATED_SOURCES})
add_dependencies(${TARGET_NAME1} MyTool PreBuildCommands)

add_executable(${TARGET_NAME2} ${SOURCES} ${GENERATED_SOURCES})
add_dependencies(${TARGET_NAME2} MyTool PreBuildCommands)

I'd like, or better I need, that when the building of MyTool fails the 
other dependent targets won't build or fails their build too.
How could I achieve that?

 


More information about the CMake mailing list