[CMake] Recompiles everything every time

Collier, Jack Jack.Collier at drdc-rddc.gc.ca
Thu Feb 10 15:47:59 EST 2011


I have a large project that I recently converted from autotools to cmake.  Everything works great save for the fact that everytime I make the project every single source file is recompiled.  I think the reason is that my build relies on a number of custom targets this generate a bunch of header files that are used by almost all the other sources in the project.  According to the documentation for add_custom_target the target is always considered out of date so it will recompile everytime.  Is there anyway to get around this and only compile if something has changed?  I have included one of the custom targets and the associated custom command below:


#Add command to compile IDL files
ADD_CUSTOM_TARGET(CompileIdl ALL)
ADD_CUSTOM_COMMAND(
        DEPENDS ${TAO_IDL}
        COMMAND ${TAO_IDL} -in -hc C.h -cs C.cpp -ci C.i.h -hs S.h -hT S_T.h -ss S.cpp -sT S_T.cpp -si S.i.h  ${IDL_INCLUDES} ${SRC_FINAL}
        TARGET CompileIdl
        OUTPUTS ${IDL_CLIENT_CPP} ${IDL_CLIENT_H} ${IDL_CLIENT_IH} ${IDL_SERVER_CPP} ${IDL_SERVER_H} ${IDL_SERVER_IH}
        )

#Now compile the generated sources
SET(BUILT_SOURCES ${IDL_CLIENT_CPP} ${IDL_CLIENT_H} ${IDL_CLIENT_IH} ${IDL_SERVER_CPP} ${IDL_SERVER_H} ${IDL_SERVER_IH} )
SET_SOURCE_FILES_PROPERTIES(${BUILT_SOURCES} PROPERTIES GENERATED true)


More information about the CMake mailing list