Cmake - preventing "cleaning" from cleaning ExternalProject

I was wondering if there is a way to prevent make cleancmake from rebuilding external dependencies. I use ExternalProjectto create third-party C ++ libraries, and they do not need to be rebuilt, even if I do make clean.

On the other hand, I may need to create a new rule, say make really-clean, that even clears the dependencies. is there any good way to do this?

Thank.

+5
source share
1 answer

I assume that you are using ADD_CUSTOM_COMMAND or ADD_LIBRARY or another ADD_ * to create dependency files.

ExternalProject , CMakeLists.txt , CMakeLists.txt:

SET_DIRECTORY_PROPERTIES(PROPERTIES CLEAN_NO_CUSTOM 1)

, .

, . ,

ADD_CUSTOM_COMMAND(OUTPUT libdep
   COMMAND dep_gen_cmd
   ....
)

ADD_CUSTOM_COMMAND(OUTPUT prj
   ....
   DEPENDS libdep
)

:

ADD_CUSTOM_TARGET(libdep_gen
      COMMAND dep_gen_cmd
      ...
)

ADD_CUSTOM_COMMAND(OUTPUT prj
     COMMAND test -e libdep || make libdep_gen
     ...
)
+4

All Articles