ENH: fix bug where sharedforward would not work if there was a space in the path...
[cmake.git] / Modules / FindTclStub.cmake
blob788dbe4b58893dbe95b09f885ce102a46bb7e9ae
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
12 # In an effort to remove some clutter and clear up some issues for people
13 # who are not necessarily Tcl/Tk gurus/developpers, some variables were
14 # moved or removed. Changes compared to CMake 2.4 are:
15 # - TCL_STUB_LIBRARY_DEBUG and TK_STUB_LIBRARY_DEBUG were removed.
16 #   => these libs are not packaged by default with Tcl/Tk distributions. 
17 #      Even when Tcl/Tk is built from source, several flavors of debug libs
18 #      are created and there is no real reason to pick a single one
19 #      specifically (say, amongst tclstub84g, tclstub84gs, or tclstub84sgx). 
20 #      Let's leave that choice to the user by allowing him to assign 
21 #      TCL_STUB_LIBRARY to any Tcl library, debug or not.
23 INCLUDE(FindTCL)
25 GET_FILENAME_COMPONENT(TCL_TCLSH_PATH "${TCL_TCLSH}" PATH)
26 GET_FILENAME_COMPONENT(TCL_TCLSH_PATH_PARENT "${TCL_TCLSH_PATH}" PATH)
27 STRING(REGEX REPLACE 
28   "^.*tclsh([0-9]\\.*[0-9]).*$" "\\1" TCL_TCLSH_VERSION "${TCL_TCLSH}")
30 GET_FILENAME_COMPONENT(TK_WISH_PATH "${TK_WISH}" PATH)
31 GET_FILENAME_COMPONENT(TK_WISH_PATH_PARENT "${TK_WISH_PATH}" PATH)
32 STRING(REGEX REPLACE 
33   "^.*wish([0-9]\\.*[0-9]).*$" "\\1" TK_WISH_VERSION "${TK_WISH}")
35 GET_FILENAME_COMPONENT(TCL_INCLUDE_PATH_PARENT "${TCL_INCLUDE_PATH}" PATH)
36 GET_FILENAME_COMPONENT(TK_INCLUDE_PATH_PARENT "${TK_INCLUDE_PATH}" PATH)
38 GET_FILENAME_COMPONENT(TCL_LIBRARY_PATH "${TCL_LIBRARY}" PATH)
39 GET_FILENAME_COMPONENT(TCL_LIBRARY_PATH_PARENT "${TCL_LIBRARY_PATH}" PATH)
40 STRING(REGEX REPLACE 
41   "^.*tcl([0-9]\\.*[0-9]).*$" "\\1" TCL_LIBRARY_VERSION "${TCL_LIBRARY}")
43 GET_FILENAME_COMPONENT(TK_LIBRARY_PATH "${TK_LIBRARY}" PATH)
44 GET_FILENAME_COMPONENT(TK_LIBRARY_PATH_PARENT "${TK_LIBRARY_PATH}" PATH)
45 STRING(REGEX REPLACE 
46   "^.*tk([0-9]\\.*[0-9]).*$" "\\1" TK_LIBRARY_VERSION "${TK_LIBRARY}")
48 SET(TCLTK_POSSIBLE_LIB_PATHS
49   "${TCL_INCLUDE_PATH_PARENT}/lib"
50   "${TK_INCLUDE_PATH_PARENT}/lib"
51   "${TCL_LIBRARY_PATH}"
52   "${TK_LIBRARY_PATH}"
53   "${TCL_TCLSH_PATH_PARENT}/lib"
54   "${TK_WISH_PATH_PARENT}/lib"
55   /usr/lib 
56   /usr/local/lib
59 IF(WIN32)
60   GET_FILENAME_COMPONENT(
61     ActiveTcl_CurrentVersion 
62     "[HKEY_LOCAL_MACHINE\\SOFTWARE\\ActiveState\\ActiveTcl;CurrentVersion]" 
63     NAME)
64   SET(TCLTK_POSSIBLE_LIB_PATHS ${TCLTK_POSSIBLE_LIB_PATHS}
65     "[HKEY_LOCAL_MACHINE\\SOFTWARE\\ActiveState\\ActiveTcl\\${ActiveTcl_CurrentVersion}]/lib"
66     "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.6;Root]/lib"
67     "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.5;Root]/lib"
68     "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.4;Root]/lib"
69     "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.3;Root]/lib"
70     "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.2;Root]/lib"
71     "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.0;Root]/lib"
72     "$ENV{ProgramFiles}/Tcl/Lib"
73     "C:/Program Files/Tcl/lib" 
74     "C:/Tcl/lib" 
75     )
76 ENDIF(WIN32)
78 FIND_LIBRARY(TCL_STUB_LIBRARY
79   NAMES 
80   tclstub 
81   tclstub${TK_LIBRARY_VERSION} tclstub${TCL_TCLSH_VERSION} tclstub${TK_WISH_VERSION}
82   tclstub86 tclstub8.6
83   tclstub85 tclstub8.5 
84   tclstub84 tclstub8.4 
85   tclstub83 tclstub8.3 
86   tclstub82 tclstub8.2 
87   tclstub80 tclstub8.0
88   PATHS ${TCLTK_POSSIBLE_LIB_PATHS}
91 FIND_LIBRARY(TK_STUB_LIBRARY 
92   NAMES 
93   tkstub 
94   tkstub${TCL_LIBRARY_VERSION} tkstub${TCL_TCLSH_VERSION} tkstub${TK_WISH_VERSION}
95   tkstub86 tkstub8.6
96   tkstub85 tkstub8.5 
97   tkstub84 tkstub8.4 
98   tkstub83 tkstub8.3 
99   tkstub82 tkstub8.2 
100   tkstub80 tkstub8.0
101   PATHS ${TCLTK_POSSIBLE_LIB_PATHS}
104 MARK_AS_ADVANCED(
105   TCL_STUB_LIBRARY
106   TK_STUB_LIBRARY
107   )