FindITK.cmake 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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. #=============================================================================
  22. # Copyright 2001-2009 Kitware, Inc.
  23. #
  24. # Distributed under the OSI-approved BSD License (the "License");
  25. # see accompanying file Copyright.txt for details.
  26. #
  27. # This software is distributed WITHOUT ANY WARRANTY; without even the
  28. # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  29. # See the License for more information.
  30. #=============================================================================
  31. # (To distribute this file outside of CMake, substitute the full
  32. # License text for the above reference.)
  33. SET(ITK_DIR_STRING "directory containing ITKConfig.cmake. This is either the root of the build tree, or PREFIX/lib/InsightToolkit for an installation.")
  34. # Search only if the location is not already known.
  35. IF(NOT ITK_DIR)
  36. # Get the system search path as a list.
  37. IF(UNIX)
  38. STRING(REGEX MATCHALL "[^:]+" ITK_DIR_SEARCH1 "$ENV{PATH}")
  39. ELSE(UNIX)
  40. STRING(REGEX REPLACE "\\\\" "/" ITK_DIR_SEARCH1 "$ENV{PATH}")
  41. ENDIF(UNIX)
  42. STRING(REGEX REPLACE "/;" ";" ITK_DIR_SEARCH2 ${ITK_DIR_SEARCH1})
  43. # Construct a set of paths relative to the system search path.
  44. SET(ITK_DIR_SEARCH "")
  45. FOREACH(dir ${ITK_DIR_SEARCH2})
  46. SET(ITK_DIR_SEARCH ${ITK_DIR_SEARCH} "${dir}/../lib/InsightToolkit")
  47. ENDFOREACH(dir)
  48. #
  49. # Look for an installation or build tree.
  50. #
  51. FIND_PATH(ITK_DIR ITKConfig.cmake
  52. # Look for an environment variable ITK_DIR.
  53. $ENV{ITK_DIR}
  54. # Look in places relative to the system executable search path.
  55. ${ITK_DIR_SEARCH}
  56. # Look in standard UNIX install locations.
  57. /usr/local/lib/InsightToolkit
  58. /usr/lib/InsightToolkit
  59. # Read from the CMakeSetup registry entries. It is likely that
  60. # ITK will have been recently built.
  61. [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild1]
  62. [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild2]
  63. [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild3]
  64. [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild4]
  65. [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild5]
  66. [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild6]
  67. [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild7]
  68. [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild8]
  69. [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild9]
  70. [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild10]
  71. # Help the user find it if we cannot.
  72. DOC "The ${ITK_DIR_STRING}"
  73. )
  74. ENDIF(NOT ITK_DIR)
  75. # If ITK was found, load the configuration file to get the rest of the
  76. # settings.
  77. IF(ITK_DIR)
  78. SET(ITK_FOUND 1)
  79. INCLUDE(${ITK_DIR}/ITKConfig.cmake)
  80. # Set USE_ITK_FILE for backward-compatability.
  81. SET(USE_ITK_FILE ${ITK_USE_FILE})
  82. ELSE(ITK_DIR)
  83. SET(ITK_FOUND 0)
  84. IF(ITK_FIND_REQUIRED)
  85. MESSAGE(FATAL_ERROR "Please set ITK_DIR to the ${ITK_DIR_STRING}")
  86. ENDIF(ITK_FIND_REQUIRED)
  87. ENDIF(ITK_DIR)