Imported Upstream version 2.8.10.2
[platform/upstream/cmake.git] / Modules / FindTclStub.cmake
1 # - Find Tcl stub libraries.
2 # This module finds Tcl stub libraries. It first finds Tcl include files and
3 # libraries by calling FindTCL.cmake.
4 # How to Use the Tcl Stubs Library:
5 #   http://tcl.activestate.com/doc/howto/stubs.html
6 # Using Stub Libraries:
7 #   http://safari.oreilly.com/0130385603/ch48lev1sec3
8 # This code sets the following variables:
9 #  TCL_STUB_LIBRARY       = path to Tcl stub library
10 #  TK_STUB_LIBRARY        = path to Tk stub library
11 #  TTK_STUB_LIBRARY       = path to ttk stub library
12 #
13 # In an effort to remove some clutter and clear up some issues for people
14 # who are not necessarily Tcl/Tk gurus/developpers, some variables were
15 # moved or removed. Changes compared to CMake 2.4 are:
16 # - TCL_STUB_LIBRARY_DEBUG and TK_STUB_LIBRARY_DEBUG were removed.
17 #   => these libs are not packaged by default with Tcl/Tk distributions.
18 #      Even when Tcl/Tk is built from source, several flavors of debug libs
19 #      are created and there is no real reason to pick a single one
20 #      specifically (say, amongst tclstub84g, tclstub84gs, or tclstub84sgx).
21 #      Let's leave that choice to the user by allowing him to assign
22 #      TCL_STUB_LIBRARY to any Tcl library, debug or not.
23
24 #=============================================================================
25 # Copyright 2008-2009 Kitware, Inc.
26 #
27 # Distributed under the OSI-approved BSD License (the "License");
28 # see accompanying file Copyright.txt for details.
29 #
30 # This software is distributed WITHOUT ANY WARRANTY; without even the
31 # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
32 # See the License for more information.
33 #=============================================================================
34 # (To distribute this file outside of CMake, substitute the full
35 #  License text for the above reference.)
36
37 include(FindTCL)
38
39 get_filename_component(TCL_TCLSH_PATH "${TCL_TCLSH}" PATH)
40 get_filename_component(TCL_TCLSH_PATH_PARENT "${TCL_TCLSH_PATH}" PATH)
41 string(REGEX REPLACE
42   "^.*tclsh([0-9]\\.*[0-9]).*$" "\\1" TCL_TCLSH_VERSION "${TCL_TCLSH}")
43
44 get_filename_component(TK_WISH_PATH "${TK_WISH}" PATH)
45 get_filename_component(TK_WISH_PATH_PARENT "${TK_WISH_PATH}" PATH)
46 string(REGEX REPLACE
47   "^.*wish([0-9]\\.*[0-9]).*$" "\\1" TK_WISH_VERSION "${TK_WISH}")
48
49 get_filename_component(TCL_INCLUDE_PATH_PARENT "${TCL_INCLUDE_PATH}" PATH)
50 get_filename_component(TK_INCLUDE_PATH_PARENT "${TK_INCLUDE_PATH}" PATH)
51
52 get_filename_component(TCL_LIBRARY_PATH "${TCL_LIBRARY}" PATH)
53 get_filename_component(TCL_LIBRARY_PATH_PARENT "${TCL_LIBRARY_PATH}" PATH)
54 string(REGEX REPLACE
55   "^.*tcl([0-9]\\.*[0-9]).*$" "\\1" TCL_LIBRARY_VERSION "${TCL_LIBRARY}")
56
57 get_filename_component(TK_LIBRARY_PATH "${TK_LIBRARY}" PATH)
58 get_filename_component(TK_LIBRARY_PATH_PARENT "${TK_LIBRARY_PATH}" PATH)
59 string(REGEX REPLACE
60   "^.*tk([0-9]\\.*[0-9]).*$" "\\1" TK_LIBRARY_VERSION "${TK_LIBRARY}")
61
62 set(TCLTK_POSSIBLE_LIB_PATHS
63   "${TCL_INCLUDE_PATH_PARENT}/lib"
64   "${TK_INCLUDE_PATH_PARENT}/lib"
65   "${TCL_LIBRARY_PATH}"
66   "${TK_LIBRARY_PATH}"
67   "${TCL_TCLSH_PATH_PARENT}/lib"
68   "${TK_WISH_PATH_PARENT}/lib"
69 )
70
71 if(WIN32)
72   get_filename_component(
73     ActiveTcl_CurrentVersion
74     "[HKEY_LOCAL_MACHINE\\SOFTWARE\\ActiveState\\ActiveTcl;CurrentVersion]"
75     NAME)
76   set(TCLTK_POSSIBLE_LIB_PATHS ${TCLTK_POSSIBLE_LIB_PATHS}
77     "[HKEY_LOCAL_MACHINE\\SOFTWARE\\ActiveState\\ActiveTcl\\${ActiveTcl_CurrentVersion}]/lib"
78     "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.6;Root]/lib"
79     "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.5;Root]/lib"
80     "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.4;Root]/lib"
81     "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.3;Root]/lib"
82     "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.2;Root]/lib"
83     "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.0;Root]/lib"
84     "$ENV{ProgramFiles}/Tcl/Lib"
85     "C:/Program Files/Tcl/lib"
86     "C:/Tcl/lib"
87     )
88 endif()
89
90 find_library(TCL_STUB_LIBRARY
91   NAMES
92   tclstub
93   tclstub${TK_LIBRARY_VERSION} tclstub${TCL_TCLSH_VERSION} tclstub${TK_WISH_VERSION}
94   tclstub86 tclstub8.6
95   tclstub85 tclstub8.5
96   tclstub84 tclstub8.4
97   tclstub83 tclstub8.3
98   tclstub82 tclstub8.2
99   tclstub80 tclstub8.0
100   PATHS ${TCLTK_POSSIBLE_LIB_PATHS}
101 )
102
103 find_library(TK_STUB_LIBRARY
104   NAMES
105   tkstub
106   tkstub${TCL_LIBRARY_VERSION} tkstub${TCL_TCLSH_VERSION} tkstub${TK_WISH_VERSION}
107   tkstub86 tkstub8.6
108   tkstub85 tkstub8.5
109   tkstub84 tkstub8.4
110   tkstub83 tkstub8.3
111   tkstub82 tkstub8.2
112   tkstub80 tkstub8.0
113   PATHS ${TCLTK_POSSIBLE_LIB_PATHS}
114 )
115
116 find_library(TTK_STUB_LIBRARY
117   NAMES
118   ttkstub
119   ttkstub${TCL_LIBRARY_VERSION} ttkstub${TCL_TCLSH_VERSION} ttkstub${TK_WISH_VERSION}
120   ttkstub88 ttkstub8.8
121   ttkstub87 ttkstub8.7
122   ttkstub86 ttkstub8.6
123   ttkstub85 ttkstub8.5
124   PATHS ${TCLTK_POSSIBLE_LIB_PATHS}
125 )
126
127 mark_as_advanced(
128   TCL_STUB_LIBRARY
129   TK_STUB_LIBRARY
130   )