首页 > 解决方案 > 使用 CMake FetchContent 时的目标冲突

问题描述

在 CMake 项目中,我使用 FetchContent 来获取两个依赖项。它们都定义了相同的目标(在这种情况下doc),导致配置步骤出错:

CMake Error at thirdparty/penf/doc/CMakeLists.txt:7 (add_custom_target):
  add_custom_target cannot create target "doc" because another target with
  the same name already exists.  The existing target is a custom target
  created in source directory
  "/home/me/project/thirdparty/flogging/doc".  See
  documentation for policy CMP0002 for more details.

我怎样才能避免这个目标冲突?

标签: cmakedependencies

解决方案


推荐阅读