Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I redefine target "clean"?

Tags:

cmake

My CMmake build script includes an "external native makefile". Target-all has a dependency with an "external make". This dependency is made by CMake.

CMakeLists.txt
       |____( add_custom_target )_____ GNU make file

But Target-clean doesn't have a dependency with an "external make clean". I can't make dependency clean - external make clean. I can make a new custom-target (for example, newClean), and it has a dependency with "clean" and "external make clean". But "clean" and "newClean" exist. It may be the confusion.

How do I resolve this problem?

like image 965
jongwon.kwak Avatar asked Mar 26 '12 10:03

jongwon.kwak


1 Answers

There are three possible solutions I can think of:

  1. Make sure all output files from custom commands are listed in the OUTPUT line. They will then be removed as part of clean (this behaviour is mentioned with the CLEAN_NO_CUSTOM property).

  2. Add extra files to the ADDITIONAL_MAKE_CLEAN_FILES directory property.

  3. Create a new custom command which calls the normal clean target and your other make file. Example:

    add_custom_target(really-clean
      COMMAND "$(CMAKE)" --build "${CMAKE_BINARY_DIR}" clean
      COMMAND cd "${CMAKE_BINARY_DIR}/otherproject" && make clean
    )
    
like image 169
Silas Parker Avatar answered Nov 04 '22 09:11

Silas Parker