Resync
[CMakeLuaTailorHgBridge.git] / CMakeLua / Modules / FindTclStub.cmake
blob196d57b410c9cec05f3c94dd67b37392d9d981aa
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
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.
24 INCLUDE(FindTCL)
26 GET_FILENAME_COMPONENT(TCL_TCLSH_PATH "${TCL_TCLSH}" PATH)
27 GET_FILENAME_COMPONENT(TCL_TCLSH_PATH_PARENT "${TCL_TCLSH_PATH}" PATH)
28 STRING(REGEX REPLACE 
29   "^.*tclsh([0-9]\\.*[0-9]).*$" "\\1" TCL_TCLSH_VERSION "${TCL_TCLSH}")
31 GET_FILENAME_COMPONENT(TK_WISH_PATH "${TK_WISH}" PATH)
32 GET_FILENAME_COMPONENT(TK_WISH_PATH_PARENT "${TK_WISH_PATH}" PATH)
33 STRING(REGEX REPLACE 
34   "^.*wish([0-9]\\.*[0-9]).*$" "\\1" TK_WISH_VERSION "${TK_WISH}")
36 GET_FILENAME_COMPONENT(TCL_INCLUDE_PATH_PARENT "${TCL_INCLUDE_PATH}" PATH)
37 GET_FILENAME_COMPONENT(TK_INCLUDE_PATH_PARENT "${TK_INCLUDE_PATH}" PATH)
39 GET_FILENAME_COMPONENT(TCL_LIBRARY_PATH "${TCL_LIBRARY}" PATH)
40 GET_FILENAME_COMPONENT(TCL_LIBRARY_PATH_PARENT "${TCL_LIBRARY_PATH}" PATH)
41 STRING(REGEX REPLACE 
42   "^.*tcl([0-9]\\.*[0-9]).*$" "\\1" TCL_LIBRARY_VERSION "${TCL_LIBRARY}")
44 GET_FILENAME_COMPONENT(TK_LIBRARY_PATH "${TK_LIBRARY}" PATH)
45 GET_FILENAME_COMPONENT(TK_LIBRARY_PATH_PARENT "${TK_LIBRARY_PATH}" PATH)
46 STRING(REGEX REPLACE 
47   "^.*tk([0-9]\\.*[0-9]).*$" "\\1" TK_LIBRARY_VERSION "${TK_LIBRARY}")
49 SET(TCLTK_POSSIBLE_LIB_PATHS
50   "${TCL_INCLUDE_PATH_PARENT}/lib"
51   "${TK_INCLUDE_PATH_PARENT}/lib"
52   "${TCL_LIBRARY_PATH}"
53   "${TK_LIBRARY_PATH}"
54   "${TCL_TCLSH_PATH_PARENT}/lib"
55   "${TK_WISH_PATH_PARENT}/lib"
56   /usr/lib 
57   /usr/local/lib
60 IF(WIN32)
61   GET_FILENAME_COMPONENT(
62     ActiveTcl_CurrentVersion 
63     "[HKEY_LOCAL_MACHINE\\SOFTWARE\\ActiveState\\ActiveTcl;CurrentVersion]" 
64     NAME)
65   SET(TCLTK_POSSIBLE_LIB_PATHS ${TCLTK_POSSIBLE_LIB_PATHS}
66     "[HKEY_LOCAL_MACHINE\\SOFTWARE\\ActiveState\\ActiveTcl\\${ActiveTcl_CurrentVersion}]/lib"
67     "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.6;Root]/lib"
68     "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.5;Root]/lib"
69     "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.4;Root]/lib"
70     "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.3;Root]/lib"
71     "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.2;Root]/lib"
72     "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.0;Root]/lib"
73     "$ENV{ProgramFiles}/Tcl/Lib"
74     "C:/Program Files/Tcl/lib" 
75     "C:/Tcl/lib" 
76     )
77 ENDIF(WIN32)
79 FIND_LIBRARY(TCL_STUB_LIBRARY
80   NAMES 
81   tclstub 
82   tclstub${TK_LIBRARY_VERSION} tclstub${TCL_TCLSH_VERSION} tclstub${TK_WISH_VERSION}
83   tclstub86 tclstub8.6
84   tclstub85 tclstub8.5 
85   tclstub84 tclstub8.4 
86   tclstub83 tclstub8.3 
87   tclstub82 tclstub8.2 
88   tclstub80 tclstub8.0
89   PATHS ${TCLTK_POSSIBLE_LIB_PATHS}
92 FIND_LIBRARY(TK_STUB_LIBRARY 
93   NAMES 
94   tkstub 
95   tkstub${TCL_LIBRARY_VERSION} tkstub${TCL_TCLSH_VERSION} tkstub${TK_WISH_VERSION}
96   tkstub86 tkstub8.6
97   tkstub85 tkstub8.5 
98   tkstub84 tkstub8.4 
99   tkstub83 tkstub8.3 
100   tkstub82 tkstub8.2 
101   tkstub80 tkstub8.0
102   PATHS ${TCLTK_POSSIBLE_LIB_PATHS}
105 FIND_LIBRARY(TTK_STUB_LIBRARY 
106   NAMES 
107   ttkstub 
108   ttkstub${TCL_LIBRARY_VERSION} ttkstub${TCL_TCLSH_VERSION} ttkstub${TK_WISH_VERSION}
109   ttkstub88 ttkstub8.8
110   ttkstub87 ttkstub8.7
111   ttkstub86 ttkstub8.6
112   ttkstub85 ttkstub8.5 
113   PATHS ${TCLTK_POSSIBLE_LIB_PATHS}
116 MARK_AS_ADVANCED(
117   TCL_STUB_LIBRARY
118   TK_STUB_LIBRARY
119   )