MantisBT - CMake
View Issue Details
0005473CMakeCMakepublic2007-08-09 14:052016-06-10 14:30
ufnoise 
Kitware Robot 
normalmajoralways
closedmoved 
 
 
0005473: rebuild always triggered when using SET_SOURCE_FILES_PROPERTIES
When I use SET_SOURCE_FILES_PROPERTIES on a list of files, adding or removing a file triggers a rebuild of all of the files in the library. Only the file being added would need to be recompiled.

PROJECT(main)
SET (SRCS a.cc b.cc c.cc d.cc e.cc f.cc g.cc)
ADD_EXECUTABLE(a ${SRCS})
ADD_LIBRARY(b ${SRCS})
SET_SOURCE_FILES_PROPERTIES (
  ${SRCS}
  COMPILE_FLAGS "-Wall"
)
No tags attached.
has duplicate 0014152closed Brad King Comment change in flags.make triggers unnecessary rebuilds 
Issue History
2007-08-09 14:05ufnoiseNew Issue
2007-12-17 17:54Bill HoffmanStatusnew => assigned
2007-12-17 17:54Bill HoffmanAssigned To => Brad King
2007-12-17 18:00Brad KingAssigned ToBrad King => Ken Martin
2007-12-17 18:02Brad KingNote Added: 0009968
2007-12-17 18:05Brad KingNote Added: 0009969
2010-12-14 11:32David ColeAssigned ToKen Martin => Brad King
2011-01-26 11:24David ColeCategory => CMake
2012-08-13 10:44Brad KingStatusassigned => backlog
2012-08-13 10:44Brad KingNote Added: 0030553
2013-05-17 08:15Brad KingAssigned ToBrad King =>
2013-05-17 08:16Brad KingRelationship addedhas duplicate 0014152
2013-05-17 08:25Craig ScottNote Added: 0033083
2013-05-17 09:00Brad KingNote Added: 0033086
2016-06-10 14:27Kitware RobotNote Added: 0041379
2016-06-10 14:27Kitware RobotStatusbacklog => resolved
2016-06-10 14:27Kitware RobotResolutionopen => moved
2016-06-10 14:27Kitware RobotAssigned To => Kitware Robot
2016-06-10 14:30Kitware RobotStatusresolved => closed

Notes
(0009968)
Brad King   
2007-12-17 18:02   
Ken, this is because flags.make gets lines like this:

# Custom flags: CMakeFiles/b.dir/a.o_FLAGS = -Wall
# Custom flags: CMakeFiles/b.dir/b.o_FLAGS = -Wall

Adding or removing a line causes rebuilds just as much as changing the flags. My original design had a separate rule file per object so that this would not happen. Of course that had the problem of taking forever to generate so many build files on Windows filesystems.
(0009969)
Brad King   
2007-12-17 18:05   
ufnoise, you can work around this by not setting these flags directly on the source files. The COMPILE_FLAGS property is really meant for when one file has something special as compared to the others.

You may use SET_TARGET_PROPERTIES to add the flags to the target's COMPILE_FLAGS property, or add the flags to the CMAKE_C_FLAGS and CMAKE_CXX_FLAGS variables directly.
(0030553)
Brad King   
2012-08-13 10:44   
Sending issues I'm not actively working on to the backlog to await someone with time for them.

If an issue you care about is sent to the backlog when you feel it should have been addressed in a different manner, please bring it up on the CMake mailing list for discussion. Sign up for the mailing list here, if you're not already on it:

 http://www.cmake.org/mailman/listinfo/cmake [^]

It's easy to re-activate a bug here if you can find a CMake developer or contributor who has the bandwidth to take it on.
(0033083)
Craig Scott   
2013-05-17 08:25   
We are also being bitten by this problem. In our case, we have the software package version passed through as a define to just those few source files that need it. Because of this bug, however, whenever we change the software version, the whole target gets rebuilt rather than just those few files that should be affected.
(0033086)
Brad King   
2013-05-17 09:00   
Re 0005473:0033083: This is not a bug, just the lack of an optimization. We once experimented with per-object rule files for dependencies and it was *very* slow on filesystems that do not deal well with lots of small files. Therefore we use one flags.make file for a whole target.

The comment is used in flags.make specifically in order to *cause* this rebuild so that changing per-source flags will result in a correct rebuild.

I suggest one of the following workarounds:

* Use an OBJECT library to hold the sources with special flags so that only those rebuild when the per-source flags change.

* Use the Ninja generator
(0041379)
Kitware Robot   
2016-06-10 14:27   
Resolving issue as `moved`.

This issue tracker is no longer used. Further discussion of this issue may take place in the current CMake Issues page linked in the banner at the top of this page.