【发布时间】:2009-12-15 19:28:47
【问题描述】:
我有 3 个小的依赖工具:
main-tool/
tool1/
tool2/
* ----- main-tool ----- *
| |
tool1 ---------- > tool2
主工具依赖于工具1和工具2。
tool1 依赖于 tool2。
CMakeFiles 看起来像这样:
main-tool/CMakeLists.txt
SUBDIRS{"tool1"}
SUBDIRS{"tool2"}
main-tool/tool1/CMakeLists.txt
SUBDIRS("../tool2"}
我可以顺利编译tool1。但是,每当我想编译 main-tool 时,都会包含两次 tool2 并产生错误。我怎样才能避免这种情况?
谢谢。
【问题讨论】:
-
我解决了这个问题,方法是在 main-tool/CMakeLists.txt 中设置一个 VAR,然后在 tool1/CMakeLists.txt 中设置 IF 语句:IF (NOT DEFINED VAR) SUBDIR(../tool2) ENDIF (未定义的 VAR)。它有效,但晦涩难懂。
-
如果您已经找到解决方案,也许您应该关闭问题
标签: cmake