Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get CMake to allow for "make clean"ing just one target?

I have a project using CMake to generate Makefiles, which then get built with (GNU) make.

In my project, the CMakeLists.txt defines two targets - but only one of them gets built when makeing after Makefile generation (e.g. using the EXCLUDE_FROM_DEFAULT_BUILD property).

I want to be able to cleanup (using make) the files used in the building of one of the targets, but not the files used to build the second target.

How can I do that?

like image 855
einpoklum Avatar asked Nov 08 '16 12:11

einpoklum


1 Answers

I see two additional options:

  1. Using the internal cmake_clean.cmake scripts generated for for each target - which, unfortunately, are not directly accessible through make from the root path. For example, if you have a target named foo, you would write:

     cmake -P CMakeFiles/foo.dir/cmake_clean.cmake
    
  2. Using ninja instead of make generators where you could call

     ninja -t clean foo
    
like image 120
Florian Avatar answered Oct 23 '22 18:10

Florian