FindITK.cmake 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. # - Find an ITK installation or build tree.
  2. # When ITK is found, the ITKConfig.cmake file is sourced to setup the
  3. # location and configuration of ITK. Please read this file, or
  4. # ITKConfig.cmake.in from the ITK source tree for the full list of
  5. # definitions. Of particular interest is ITK_USE_FILE, a CMake source file
  6. # that can be included to set the include directories, library directories,
  7. # and preprocessor macros. In addition to the variables read from
  8. # ITKConfig.cmake, this find module also defines
  9. # ITK_DIR - The directory containing ITKConfig.cmake.
  10. # This is either the root of the build tree,
  11. # or the lib/InsightToolkit directory.
  12. # This is the only cache entry.
  13. #
  14. # ITK_FOUND - Whether ITK was found. If this is true,
  15. # ITK_DIR is okay.
  16. #
  17. # USE_ITK_FILE - The full path to the UseITK.cmake file.
  18. # This is provided for backward
  19. # compatability. Use ITK_USE_FILE
  20. # instead.
  21. SET(ITK_DIR_STRING "directory containing ITKConfig.cmake. This is either the root of the build tree, or PREFIX/lib/InsightToolkit for an installation.")
  22. # Search only if the location is not already known.
  23. IF(NOT ITK_DIR)
  24. # Get the system search path as a list.
  25. IF(UNIX)
  26. STRING(REGEX MATCHALL "[^:]+" ITK_DIR_SEARCH1 "$ENV{PATH}")
  27. ELSE(UNIX)
  28. STRING(REGEX REPLACE "\\\\" "/" ITK_DIR_SEARCH1 "$ENV{PATH}")
  29. ENDIF(UNIX)
  30. STRING(REGEX REPLACE "/;" ";" ITK_DIR_SEARCH2 ${ITK_DIR_SEARCH1})
  31. # Construct a set of paths relative to the system search path.
  32. SET(ITK_DIR_SEARCH "")
  33. FOREACH(dir ${ITK_DIR_SEARCH2})
  34. SET(ITK_DIR_SEARCH ${ITK_DIR_SEARCH} "${dir}/../lib/InsightToolkit")
  35. ENDFOREACH(dir)
  36. #
  37. # Look for an installation or build tree.
  38. #
  39. FIND_PATH(ITK_DIR ITKConfig.cmake
  40. # Look for an environment variable ITK_DIR.
  41. $ENV{ITK_DIR}
  42. # Look in places relative to the system executable search path.
  43. ${ITK_DIR_SEARCH}
  44. # Look in standard UNIX install locations.
  45. /usr/local/lib/InsightToolkit
  46. /usr/lib/InsightToolkit
  47. # Read from the CMakeSetup registry entries. It is likely that
  48. # ITK will have been recently built.
  49. [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild1]
  50. [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild2]
  51. [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild3]
  52. [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild4]
  53. [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild5]
  54. [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild6]
  55. [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild7]
  56. [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild8]
  57. [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild9]
  58. [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild10]
  59. # Help the user find it if we cannot.
  60. DOC "The ${ITK_DIR_STRING}"
  61. )
  62. ENDIF(NOT ITK_DIR)
  63. # If ITK was found, load the configuration file to get the rest of the
  64. # settings.
  65. IF(ITK_DIR)
  66. SET(ITK_FOUND 1)
  67. INCLUDE(${ITK_DIR}/ITKConfig.cmake)
  68. # Set USE_ITK_FILE for backward-compatability.
  69. SET(USE_ITK_FILE ${ITK_USE_FILE})
  70. ELSE(ITK_DIR)
  71. SET(ITK_FOUND 0)
  72. IF(ITK_FIND_REQUIRED)
  73. MESSAGE(FATAL_ERROR "Please set ITK_DIR to the ${ITK_DIR_STRING}")
  74. ENDIF(ITK_FIND_REQUIRED)
  75. ENDIF(ITK_DIR)