summaryrefslogtreecommitdiffstats
path: root/Modules/FindITK.cmake
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2002-11-06 23:40:13 (GMT)
committerBrad King <brad.king@kitware.com>2002-11-06 23:40:13 (GMT)
commitc79abbd99c9149049cb99930786b2933160ca207 (patch)
tree4e6b8650c7eb44c01b08c2b350ad92eef67986fe /Modules/FindITK.cmake
parent6ab16695d066278fe9f78774ec3df3733d932c06 (diff)
downloadCMake-c79abbd99c9149049cb99930786b2933160ca207.zip
CMake-c79abbd99c9149049cb99930786b2933160ca207.tar.gz
CMake-c79abbd99c9149049cb99930786b2933160ca207.tar.bz2
ENH: Enhanced FindITK supporting use of ITK from an install tree or a build tree. Only one cache entry is brought into user's project, called "ITK_DIR". This is the location of an ITKConfig.cmake file from which other settings are loaded.
Diffstat (limited to 'Modules/FindITK.cmake')
-rw-r--r--Modules/FindITK.cmake88
1 files changed, 63 insertions, 25 deletions
diff --git a/Modules/FindITK.cmake b/Modules/FindITK.cmake
index a74664a..4858f5f 100644
--- a/Modules/FindITK.cmake
+++ b/Modules/FindITK.cmake
@@ -1,16 +1,57 @@
#
-# Find the native ITK includes and library
+# Find an ITK installation or build tree.
#
-# This module defines
+# When ITK is found, the ITKConfig.cmake file is sourced to setup the
+# location and configuration of ITK. Please read this file, or
+# ITKConfig.cmake.in from the ITK source tree for the full list of
+# definitions. Of particular interest is
#
-# ITK_BINARY_PATH - where is the binary tree (only defined if SOURCE_PATH is defined)
-# USE_ITK_FILE - the full path and location of the UseITK.cmake file
+# ITK_USE_FILE - A CMake source file that can be included
+# to set the include directories, library
+# directories, and preprocessor macros.
#
-
+# In addition to the variables read from ITKConfig.cmake, this find
+# module also defines
+#
+# ITK_DIR - The directory containing ITKConfig.cmake. This is either
+# the root of the build tree, or the lib/InsightToolkit
+# directory. This is the only cache entry.
+#
+# ITK_FOUND - Whether ITK was found. If this is true, ITK_DIR is okay.
#
-# Look for a binary tree
-#
-FIND_PATH(ITK_BINARY_PATH UseITK.cmake
+# USE_ITK_FILE - The full path to the UseITK.cmake file. This is provided
+# for backward compatability. Use ITK_USE_FILE instead.
+#
+
+# Search only if the location is not already known.
+IF(NOT ITK_DIR)
+ # Get the system search path as a list.
+ IF(UNIX)
+ STRING(REGEX MATCHALL "[^:]+" ITK_DIR_SEARCH1 $ENV{PATH})
+ ELSE(UNIX)
+ STRING(REGEX REPLACE "\\\\" "/" ITK_DIR_SEARCH1 $ENV{PATH})
+ ENDIF(UNIX)
+ STRING(REGEX REPLACE "/;" ";" ITK_DIR_SEARCH2 ${ITK_DIR_SEARCH1})
+
+ # Construct a set of paths relative to the system search path.
+ SET(ITK_DIR_SEARCH "")
+ FOREACH(dir ${ITK_DIR_SEARCH2})
+ SET(ITK_DIR_SEARCH ${ITK_DIR_SEARCH} "${dir}/../lib/InsightToolkit")
+ ENDFOREACH(dir)
+
+ #
+ # Look for an installation or build tree.
+ #
+ FIND_PATH(ITK_DIR ITKConfig.cmake
+ # Look in places relative to the system executable search path.
+ ${ITK_DIR_SEARCH}
+
+ # Look in standard UNIX install locations.
+ /usr/local/lib/InsightToolkit
+ /usr/lib/InsightToolkit
+
+ # Read from the CMakeSetup registry entries. It is likely that
+ # ITK will have been recently built.
[HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild1]
[HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild2]
[HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild3]
@@ -21,23 +62,20 @@ FIND_PATH(ITK_BINARY_PATH UseITK.cmake
[HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild8]
[HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild9]
[HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild10]
- ../ITKBIN
- ../itkbin
- ../Insight-vc
- ../InsightBin
- ITKBIN
- itkbin
- $ENV{HOME}/ITKBIN
- $ENV{HOME}/Insight
- $ENV{HOME}/InsightBin
- $ENV{HOME}/itkbin
- )
-
-
-
-IF (ITK_BINARY_PATH)
- SET (USE_ITK_FILE ${ITK_BINARY_PATH}/UseITK.cmake)
-ENDIF (ITK_BINARY_PATH)
+ # Help the user find it if we cannot.
+ DOC "The directory containing ITKConfig.cmake. This is either the root of the build tree, or PREFIX/lib/InsightToolkit for an installation."
+ )
+ENDIF(NOT ITK_DIR)
+# If ITK was found, load the configuration file to get the rest of the
+# settings.
+IF(ITK_DIR)
+ SET(ITK_FOUND 1)
+ INCLUDE(${ITK_DIR}/ITKConfig.cmake)
+ # Set USE_ITK_FILE for backward-compatability.
+ SET(USE_ITK_FILE ${ITK_USE_FILE})
+ELSE(ITK_DIR)
+ SET(ITK_FOUND 0)
+ENDIF(ITK_DIR)