CMake找不到自定义模块

时间:2013-06-06 20:14:37

标签: cmake

我在库Poco中发现了 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指向该模块文件?

1 个答案:

答案 0 :(得分:1)

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

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

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