jongwon.kwak
jongwon.kwak

Reputation: 163

How do I redefine target "clean"?

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?

Upvotes: 6

Views: 9034

Answers (1)

Silas Parker
Silas Parker

Reputation: 8147

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
    )
    

Upvotes: 7

Related Questions