Makefiles: changing per-source flags recompiles all sources in a target
I have the following problem. All the sources of a target is recompiled when I would except the recompilation only of the files whose properties were modified by the 'SET_SOURCE_FILES_PROPERTIES' command.
example code: (not full standalone cmake code)
OPTION( SPECIAL_SWITCH "Special switch used only in one source" OFF)
IF ( ${SPECIAL_SWITCH })
SET_SOURCE_FILES_PROPERTIES( "my_source.cpp" PROPERTIES COMPILE_DEFINITIONS "MY_DEFINE")
ENDIF()
SET(Sources ... lot of source, containing the my_source.cpp too)
ADD_LIBRARY( MyObject OBJECT ${Sources})
After enabling/disabling the 'SPECIAL_SWITCH' option all the sources are recompiled present in the 'Sources' variable. The 'MY_DEFINE' definition is added only for the file 'my_source.cpp' as expected (checked in verbose mode). I can't see the reason why CMAKE recompiles the other '.obj' files..
Regards, Gábor