[CMake] FIND_* search paths

Bill Hoffman bill.hoffman at kitware.com
Wed Jan 4 13:12:16 EST 2006


There is a problem in cmake with FIND_LIBRARY,
FIND_PATH, and FIND_FILE searching paths.

Currently they search like this:

FIND_PATH:
1. The list of paths specified in the call to the command.
2. CMAKE_INCLUDE_PATH environment variable
3. PATH environment variable
4. Mac Framework directories (on apple)

FIND_LIBRARY:
1. CMAKE_LIBRARY_PATH environment variable
2. LIB environment variable
3. PATH environment variable
4. The list of paths specified in the call to the command
5. some compiler specific paths for borland and visual studio
6. Mac Framework directories (on apple)

FIND_FILE:
1. The list of paths specified in the call to the command.
2. CMAKE_LIBRARY_PATH environment variable
3. PATH environment variable

I would like to propose a change to clean things up.
I suggest creating some variables that are set in the Platform
files.

CMAKE_SYSTEM_INCLUDE_DIRECTORIES
CMAKE_SYSTEM_LIB_DIRECTORIES

These would be set based on the OS and compiler being used.
Then I would like to make the list of paths specified in the call
to the FIND_* command always come first.   Then you would refer
to the variables above for search paths.

FIND_LIBRARY(FOO_LIB foo 
  ${CMAKE_SYSTEM_LIB_DIRECTORIES} /my/special/path)
FIND_PATH(FOO_INCLUDE_DIR foo.h 
  ${CMAKE_SYSTEM_INCLUDE_DIRECTORIES} /my/special/include/path)

Or if you wanted to search your special stuff first you could do this:
FIND_PATH(FOO_INCLUDE_DIR foo.h 
  /my/special/include/path ${CMAKE_SYSTEM_INCLUDE_DIRECTORIES} )

So, the order for all of them would be:

1. The list of paths specified in the call to the command, and
   people would use the system ones, that would include frameworks on the Mac,
   or any special compiler paths.
2. CMAKE_*_PATH environment variable
3. PATH environment variable
4. (for FIND_LIBRARY only) The compiler specific paths that we searched in the past, this
is around only for backwards compatibility in the FIND_LIBRARY command,
and those paths will be duplicated in the CMAKE_SYSTEM_LIB_DIRECTORIES
variable.


How does this sound?

-Bill



More information about the CMake mailing list