1 # - Find a library installation or build tree.
3 # The following variables are set if @LIBRARY_NAME@ is found.
4 # If @LIBRARY_NAME@ is not found, @LIBRARY_NAME@_FOUND is set to false.
5 # @LIBRARY_NAME@_FOUND - Set to true when @LIBRARY_NAME@ is found.
6 # @LIBRARY_NAME@_USE_FILE - CMake file to use @LIBRARY_NAME@.
7 # @LIBRARY_NAME@_MAJOR_VERSION - The @LIBRARY_NAME@ major version number.
8 # @LIBRARY_NAME@_MINOR_VERSION - The @LIBRARY_NAME@ minor version number
10 # @LIBRARY_NAME@_BUILD_VERSION - The @LIBRARY_NAME@ patch level
11 # (meaningless for odd minor).
12 # @LIBRARY_NAME@_INCLUDE_DIRS - Include directories for @LIBRARY_NAME@
13 # @LIBRARY_NAME@_LIBRARY_DIRS - Link directories for @LIBRARY_NAME@ libraries
14 # @LIBRARY_NAME@_LIBRARIES - List of libraries to link against
16 # The following cache entries must be set by the user to locate @LIBRARY_NAME@:
17 # @LIBRARY_NAME@_DIR - The directory containing @LIBRARY_NAME@Config.cmake.
18 # This is either the root of the build tree,
19 # or the lib/@LIBRARY_NAME@ directory. This is the
23 # Construct consitent error messages for use below.
24 SET(@LIBRARY_NAME@_DIR_DESCRIPTION "directory containing @LIBRARY_NAME@Config.cmake. This is either the root of the build tree, or PREFIX/lib/@LIBRARY_NAME@ for an installation.")
25 SET(@LIBRARY_NAME@_NOT_FOUND_MESSAGE "@LIBRARY_NAME@ not found. Set the @LIBRARY_NAME@_DIR cmake cache entry to the ${@LIBRARY_NAME@_DIR_DESCRIPTION}")
27 # Search only if the location is not already known.
28 IF(NOT @LIBRARY_NAME@_DIR)
29 # Get the system search path as a list.
31 STRING(REGEX MATCHALL "[^:]+" @LIBRARY_NAME@_DIR_SEARCH1 "$ENV{PATH}")
33 STRING(REGEX REPLACE "\\\\" "/" @LIBRARY_NAME@_DIR_SEARCH1 "$ENV{PATH}")
35 STRING(REGEX REPLACE "/;" ";" @LIBRARY_NAME@_DIR_SEARCH2 "${@LIBRARY_NAME@_DIR_SEARCH1}")
37 # Construct a set of paths relative to the system search path.
38 SET(@LIBRARY_NAME@_DIR_SEARCH "")
39 FOREACH(dir ${@LIBRARY_NAME@_DIR_SEARCH2})
40 SET(@LIBRARY_NAME@_DIR_SEARCH ${@LIBRARY_NAME@_DIR_SEARCH}
41 ${dir}/../lib/@INSTALL_PATH@
46 # Look for an installation or build tree.
48 FIND_PATH(@LIBRARY_NAME@_DIR Use@LIBRARY_NAME@.cmake
49 # Look for an environment variable @LIBRARY_NAME@_DIR.
50 $ENV{@LIBRARY_NAME@_DIR}
52 # Look in places relative to the system executable search path.
53 ${@LIBRARY_NAME@_DIR_SEARCH}
55 # Look in standard WIN install locations.
56 "$ENV{ProgramFiles}/@LIBRARY_NAME@"
58 # Look in standard UNIX install locations.
59 /usr/local/@INSTALL_PATH@
62 # Read from the CMakeSetup registry entries. It is likely that
63 # @LIBRARY_NAME@ will have been recently built.
64 [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild1]
65 [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild2]
66 [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild3]
67 [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild4]
68 [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild5]
69 [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild6]
70 [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild7]
71 [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild8]
72 [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild9]
73 [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild10]
75 # Help the user find it if we cannot.
76 DOC "The ${@LIBRARY_NAME@_DIR_DESCRIPTION}"
78 ENDIF(NOT @LIBRARY_NAME@_DIR)
80 # If @LIBRARY_NAME@ was found, load the configuration file to get the rest of the
82 IF(@LIBRARY_NAME@_DIR)
83 # Make sure the @LIBRARY_NAME@Config.cmake file exists in the directory provided.
84 IF(EXISTS ${@LIBRARY_NAME@_DIR}/@LIBRARY_NAME@Config.cmake)
86 # We found @LIBRARY_NAME@. Load the settings.
87 SET(@LIBRARY_NAME@_FOUND 1)
88 INCLUDE(${@LIBRARY_NAME@_DIR}/@LIBRARY_NAME@Config.cmake)
90 ENDIF(EXISTS ${@LIBRARY_NAME@_DIR}/@LIBRARY_NAME@Config.cmake)
91 ELSE(@LIBRARY_NAME@_DIR)
92 # We did not find @LIBRARY_NAME@.
93 SET(@LIBRARY_NAME@_FOUND 0)
94 ENDIF(@LIBRARY_NAME@_DIR)
96 #-----------------------------------------------------------------------------
97 IF(NOT @LIBRARY_NAME@_FOUND)
98 # @LIBRARY_NAME@ not found, explain to the user how to specify its location.
99 IF(NOT @LIBRARY_NAME@_FIND_QUIETLY)
100 MESSAGE(FATAL_ERROR ${@LIBRARY_NAME@_NOT_FOUND_MESSAGE})
101 ELSE(NOT @LIBRARY_NAME@_FIND_QUIETLY)
102 IF(@LIBRARY_NAME@_FIND_REQUIRED)
103 MESSAGE(FATAL_ERROR ${@LIBRARY_NAME@_NOT_FOUND_MESSAGE})
104 ENDIF(@LIBRARY_NAME@_FIND_REQUIRED)
105 ENDIF(NOT @LIBRARY_NAME@_FIND_QUIETLY)
106 ENDIF(NOT @LIBRARY_NAME@_FOUND)