[CMake] Adding dependencies to the `clean` target in 2016?

Brad King brad.king at kitware.com
Mon Dec 5 09:05:41 EST 2016


On 12/03/2016 06:52 AM, Dan Liew wrote:
> There was a post about this 10 years ago [1], has anything changed since then?

No.  From my response back then:

>> The "clean" target is not a first class target available to
>> CMakeLists.txt code....We do plan to make targets like install
>> and clean first class eventually but it is not yet implemented.

This never happened.  These generator-provided targets have very
different semantics (e.g. per-directory behavior in the Makefile
generator) and that makes it hard to define them in a way that is
visible to client code during configuration.  It may be possible but
will require deep design thought.

> I realise the `clean` target won't be available for all generators but
> for those that do, it would be really nice to able to do something
> like this.
> 
> add_dependencies(clean CleanKLEERuntimes)

Just as `ADDITIONAL_MAKE_CLEAN_FILES` is a make-specific solution I
think something like `ADDITIONAL_MAKE_CLEAN_COMMAND` or perhaps
`ADDITIONAL_MAKE_CLEAN_TARGET` could be offered.  Such configuration
could be interpreted by the makefile generator while generating the
"make clean" target.

-Brad



More information about the CMake mailing list