[CMake] Question about overriding Find modules in cmake
Allen Gooch
allen.gooch at gmail.com
Mon Mar 30 19:10:10 EDT 2009
Using cmake-2.7 out of CVS, I'm trying to override the Find modules which
come with cmake install. In our src tree we have checked in versions of
certain dependencies and I would like to set paths to point at those instead
of any libraries which may be installed. In trying to override the behavior
of FindExpat I've done the following:
0. added a cmake-modules directory to the top of my src tree
1. in my top-level CmakeLists.txt file define where we keep our third-party
binary packages as ${GlobalExternalDir}
2. in my top-level CMakeLists.txt file, prepend this dirpath to
CMAKE_MODULE_PATH with 'set (CMAKE_MODULE_PATH
${CMAKE_SOURCE_DIR}/cmake-modules ${CMAKE_MODULE_PATH})'
3. in my cmake-modules directory create a FindExpat.cmake which locates
include dir and library in ${GlobalExternalDir} and uses message to report
on the found locations
When I run it, the messages indicate that my FindExpat is being used,
instead of the one installed by cmake in
/usr/local/share/cmake-2.7/Modules/FindEXPAT.cmake, however my logging out
of the Expat_INCLUDE_DIR and Expat_LIBRARY values indicate that sytem
libraries are being found instead of the ones in our src tree. Below is my
FindExpat.cmake file contents:
# BEGIN FindExpat.cmake
message (STATUS "Finding Expat in global dir: ${GlobalExternalDir}")
find_path (Expat_INCLUDE_DIR
NAMES expat.h
PATHS ${GlobalExternalDir}/expat/expat-2.0.1/lib
)
message (STATUS "Set Expat_INCLUDE_DIR: ${Expat_INCLUDE_DIR}")
find_library (Expat_LIBRARY
NAMES expat
PATHS ${GlobalExternalDir}/expat/expat-2.0.1/bin/linux-x32/release
)
message (STATUS "Set Expat_LIBRARY: ${Expat_LIBRARY}")
if (Expat_INCLUDE_DIR)
set (Expat_FOUND TRUE)
set (Expat_INCLUDE_DIRS ${Expat_INCLUDE_DIR})
set (Expat_LIBRARIES ${Expat_LIBRARY})
message (STATUS "Found Expat")
endif ()
# END FindExpat.cmake
Any ideas on why this cannot use my local install of expat versus that of
the system?
Many thanks in advance,
-allen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20090330/a2c3ead0/attachment.htm>
More information about the CMake
mailing list