1 # ---------------------------------------------------------------------
3 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
5 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
6 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
7 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
9 # This software is governed by the CeCILL-B license under French law and
10 # abiding by the rules of distribution of free software. You can use,
11 # modify and/ or redistribute the software under the terms of the CeCILL-B
12 # license as circulated by CEA, CNRS and INRIA at the following URL
13 # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
14 # or in the file LICENSE.txt.
16 # As a counterpart to the access to the source code and rights to copy,
17 # modify and redistribute granted by the license, users are provided only
18 # with a limited warranty and the software's author, the holder of the
19 # economic rights, and the successive licensors have only limited
22 # The fact that you are presently reading this means that you have had
23 # knowledge of the CeCILL-B license and that you accept its terms.
24 # ------------------------------------------------------------------------ */
27 # - Find a library installation or build tree.
29 # The following variables are set if @LIBRARY_NAME@ is found.
30 # If @LIBRARY_NAME@ is not found, @LIBRARY_NAME@_FOUND is set to false.
31 # @LIBRARY_NAME@_FOUND - Set to true when @LIBRARY_NAME@ is found.
32 # @LIBRARY_NAME@_USE_FILE - CMake file to use @LIBRARY_NAME@.
33 # @LIBRARY_NAME@_MAJOR_VERSION - The @LIBRARY_NAME@ major version number.
34 # @LIBRARY_NAME@_MINOR_VERSION - The @LIBRARY_NAME@ minor version number
36 # @LIBRARY_NAME@_BUILD_VERSION - The @LIBRARY_NAME@ patch level
37 # (meaningless for odd minor).
38 # @LIBRARY_NAME@_INCLUDE_DIRS - Include directories for @LIBRARY_NAME@
39 # @LIBRARY_NAME@_LIBRARY_DIRS - Link directories for @LIBRARY_NAME@ libraries
40 # @LIBRARY_NAME@_LIBRARIES - List of libraries to link against
42 # The following cache entries must be set by the user to locate @LIBRARY_NAME@:
43 # @LIBRARY_NAME@_DIR - The directory containing @LIBRARY_NAME@Config.cmake.
44 # This is either the root of the build tree,
45 # or the lib/@LIBRARY_NAME@ directory. This is the
49 # Construct consitent error messages for use below.
50 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.")
51 SET(@LIBRARY_NAME@_NOT_FOUND_MESSAGE "@LIBRARY_NAME@ not found. Set the @LIBRARY_NAME@_DIR cmake cache entry to the ${@LIBRARY_NAME@_DIR_DESCRIPTION}")
53 # Search only if the location is not already known.
54 IF(NOT @LIBRARY_NAME@_DIR)
55 # Get the system search path as a list.
57 STRING(REGEX MATCHALL "[^:]+" @LIBRARY_NAME@_DIR_SEARCH1 "$ENV{PATH}")
59 STRING(REGEX REPLACE "\\\\" "/" @LIBRARY_NAME@_DIR_SEARCH1 "$ENV{PATH}")
61 STRING(REGEX REPLACE "/;" ";" @LIBRARY_NAME@_DIR_SEARCH2 "${@LIBRARY_NAME@_DIR_SEARCH1}")
63 # Construct a set of paths relative to the system search path.
64 SET(@LIBRARY_NAME@_DIR_SEARCH "")
65 FOREACH(dir ${@LIBRARY_NAME@_DIR_SEARCH2})
66 SET(@LIBRARY_NAME@_DIR_SEARCH ${@LIBRARY_NAME@_DIR_SEARCH}
67 ${dir}/../lib/@INSTALL_PATH@
72 # Look for an installation or build tree.
74 FIND_PATH(@LIBRARY_NAME@_DIR Use@LIBRARY_NAME@.cmake
75 # Look for an environment variable @LIBRARY_NAME@_DIR.
76 $ENV{@LIBRARY_NAME@_DIR}
78 # Look in places relative to the system executable search path.
79 ${@LIBRARY_NAME@_DIR_SEARCH}
81 # Look in standard WIN install locations.
82 "$ENV{ProgramFiles}/@LIBRARY_NAME@"
84 # Look in standard UNIX install locations.
85 /usr/local/@INSTALL_PATH@
88 # Read from the CMakeSetup registry entries. It is likely that
89 # @LIBRARY_NAME@ will have been recently built.
90 [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild1]
91 [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild2]
92 [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild3]
93 [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild4]
94 [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild5]
95 [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild6]
96 [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild7]
97 [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild8]
98 [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild9]
99 [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild10]
101 # Help the user find it if we cannot.
102 DOC "The ${@LIBRARY_NAME@_DIR_DESCRIPTION}"
104 ENDIF(NOT @LIBRARY_NAME@_DIR)
106 # If @LIBRARY_NAME@ was found, load the configuration file to get the rest of the
108 IF(@LIBRARY_NAME@_DIR)
109 # Make sure the @LIBRARY_NAME@Config.cmake file exists in the directory provided.
110 IF(EXISTS ${@LIBRARY_NAME@_DIR}/@LIBRARY_NAME@Config.cmake)
112 # We found @LIBRARY_NAME@. Load the settings.
113 SET(@LIBRARY_NAME@_FOUND 1)
114 INCLUDE(${@LIBRARY_NAME@_DIR}/@LIBRARY_NAME@Config.cmake)
116 ENDIF(EXISTS ${@LIBRARY_NAME@_DIR}/@LIBRARY_NAME@Config.cmake)
117 ELSE(@LIBRARY_NAME@_DIR)
118 # We did not find @LIBRARY_NAME@.
119 SET(@LIBRARY_NAME@_FOUND 0)
120 ENDIF(@LIBRARY_NAME@_DIR)
122 #-----------------------------------------------------------------------------
123 IF(NOT @LIBRARY_NAME@_FOUND)
124 # @LIBRARY_NAME@ not found, explain to the user how to specify its location.
125 IF(NOT @LIBRARY_NAME@_FIND_QUIETLY)
126 MESSAGE(FATAL_ERROR ${@LIBRARY_NAME@_NOT_FOUND_MESSAGE})
127 ELSE(NOT @LIBRARY_NAME@_FIND_QUIETLY)
128 IF(@LIBRARY_NAME@_FIND_REQUIRED)
129 MESSAGE(FATAL_ERROR ${@LIBRARY_NAME@_NOT_FOUND_MESSAGE})
130 ENDIF(@LIBRARY_NAME@_FIND_REQUIRED)
131 ENDIF(NOT @LIBRARY_NAME@_FIND_QUIETLY)
132 ENDIF(NOT @LIBRARY_NAME@_FOUND)