[cmake-developers] Relation between CMAKE_PREFIX_PATH and CMAKE_FIND_ROOT_PATH

Alexander Neundorf neundorf at kde.org
Tue Jan 3 13:54:49 EST 2012


On Tuesday 03 January 2012, Eric Noulard wrote:
> Sorry sent too soon, finger slipped.
> ...
> 
> I have been giving wrong advice about the usage of CMAKE_FIND_ROOT_PATH
> which seems to be "reserved" for cross-compiling whereas
> 
> CMAKE_PREFIX_PATH
> CMAKE_INCLUDE_PATH
> CMAKE_PROGRAM_PATH
> CMAKE_LIBRARY_PATH
> CMAKE_IGNORE_PATH
> 
> are meant to be used in the general case.
> 
> Could someone enlighten me about the intended usage and
> relationship between those vars and their "SYSTEM" counterpart
> CMAKE_SYSTEM_*_PATH ?

CMAKE_INCLUDE_PATH is a list of directories used by find_file() and 
find_path(), could include /home/mystuff/include/

CMAKE_PROGRAM_PATH is a list of directories used by find_program(), could 
include /home/mystuff/bin/

CMAKE_LIBRARY_PATH is a list of directories used by find_library(), could 
include /home/mystuff/lib/

These were added 2006 I think.

Late 2007 or maybe 2008 came CMAKE_PREFIX_PATH.
This make the variables above mostly unnecessary. It is a list of directories, 
where the respective subdirectory is appended by find_program(), find_file() 
etc.
So for the example above you would be done by setting it to /home/mystuff/ .

The directories from these variables are checked before the directories given 
via PATHS or HINTS.


CMAKE_FIND_ROOT_PATH is different (and was added before CMAKE_PREFIX_PATH), it 
is a list of directories which contain root directories where the filesystem 
of the target system in a cross-compilation setting is location.
You set it e.g. to /opt/eldk/arm/.
Then cmake will prepend this root dir to each of the directories it would 
check otherwise.
I.e. find_program() will check in /opt/eldk/arm/bin/, /opt/eldk/arm/usr/bin/,  
/opt/eldk/arm/usr/local/bin/, /opt/eldk/arm/usr/X11/bin/,  etc.

I.e. the assumption is that under those prefixes a whole normal filesystem is 
located.
 
Alex



More information about the cmake-developers mailing list