Imported Upstream version 2.8.10.2
[platform/upstream/cmake.git] / Modules / FindCABLE.cmake
1 # - Find CABLE
2 # This module finds if CABLE is installed and determines where the
3 # include files and libraries are.  This code sets the following variables:
4 #
5 #  CABLE             the path to the cable executable
6 #  CABLE_TCL_LIBRARY the path to the Tcl wrapper library
7 #  CABLE_INCLUDE_DIR the path to the include directory
8 #
9 # To build Tcl wrappers, you should add shared library and link it to
10 # ${CABLE_TCL_LIBRARY}.  You should also add ${CABLE_INCLUDE_DIR} as
11 # an include directory.
12
13 #=============================================================================
14 # Copyright 2001-2009 Kitware, Inc.
15 #
16 # Distributed under the OSI-approved BSD License (the "License");
17 # see accompanying file Copyright.txt for details.
18 #
19 # This software is distributed WITHOUT ANY WARRANTY; without even the
20 # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
21 # See the License for more information.
22 #=============================================================================
23 # (To distribute this file outside of CMake, substitute the full
24 #  License text for the above reference.)
25
26 if(NOT CABLE)
27   find_path(CABLE_BUILD_DIR cableVersion.h)
28 endif()
29
30 if(CABLE_BUILD_DIR)
31   load_cache(${CABLE_BUILD_DIR}
32              EXCLUDE
33                BUILD_SHARED_LIBS
34                LIBRARY_OUTPUT_PATH
35                EXECUTABLE_OUTPUT_PATH
36                MAKECOMMAND
37                CMAKE_INSTALL_PREFIX
38              INCLUDE_INTERNALS
39                CABLE_LIBRARY_PATH
40                CABLE_EXECUTABLE_PATH)
41
42   if(CABLE_LIBRARY_PATH)
43     find_library(CABLE_TCL_LIBRARY NAMES CableTclFacility PATHS
44                  ${CABLE_LIBRARY_PATH}
45                  ${CABLE_LIBRARY_PATH}/*)
46   else()
47     find_library(CABLE_TCL_LIBRARY NAMES CableTclFacility PATHS
48                  ${CABLE_BINARY_DIR}/CableTclFacility
49                  ${CABLE_BINARY_DIR}/CableTclFacility/*)
50   endif()
51
52   if(CABLE_EXECUTABLE_PATH)
53     find_program(CABLE NAMES cable PATHS
54                  ${CABLE_EXECUTABLE_PATH}
55                  ${CABLE_EXECUTABLE_PATH}/*)
56   else()
57     find_program(CABLE NAMES cable PATHS
58                  ${CABLE_BINARY_DIR}/Executables
59                  ${CABLE_BINARY_DIR}/Executables/*)
60   endif()
61
62   find_path(CABLE_INCLUDE_DIR CableTclFacility/ctCalls.h
63             ${CABLE_SOURCE_DIR})
64 else()
65   # Find the cable executable in the path.
66   find_program(CABLE NAMES cable)
67
68   # Get the path where the executable sits, but without the executable
69   # name on it.
70   get_filename_component(CABLE_ROOT_BIN ${CABLE} PATH)
71
72   # Find the cable include directory in a path relative to the cable
73   # executable.
74   find_path(CABLE_INCLUDE_DIR CableTclFacility/ctCalls.h
75             ${CABLE_ROOT_BIN}/../include/Cable)
76
77   # Find the WrapTclFacility library in a path relative to the cable
78   # executable.
79   find_library(CABLE_TCL_LIBRARY NAMES CableTclFacility PATHS
80                ${CABLE_ROOT_BIN}/../lib/Cable)
81 endif()