FindOpenIGTLink.cmake 3.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. # - Find an OpenIGTLink installation or build tree.
  2. # When OpenIGTLink is found, the OpenIGTLinkConfig.cmake file is sourced to setup the
  3. # location and configuration of OpenIGTLink. Please read this file, or
  4. # OpenIGTLinkConfig.cmake.in from the OpenIGTLink source tree for the full list of
  5. # definitions. Of particular interest is OpenIGTLink_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. # OpenIGTLinkConfig.cmake, this find module also defines
  9. # OpenIGTLink_DIR - The directory containing OpenIGTLinkConfig.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. # OpenIGTLink_FOUND - Whether OpenIGTLink was found. If this is true,
  15. # OpenIGTLink_DIR is okay.
  16. #
  17. # USE_OpenIGTLink_FILE - The full path to the UseOpenIGTLink.cmake file.
  18. # This is provided for backward
  19. # compatability. Use OpenIGTLink_USE_FILE
  20. # instead.
  21. SET(OpenIGTLink_DIR_STRING "directory containing OpenIGTLinkConfig.cmake. This is either the root of the build tree, or PREFIX/lib/igtl for an installation.")
  22. # Search only if the location is not already known.
  23. IF(NOT OpenIGTLink_DIR)
  24. # Get the system search path as a list.
  25. IF(UNIX)
  26. STRING(REGEX MATCHALL "[^:]+" OpenIGTLink_DIR_SEARCH1 "$ENV{PATH}")
  27. ELSE(UNIX)
  28. STRING(REGEX REPLACE "\\\\" "/" OpenIGTLink_DIR_SEARCH1 "$ENV{PATH}")
  29. ENDIF(UNIX)
  30. STRING(REGEX REPLACE "/;" ";" OpenIGTLink_DIR_SEARCH2 ${OpenIGTLink_DIR_SEARCH1})
  31. # Construct a set of paths relative to the system search path.
  32. SET(OpenIGTLink_DIR_SEARCH "")
  33. FOREACH(dir ${OpenIGTLink_DIR_SEARCH2})
  34. SET(OpenIGTLink_DIR_SEARCH ${OpenIGTLink_DIR_SEARCH} "${dir}/../lib/igtl")
  35. ENDFOREACH(dir)
  36. #
  37. # Look for an installation or build tree.
  38. #
  39. FIND_PATH(OpenIGTLink_DIR OpenIGTLinkConfig.cmake
  40. # Look for an environment variable OpenIGTLink_DIR.
  41. $ENV{OpenIGTLink_DIR}
  42. # Look in places relative to the system executable search path.
  43. ${OpenIGTLink_DIR_SEARCH}
  44. # Look in standard UNIX install locations.
  45. /usr/local/lib/igtl
  46. /usr/lib/igtl
  47. # Read from the CMakeSetup registry entries. It is likely that
  48. # OpenIGTLink 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 ${OpenIGTLink_DIR_STRING}"
  61. )
  62. ENDIF(NOT OpenIGTLink_DIR)
  63. # If OpenIGTLink was found, load the configuration file to get the rest of the
  64. # settings.
  65. IF(OpenIGTLink_DIR)
  66. SET(OpenIGTLink_FOUND 1)
  67. INCLUDE(${OpenIGTLink_DIR}/OpenIGTLinkConfig.cmake)
  68. # Set USE_OpenIGTLink_FILE for backward-compatability.
  69. SET(USE_OpenIGTLink_FILE ${OpenIGTLink_USE_FILE})
  70. ELSE(OpenIGTLink_DIR)
  71. SET(OpenIGTLink_FOUND 0)
  72. IF(OpenIGTLink_FIND_REQUIRED)
  73. MESSAGE(FATAL_ERROR "Please set OpenIGTLink_DIR to the ${OpenIGTLink_DIR_STRING}")
  74. ENDIF(OpenIGTLink_FIND_REQUIRED)
  75. ENDIF(OpenIGTLink_DIR)