[CMake] Add search paths for FIND_PACKAGE ?

Alexander Neundorf a.neundorf-work at gmx.net
Mon Nov 19 14:34:46 EST 2007


On Monday 19 November 2007, Christian Ehrlicher wrote:
> Mike Jackson schrieb:
> > Actually I run into this ALL the time (tiff, expat, hdf5) and I have
> > most of mine stored in "non-Standard" locations. I end up copying the
> > the FindXXX.cmake into my local project directory and then adding some
> > code like the following:
> >
> > SET(EXPAT_INCLUDE_SEARCH_DIRS
> >   $ENV{EXPAT_INSTALL}/include/expat
> > )
> >
> > SET (EXPAT_LIB_SEARCH_DIRS
> >   $ENV{EXPAT_INSTALL}/lib
> >   )
> >
> > FIND_PATH(EXPAT_INCLUDE_DIR
> >   NAMES expat.h
> >   PATHS ${EXPAT_INCLUDE_SEARCH_DIRS}
> >   NO_DEFAULT_PATH
> >   )
> >
> > The important part is that I am looking for an environment variable to
> > help find the paths/libraries. This type of thing could be added the the
> > FindXXX.cmake files so if someone has their libs installed in
> > non-standard locations they can set an env variable and let cmake find
> > the package that way.
> >
> >
> > Also.. Why would I "hard-code" paths into a "cross-platform" build
> > system.. that is just asking for trouble. If Stephen has one of his
> > associates build his source for him then that associates computer must
> > be laid out the EXACT same way which is not going to happed.
>
> Search for CMAKE_INCLUDE_PATH and CMAKE_LIBRARY_PATH

CMake cvs supports an environment variable CMAKE_FIND_PREFIX_PATH, to which it 
will automatically append bin/, lib/ and include/.
So if all your stuff is in /some/weird/place, set CMAKE_FIND_PREFIX_PATH 
to /some/weird/place, and it will the headers in /some/weird/place/include, 
the libs in /some/weird/place/lib and apps in /some/weird/place/bin

It will also find the stuff if it is in the same install prefix as cmake, or 
if it is in the same install prefix as the CMAKE_INSTALL_PREFIX of the 
current build.

Alex


More information about the CMake mailing list