FindITK.cmake 3.3 KB

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