Reputation: 33
Just attempting to create my first cmake project. I have a very simple setup but cannot seem to get find_package to work. I am on Mac OS X 10.9.3 and installed cmake from the dmg package (cmake version 2.8.12.2). I have created a very simple CMakeLists.txt as follows:
cmake_minimum_required (VERSION 2.8)
project (Tutorial)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} “${CMAKE_SOURCE_DIR}/cmake/Modules”)
message( STATUS ${CMAKE_MODULE_PATH} )
FIND_PACKAGE(GSL REQUIRED)
add_executable(Tutorial src/main.cpp)
and have placed the FindGSL.cmake file (downloaded) in the cmake/Module folder as shown by my terminal output:
bash-3.2$ ls cmake/Modules/
FindGSL.cmake
I then get the following output from cmake:
bash-3.2$ cmake ../
-- “/Users/adam/repos/ctmc/cmake/Modules”
CMake Error at CMakeLists.txt:6 (FIND_PACKAGE):
By not providing "FindGSL.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "GSL", but
CMake did not find one.
Could not find a package configuration file provided by "GSL" with any of
the following names:
GSLConfig.cmake
gsl-config.cmake
Add the installation prefix of "GSL" to CMAKE_PREFIX_PATH or set "GSL_DIR"
to a directory containing one of the above files. If "GSL" provides a
separate development package or SDK, be sure it has been installed.
-- Configuring incomplete, errors occurred!
See also "/Users/adam/repos/ctmc/build/CMakeFiles/CMakeOutput.log".
Could anyone point out what I am doing wrong?
Upvotes: 3
Views: 6232
Reputation:
Check your cmake/Modules
directory permissions. You don't have execute
permissions for
directory so you can read file if you have full path to it, but you can't find it:
> ls cmake/Modules/FindMy.cmake
cmake/Modules/FindMy.cmake
> cat CMakeLists.txt
cmake_minimum_required(VERSION 3.0)
project(Foo)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/Modules")
find_package(My REQUIRED)
> cmake -H. -B_builds
... OK
And again without x
-permission
> chmod -x cmake/Modules/
> rm -rf _builds/
> cmake -H. -B_builds
...
CMake Error at CMakeLists.txt:5 (find_package):
By not providing "FindMy.cmake" in CMAKE_MODULE_PATH this project has asked
CMake to find a package configuration file provided by "My", but CMake did
not find one.
Upvotes: 2