cmake-防止"make clean"清理ExternalProject [英] cmake - preventing `make clean` from cleaning ExternalProject

查看:210
本文介绍了cmake-防止"make clean"清理ExternalProject的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有某种方法可以防止cmake中的make clean重新建立外部依赖关系.我正在使用ExternalProject构建第三方c ++库,即使我做了make clean,也不必重建它们.

I was wondering if there's some way to prevent make clean in cmake from re-building external dependencies. I'm using ExternalProject to build third party c++ libraries, and they do not have to be rebuilt even if I do make clean.

另一方面,我可能想创建一个新规则,例如make really-clean,它甚至可以清除依赖关系.有什么好方法吗?

On the other hand, I might want to create a new rule, say, make really-clean, which even clears the dependencies. is there a good way to do this?

谢谢.

推荐答案

我假设您使用ADD_CUSTOM_COMMAND或ADD_LIBRARY或其他ADD_ *创建依赖文件.

I assume you use ADD_CUSTOM_COMMAND, or ADD_LIBRARY or other ADD_* to create the dependency files.

如果您的ExternalProject具有它自己的目录,并且可以将CMakeLists.txt放在该目录中,则可以轻松地在该CMakeLists.txt中放置以下内容:

If your ExternalProject has it's own directory and you can put CMakeLists.txt in that directory, you can easy put following in that CMakeLists.txt:

SET_DIRECTORY_PROPERTIES(PROPERTIES CLEAN_NO_CUSTOM 1)

所以这些依赖文件不会被清除.

So those dependency files won't get cleaned.

如果不是,则可能需要避免将外部依赖项作为输出文件. 例如,如果您使用

If not, you may need to avoid to put the external dependencies as the output files. For example, if you use

ADD_CUSTOM_COMMAND(OUTPUT libdep
   COMMAND dep_gen_cmd
   ....
)

ADD_CUSTOM_COMMAND(OUTPUT prj
   ....
   DEPENDS libdep
)

然后您需要将其更改为:

then you need to change it to:

ADD_CUSTOM_TARGET(libdep_gen
      COMMAND dep_gen_cmd
      ...
)

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

这篇关于cmake-防止"make clean"清理ExternalProject的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆