~ubuntu-branches/ubuntu/jaunty/cmake/jaunty-security

« back to all changes in this revision

Viewing changes to Modules/FindVTK.cmake

  • Committer: Bazaar Package Importer
  • Author(s): A. Maitland Bottoms
  • Date: 2005-03-02 09:22:44 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20050302092244-y6o9j8wr27vqcqvx
Tags: 2.0.5-1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#
2
 
# Find the native VTK includes and library
3
 
#
4
 
# This module defines:
5
 
#
6
 
# VTK_INSTALL_PATH  - Where is the installed version of VTK.
7
 
# USE_BUILT_VTK     - Should a built-from-source version of VTK be used.
8
 
#
9
 
# VTK_BINARY_PATH   - Where is (one of) the binary tree(s).
10
 
# USE_INSTALLED_VTK - Should an installed version of VTK be used
11
 
#
12
 
# USE_VTK_FILE      - (internal)
13
 
#                     Full path and location to the UseVTK.cmake file.
14
 
#                     This value changes each time USE_BUILT_VTK or 
15
 
#                     USE_INSTALLED_VTK is modified, and only if ONE of
16
 
#                     these setting is set to ON.
17
 
#
18
 
 
19
 
#
20
 
# Look for a binary tree (built from source)
21
 
22
 
FIND_PATH(VTK_BINARY_PATH UseVTK.cmake
23
 
  [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild1]
24
 
  [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild2]
25
 
  [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild3]
26
 
  [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild4]
27
 
  [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild5]
28
 
  [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild6]
29
 
  [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild7]
30
 
  [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild8]
31
 
  [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild9]
32
 
  [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild10]
33
 
  ../VTKBIN
34
 
  ../vtkbin
35
 
  VTKBIN
36
 
  vtkbin
37
 
  $ENV{HOME}/VTKBIN
38
 
  $ENV{HOME}/vtkbin
39
 
)
40
 
 
41
 
#
42
 
# If we found a built tree, USE_BUILT_VTK allows the user to 
43
 
# use it or not. Defaults to ON.
44
 
#
45
 
IF (VTK_BINARY_PATH)
46
 
  SET (USE_BUILT_VTK 1 CACHE BOOL 
47
 
       "Use a built (versus installed) version of VTK. Be sure that VTK_BINARY_PATH is correct.")
48
 
ENDIF (VTK_BINARY_PATH)
49
 
 
50
 
#
51
 
# Look for an installed tree
52
 
#
53
 
FIND_PATH(VTK_INSTALL_PATH include/vtk/UseVTK.cmake
54
 
  /usr/local
55
 
  /usr
56
 
  [HKEY_LOCAL_MACHINE\\SOFTWARE\\Kitware\\VTK\\Nightly]
57
 
  [HKEY_LOCAL_MACHINE\\SOFTWARE\\Kitware\\VTK\\43]
58
 
  [HKEY_LOCAL_MACHINE\\SOFTWARE\\Kitware\\VTK\\42]
59
 
  [HKEY_LOCAL_MACHINE\\SOFTWARE\\Kitware\\VTK\\41]
60
 
  [HKEY_LOCAL_MACHINE\\SOFTWARE\\Kitware\\VTK\\40]
61
 
)
62
 
 
63
 
#
64
 
# If we found an installed tree, USE_INSTALLED_VTK allows the user to 
65
 
# use it or not.
66
 
#
67
 
# Defaults to OFF if a built tree was found before (see above), ON otherwise.
68
 
#
69
 
IF (VTK_INSTALL_PATH)
70
 
  IF (USE_BUILT_VTK)
71
 
    SET (USE_INSTALLED_VTK 0 CACHE BOOL 
72
 
         "Use an installed (versus built from source) version of VTK. Be sure that VTK_INSTALL_PATH is correct.")
73
 
  ELSE (USE_BUILT_VTK)
74
 
    SET (USE_INSTALLED_VTK 1 CACHE BOOL 
75
 
         "Use an installed (versus built from source) version of VTK. Be sure that VTK_INSTALL_PATH is correct.")
76
 
  ENDIF (USE_BUILT_VTK)
77
 
ENDIF (VTK_INSTALL_PATH)
78
 
 
79
 
#
80
 
# Set the USE_VTK_FILE only if one of USE_BUILT_VTK or USE_INSTALLED_VTK
81
 
# is ON.
82
 
#
83
 
IF (USE_BUILT_VTK)
84
 
  IF (NOT USE_INSTALLED_VTK)
85
 
    IF (EXISTS "${VTK_BINARY_PATH}/UseVTK.cmake")
86
 
      SET (USE_VTK_FILE "${VTK_BINARY_PATH}/UseVTK.cmake")
87
 
    ENDIF (EXISTS "${VTK_BINARY_PATH}/UseVTK.cmake")
88
 
  ENDIF (NOT USE_INSTALLED_VTK)
89
 
ELSE (USE_BUILT_VTK)
90
 
  IF (USE_INSTALLED_VTK)
91
 
    IF (EXISTS "${VTK_INSTALL_PATH}/include/vtk/UseVTK.cmake")
92
 
      SET (USE_VTK_FILE "${VTK_INSTALL_PATH}/include/vtk/UseVTK.cmake")
93
 
    ENDIF (EXISTS "${VTK_INSTALL_PATH}/include/vtk/UseVTK.cmake")
94
 
  ENDIF (USE_INSTALLED_VTK)
95
 
ENDIF (USE_BUILT_VTK)
96
 
 
97
 
#
98
 
# Display a warning if both settings are set to ON.
99
 
# Otherwise display a warning if VTK was not found.
100
 
#
101
 
IF (USE_BUILT_VTK AND USE_INSTALLED_VTK)
102
 
  MESSAGE ("Warning. Please make sure that only ONE of the USE_INSTALLED_VTK or USE_BUILT_VTK setting is set to ON.")
103
 
ELSE (USE_BUILT_VTK AND USE_INSTALLED_VTK)
104
 
  IF (NOT USE_VTK_FILE)
105
 
    MESSAGE ("Warning. VTK might be found on your system as different flavours: installed VTK or built VTK. Please make sure that the VTK_INSTALL_PATH or VTK_BINARY_PATH setting reflects which VTK you are planning to use, then set ONE of the USE_INSTALLED_VTK or USE_BUILT_VTK setting to ON.")
106
 
  ENDIF (NOT USE_VTK_FILE)
107
 
ENDIF (USE_BUILT_VTK AND USE_INSTALLED_VTK)
108
 
 
109
 
# Note:
110
 
#
111
 
# If you use that module then you are probably relying on VTK to be found
112
 
# on your system. Here is the CMake code you might probably want to use to
113
 
# work hand-in-hand with that module (in that example CAN_BUILD is a var
114
 
# that is set to 0 if your project can not be build):
115
 
#
116
 
# INCLUDE (${CMAKE_ROOT}/Modules/FindVTK.cmake)
117
 
#
118
 
# IF (USE_VTK_FILE)
119
 
#   INCLUDE (${USE_VTK_FILE})
120
 
# ELSE (USE_VTK_FILE)
121
 
#   SET (CAN_BUILD 0)
122
 
# ENDIF (USE_VTK_FILE)
 
2
# Find a VTK installation or build tree.
 
3
#
 
4
# The following variables are set if VTK is found.  If VTK is not
 
5
# found, VTK_FOUND is set to false.
 
6
#
 
7
# VTK_FOUND          - Set to true when VTK is found.
 
8
# VTK_USE_FILE       - CMake source file to setup a project to use VTK.
 
9
# VTK_MAJOR_VERSION  - The VTK major version number.
 
10
# VTK_MINOR_VERSION  - The VTK minor version number (odd for non-release).
 
11
# VTK_BUILD_VERSION  - The VTK patch level (meaningless for odd minor).
 
12
# VTK_INCLUDE_DIRS   - Include directories for VTK headers.
 
13
# VTK_LIBRARY_DIRS   - Link directories for VTK libraries.
 
14
# VTK_KITS           - List of VTK kits, in all CAPS (COMMON, IO, ...).
 
15
# VTK_LANGUAGES      - List of wrapped languages, in all CAPS (TCL, ...).
 
16
#
 
17
# The following cache entries must be set by the user to locate VTK:
 
18
#
 
19
# VTK_DIR      - The directory containing VTKConfig.cmake.  This is either
 
20
#                the root of the build tree, or the lib/vtk
 
21
#                directory.  This is the only cache entry.
 
22
#
 
23
# The following variables are set for backward compatability and
 
24
# should not be used in new code:
 
25
#
 
26
# USE_VTK_FILE - The full path to the UseVTK.cmake file.  This is provided
 
27
#                for backward compatability.  Use VTK_USE_FILE instead.
 
28
#
 
29
 
 
30
# Construct consitent error messages for use below.
 
31
SET(VTK_DIR_DESCRIPTION "directory containing VTKConfig.cmake.  This is either the root of the build tree, or PREFIX/lib/vtk for an installation.  For VTK 4.0, this is the location of UseVTK.cmake.  This is either the root of the build tree or PREFIX/include/vtk for an installation.")
 
32
SET(VTK_DIR_MESSAGE "VTK not found.  Set the VTK_DIR cmake cache entry to the ${VTK_DIR_DESCRIPTION}")
 
33
 
 
34
# Search only if the location is not already known.
 
35
IF(NOT VTK_DIR)
 
36
  # Get the system search path as a list.
 
37
  IF(UNIX)
 
38
    STRING(REGEX MATCHALL "[^:]+" VTK_DIR_SEARCH1 "$ENV{PATH}")
 
39
  ELSE(UNIX)
 
40
    STRING(REGEX REPLACE "\\\\" "/" VTK_DIR_SEARCH1 "$ENV{PATH}")
 
41
  ENDIF(UNIX)
 
42
  STRING(REGEX REPLACE "/;" ";" VTK_DIR_SEARCH2 "${VTK_DIR_SEARCH1}")
 
43
 
 
44
  # Construct a set of paths relative to the system search path.
 
45
  SET(VTK_DIR_SEARCH "")
 
46
  FOREACH(dir ${VTK_DIR_SEARCH2})
 
47
    SET(VTK_DIR_SEARCH ${VTK_DIR_SEARCH} "${dir}/../lib/vtk")
 
48
  ENDFOREACH(dir)
 
49
 
 
50
  # Old scripts may set these directories in the CMakeCache.txt file.
 
51
  # They can tell us where to find VTKConfig.cmake.
 
52
  SET(VTK_DIR_SEARCH_LEGACY "")
 
53
  IF(VTK_BINARY_PATH AND USE_BUILT_VTK)
 
54
    SET(VTK_DIR_SEARCH_LEGACY ${VTK_DIR_SEARCH_LEGACY} ${VTK_BINARY_PATH})
 
55
  ENDIF(VTK_BINARY_PATH AND USE_BUILT_VTK)
 
56
  IF(VTK_INSTALL_PATH AND USE_INSTALLED_VTK)
 
57
    SET(VTK_DIR_SEARCH_LEGACY ${VTK_DIR_SEARCH_LEGACY}
 
58
        ${VTK_INSTALL_PATH}/lib/vtk)
 
59
  ENDIF(VTK_INSTALL_PATH AND USE_INSTALLED_VTK)
 
60
 
 
61
  #
 
62
  # Look for an installation or build tree.
 
63
  #
 
64
  FIND_PATH(VTK_DIR UseVTK.cmake
 
65
    # Support legacy cache files.
 
66
    ${VTK_DIR_SEARCH_LEGACY}
 
67
 
 
68
    # Look for an environment variable VTK_DIR.
 
69
    $ENV{VTK_DIR}
 
70
 
 
71
    # Look in places relative to the system executable search path.
 
72
    ${VTK_DIR_SEARCH}
 
73
 
 
74
    # Look in standard UNIX install locations.
 
75
    /usr/local/lib/vtk
 
76
    /usr/lib/vtk
 
77
 
 
78
    # Read from the CMakeSetup registry entries.  It is likely that
 
79
    # VTK will have been recently built.
 
80
    [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild1]
 
81
    [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild2]
 
82
    [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild3]
 
83
    [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild4]
 
84
    [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild5]
 
85
    [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild6]
 
86
    [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild7]
 
87
    [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild8]
 
88
    [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild9]
 
89
    [HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\Settings\\StartPath;WhereBuild10]
 
90
 
 
91
    # Help the user find it if we cannot.
 
92
    DOC "The ${VTK_DIR_DESCRIPTION}"
 
93
  )
 
94
ENDIF(NOT VTK_DIR)
 
95
 
 
96
# If VTK was found, load the configuration file to get the rest of the
 
97
# settings.
 
98
IF(VTK_DIR)
 
99
  # Make sure the VTKConfig.cmake file exists in the directory provided.
 
100
  IF(EXISTS ${VTK_DIR}/VTKConfig.cmake)
 
101
 
 
102
    # We found VTK.  Load the settings.
 
103
    SET(VTK_FOUND 1)
 
104
    INCLUDE(${VTK_DIR}/VTKConfig.cmake)
 
105
 
 
106
  ELSE(EXISTS ${VTK_DIR}/VTKConfig.cmake)
 
107
    IF(EXISTS ${VTK_DIR}/UseVTK.cmake)
 
108
      # We found VTK 4.0 (UseVTK.cmake exists, but not VTKConfig.cmake).
 
109
      SET(VTK_FOUND 1)
 
110
      # Load settings for VTK 4.0.
 
111
      INCLUDE(${CMAKE_ROOT}/Modules/UseVTKConfig40.cmake)
 
112
    ELSE(EXISTS ${VTK_DIR}/UseVTK.cmake)
 
113
      # We did not find VTK.
 
114
      SET(VTK_FOUND 0)
 
115
    ENDIF(EXISTS ${VTK_DIR}/UseVTK.cmake)
 
116
  ENDIF(EXISTS ${VTK_DIR}/VTKConfig.cmake)
 
117
ELSE(VTK_DIR)
 
118
  # We did not find VTK.
 
119
  SET(VTK_FOUND 0)
 
120
ENDIF(VTK_DIR)
 
121
 
 
122
#-----------------------------------------------------------------------------
 
123
IF(VTK_FOUND)
 
124
  # Set USE_VTK_FILE for backward-compatability.
 
125
  SET(USE_VTK_FILE ${VTK_USE_FILE})
 
126
ELSE(VTK_FOUND)
 
127
  # VTK not found, explain to the user how to specify its location.
 
128
  IF(NOT VTK_FIND_QUIETLY)
 
129
    MESSAGE(FATAL_ERROR ${VTK_DIR_MESSAGE})
 
130
  ELSE(NOT VTK_FIND_QUIETLY)
 
131
    IF(VTK_FIND_REQUIRED)
 
132
      MESSAGE(FATAL_ERROR ${VTK_DIR_MESSAGE})
 
133
    ENDIF(VTK_FIND_REQUIRED)
 
134
  ENDIF(NOT VTK_FIND_QUIETLY)
 
135
ENDIF(VTK_FOUND)