[CMake] Correct usage of the find_path command

Cedric Doucet cedric.doucet at inria.fr
Wed May 6 07:07:30 EDT 2015


Hello, 

I try to create my first FindXXX.cmake and use find_package inside. 
My goal is to check that a repository exists: it's always the same because it come from the ExternalProject_add command. 
However, I don't manage to write a first very simple version. 
I can't find the path I want. 
I would like to check that /usr/local/bibliotheques/eigen/3.2.4/include/eigen3/Eigen/Core exists. 

My file organization is the following: 
project/ 
CMakeLists.txt 
build/ 
modules/ 
FindEigen.cmake 

The CMakeLists.txt contains the following lines: 
## 
cmake_minimum_required (VERSION 2.6) 
project (example CXX) 
set(CMAKE_VERBOSE_MAKEFILE ON) 
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/modules) 
find_package(Eigen) 
## 

The FindEigen.cmake file contains these lines: 
## 
find_path(EIGEN_INCLUDE_DIR Eigen/Core 
HINTS "/usr/local/bibliotheques/eigen/3.2.4/include/eigen3/" 
NO_DEFAULT_PATH) 
if(EIGEN_FOUND) 
message(STATUS "Eigen found (include: ${EIGEN_INCLUDE_DIRS})") 
else(EIGEN_FOUND) 
message(STATUS "Eigen NOT found (include: ${EIGEN_INCLUDE_DIRS})") 
endif(EIGEN_FOUND) 
## 

>From the "build" directory, I type "cmake .." in a terminal and get: 

-- Eigen NOT found (include: ) 
-- Configuring done 
-- Generating done 
-- Build files have been written to: project/find_package/build 

Could explain me what I am doing wrong? 

Thank you very much! 

Cédric 




-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20150506/621a2449/attachment.html>


More information about the CMake mailing list