Ælex
Ælex

Reputation: 14829

CMake cannot find custom module

I have found in library Poco under contrib a PocoConfig.cmake which I've copied under /cmake/Modules

I also added in my CMakeLists.txt:

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

Now I run under /Build/cmake ..

And I keep getting:

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.

Obviously CMake is not finding the module file. What am I doing wrong, how to explicitly point CMake to that module file?

Upvotes: 6

Views: 11538

Answers (2)

Ioannis Kingdom
Ioannis Kingdom

Reputation: 39

I've had similar issues. In my case I was recompiling with an old build folder in place - deleting the folder and recompiling worked.

Upvotes: 0

Guillaume
Guillaume

Reputation: 10961

The PocoConfig.cmake doesn't works with find_package (otherwise, it would be named FindPoco.cmake), that's why you're getting this error.

Just include the PocoConfig.cmake in your CMakeLists.txt with:

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

Upvotes: 3

Related Questions