[CMake] Unexpected find_path() result

Alexander Neundorf a.neundorf-work at gmx.net
Mon Jun 20 12:24:05 EDT 2011


On Monday 20 June 2011, Pere Mato Vila wrote:
> I am on a MaxOSX system with cmake version 2.8.4 and I am having problems
> with find_project(x11). I have narrowed the problem with a very simple
> test. The following lines as top level CMakeLists.txt file
> 
> cmake_minimum_required(VERSION 2.8)
> find_path(X11_Xft_INCLUDE_PATH X11/Xft/Xft.h /usr/X11R6/include)
> message("X11_Xft_INCLUDE_PATH ${X11_Xft_INCLUDE_PATH}")
> 
> give me as answer:
> 
> Re-run cmake no build system arguments
> -- The C compiler identification is GNU
> ...
> X11_Xft_INCLUDE_PATH /usr/include
> -- Configuring done
> -- Generating done
> -- Build files have been written to: /Users/mato/Development/ROOT/testcase
> 
> Which is not what I am expecting. While executing it as cmake -P
> CMakeLists.txt gives me the correct answer.
> 
> X11_Xft_INCLUDE_PATH /usr/X11R6/include
> 
> Does anybody has any idea why is this possible and whether there is a 
> workaround.  


If I remember correctly, in -P mode the basic system files, e.g. 
CMakeDetermineSystem.cmake etc. are not executed, so cmake doesn't execute 
UnixPaths.cmake, which sets all the default search paths, so in your try with 
-P only the path you gave to find_path() was searched, the default search path 
was empty.

Why don't you like the /usr/include result ?
The necessary files must be existing there, otherwise cmake wouldn't have 
returned that result.

You can influence the search oder e.g. by using "HINTS" instead of "PATHS", 
HINTS are searched *before* the default dirs, "PATHS" are searched after them.

You can also set CMAKE_PREFIX_PATH to a set of root search dirs, which will be 
used before the default dirs.

Alex


More information about the CMake mailing list