【问题标题】:CMake cannot find custom moduleCMake 找不到自定义模块
【发布时间】:2013-06-06 20:14:37
【问题描述】:

我在库 Poco 的 contrib 下找到了一个 PocoConfig.cmake,我在 /cmake/Modules 下复制了它

我还在我的 CMakeLists.txt 中添加了:

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")

现在我在 /Build/cmake 下运行 ..

我不断得到:

CMake Error at CMakeLists.txt:41 (find_package):
  By not providing "FindPoco.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "Poco", but
  CMake did not find one.

  Could not find a package configuration file provided by "Poco" with any of
  the following names:

    PocoConfig.cmake
    poco-config.cmake

  Add the installation prefix of "Poco" to CMAKE_PREFIX_PATH or set
  "Poco_DIR" to a directory containing one of the above files.  If "Poco"
  provides a separate development package or SDK, be sure it has been
  installed.

显然 CMake 没有找到模块文件。我在做什么错,如何明确地将 CMake 指向该模块文件?

【问题讨论】:

  • 你试过Add the installation prefix of "Poco" to CMAKE_PREFIX_PATH or set "Poco_DIR" to a directory containing one of the above files吗?
  • @Massimiliano 我假设您的意思是这样的:stackoverflow.com/questions/15639781/… ?我刚试了一下,一直报同样的错误。
  • debian/ubuntu libpoco-dev 直到最近才导致此错误。参考文献github.com/pocoproject/poco/issues/3244 。现在固定在 sid 中​​,现在很快就会成为靶心。

标签: cmake


【解决方案1】:

PocoConfig.cmake 不适用于 find_package(否则,它将被命名为 FindPoco.cmake),这就是您收到此错误的原因。

只需将 PocoConfig.cmake 包含在您的 CMakeLists.txt 中:

include(${CMAKE_SOURCE_DIR}/cmake/Modules/PocoConfig.cmake)

【讨论】:

  • 不幸的是,这似乎也不起作用。我不断收到关于找不到 FindPoco 的完全相同的错误。我添加了包含行并调用了 find_package,我假设这就是你的意思?还是应该只包含它并使用 find_library 代替?
  • 只包含它,不要调用 find_package。
  • 那么这与调用 find_library( PocoFoundation PATHS ... ) 有何不同?它会更好地进行搜索吗?
  • 这就是它正在做的事情,它只知道更多的搜索路径等等。但是,你可以用 find_path / find_library 做同样的事情
  • PocoConfig.cmake 用于配置模式下的 find_package(与 FindPoco.cmake 的模块模式相反)。您需要在 CMAKE_PREFIX_PATH 变量中添加 POCO 安装目录。有关更多信息,请参阅 find_package 文档。
【解决方案2】:

我也遇到过类似的问题。就我而言,我正在使用旧的构建文件夹重新编译 - 删除该文件夹并重新编译。

【讨论】:

    猜你喜欢
    • 2019-05-27
    • 2023-03-09
    • 1970-01-01
    • 1970-01-01
    • 2013-09-22
    • 1970-01-01
    • 2013-05-15
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多