[cmake-developers] Add native options to the clean step of 'cmake --build .. --clean-first'

Ben Boeckel ben.boeckel at kitware.com
Thu Dec 15 11:31:16 EST 2016


On Wed, Dec 14, 2016 at 21:26:13 +0100, Yves Frederix wrote:
> In PR https://gitlab.kitware.com/cmake/cmake/merge_requests/329 I am
> suggesting to not only pass the additional/native build options to the
> actual build step, but also to the 'clean' step in case of a call like
> `cmake --build ... --clean-first`. The change is simple enough, but
> there is the risk that a 'make clean' does not accept the additional
> build options that for a normal build are ok, which could cause a
> build to fail. Hence, I would like to check with the devs on this list
> to judge the actual risk of this PR.
> 
> Brad suggested to check the git logs to see if I could find something
> there. I tracked things down to d35651fb in which the additional build
> options were added.to the Build() function. It seems that already from
> the beginning, the additional options were only passed to the build
> step itself and not to the clean step. Whether there was a reason for
> this is unclear from the logs.
> 
> My question now is whether somebody remembers if there indeed was a
> particular reason to leave out the additional options from the 'make
> clean' call? And if not, could you come up with a real example in
> which case the proposed change would cause a build failure? I have
> tried, but wasn't able to come up with anything, although I must admit
> that my view is limited as I do not have much experience with non-VS
> generators.

Flags for other generators can cause the `clean` to not actually happen.
For example, with make `cmake --build ... --clean-first -- -i` can cause
the clean to silently fail and then it isn't really a clean build. Or
the `-t` flag which skips running commands and instead just touches
output files. `-n` just prints what would be done. Or a target is passed
and so you effectively have `make clean -j10 mytarget; make -j10
mytarget` which could be interesting with the `mytarget` subgraph making
files while `clean` is going around deleting them again.

IMO, these flags being passed to `--clean-first`'s subtask can
completely invalidate what is being asked for and it makes sense that
`--clean-first` is really just a plain clean.

--Ben


More information about the cmake-developers mailing list