【发布时间】:2017-03-09 10:26:07
【问题描述】:
我的 Mercurial 存储库 repo1 有一个名为 foo 的自定义目标;别管它做了什么。我还有另一个存储库 repo2,我想将其用作 repo1 的子存储库。 repo2 以与 repo1 类似的方式开发,并且还有一个名为 foo 的自定义目标,做同样的事情(当然只是针对 repo2 目录)。
如果我尝试在 CMakeLists.txt 中使用 add_subdirectory(relative/path/to/repo2) 为 repo1 运行 CMake,我会得到:
CMake Error at CMakeLists.txt:123 (add_custom_target):
add_custom_target cannot create target "foo" because another target with
the same name already exists. The existing target is a custom target
created in source directory
我想我可以在自定义目标名称前加上存储库名称,但这似乎是解决这个问题的粗略方法;我有点喜欢make foo 在概念上在 repo1 和 repo2 中做同样的事情这一事实。那么我可以在这里做点什么更聪明的事情吗?
【问题讨论】:
-
I kind of like the fact that 'make foo' does the same thing, conceptually, both in repo1 and in repo2.- 你期望在 repo1 中make foo的行为是什么?在 repo1 和 repo2 中构建foo?还是只在 repo1 中构建foo?如果您想要最后一种情况,请使用ExternalProject_Add而不是add_subdirectory。 -
@Tsyvarev:实际上,我不太介意它是哪个选项(此外,在某些情况下,这可能是同一件事,例如,如果
foo类似于运行cloc或ctags)。但是阅读这个问题的其他人可能有两种偏好。你能把你的建议变成答案吗?