ENH: move EstimateFormatLength to kwsys
[cmake.git] / Modules / FindTCL.cmake
blob365ab112f080592b527a40603e5974aaabb4f41b
2 # This module finds if TCL is installed and determines where the
3 # include files and libraries are. It also determines what the name of
4 # the library is. This code sets the following variables:
6 #  TCL_LIBRARY            = full path to the Tcl library (tcl tcl80 etc)
7 #  TCL_LIBRARY_DEBUG      = full path to the Tcl library (debug)
8 #  TCL_STUB_LIBRARY       = full path to the Tcl stub library
9 #  TCL_STUB_LIBRARY_DEBUG = full path to the Tcl stub library (debug)
10 #  TCL_INCLUDE_PATH       = path to where tcl.h can be found
11 #  TCL_TCLSH              = full path to the tclsh binary (tcl tcl80 etc)
12 #  TK_LIBRARY             = full path to the Tk library (tk tk80 etc)
13 #  TK_LIBRARY_DEBUG       = full path to the Tk library (debug)
14 #  TK_STUB_LIBRARY        = full path to the Tk stub library
15 #  TK_STUB_LIBRARY_DEBUG  = full path to the Tk stub library (debug)
16 #  TK_INCLUDE_PATH        = path to where tk.h can be found
17 #  TK_INTERNAL_PATH       = path to where tkWinInt.h can be found
18 #  TK_WISH                = full path to the wish binary (wish wish80 etc)
21 INCLUDE(CMakeFindFrameworks)
22 INCLUDE(FindTclsh)
23 INCLUDE(FindWish)
25 GET_FILENAME_COMPONENT(TCL_TCLSH_PATH "${TCL_TCLSH}" PATH)
26 GET_FILENAME_COMPONENT(TK_WISH_PATH "${TK_WISH}" PATH)
28 SET (TCLTK_POSSIBLE_LIB_PATHS
29   "${TCL_TCLSH_PATH}/../lib"
30   "${TK_WISH_PATH}/../lib"
31   "${TCL_INCLUDE_PATH}/../lib"
32   "${TK_INCLUDE_PATH}/../lib"
33   "C:/Program Files/Tcl/lib" 
34   "C:/Tcl/lib" 
35   [HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.4;Root]/lib
36   [HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.3;Root]/lib
37   [HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.2;Root]/lib
38   [HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.0;Root]/lib
39   /usr/lib 
40   /usr/local/lib
43 FIND_LIBRARY(TCL_LIBRARY
44   NAMES tcl tcl84 tcl8.4 tcl83 tcl8.3 tcl82 tcl8.2 tcl80 tcl8.0
45   PATHS ${TCLTK_POSSIBLE_LIB_PATHS}
48 FIND_LIBRARY(TCL_LIBRARY_DEBUG
49   NAMES tcld tcl84d tcl8.4d tcl83d tcl8.3d tcl82d tcl8.2d tcl80d tcl8.0d
50   PATHS ${TCLTK_POSSIBLE_LIB_PATHS}
53 FIND_LIBRARY(TCL_STUB_LIBRARY
54   NAMES tclstub tclstub84 tclstub8.4 tclstub83 tclstub8.3 tclstub82 tclstub8.2 tclstub80 tclstub8.0
55   PATHS ${TCLTK_POSSIBLE_LIB_PATHS}
58 FIND_LIBRARY(TCL_STUB_LIBRARY_DEBUG
59   NAMES tclstubd tclstub84d tclstub8.4d tclstub83d tclstub8.3d tclstub82d tclstub8.2d tclstub80d tclstub8.0d
60   PATHS ${TCLTK_POSSIBLE_LIB_PATHS}
63 FIND_LIBRARY(TK_LIBRARY 
64   NAMES tk tk84 tk8.4 tk83 tk8.3 tk82 tk8.2 tk80 tk8.0
65   PATHS ${TCLTK_POSSIBLE_LIB_PATHS}
68 FIND_LIBRARY(TK_LIBRARY_DEBUG
69   NAMES tkd tk84d tk8.4d tk83d tk8.3d tk82d tk8.2d tk80d tk8.0d
70   PATHS ${TCLTK_POSSIBLE_LIB_PATHS}
73 FIND_LIBRARY(TK_STUB_LIBRARY 
74   NAMES tkstub tkstub84 tkstub8.4 tkstub83 tkstub8.3 tkstub82 tkstub8.2 tkstub80 tkstub8.0
75   PATHS ${TCLTK_POSSIBLE_LIB_PATHS}
78 FIND_LIBRARY(TK_STUB_LIBRARY_DEBUG
79   NAMES tkstubd tkstub84d tkstub8.4d tkstub83d tkstub8.3d tkstub82d tkstub8.2d tkstub80d tkstub8.0d
80   PATHS ${TCLTK_POSSIBLE_LIB_PATHS}
83 CMAKE_FIND_FRAMEWORKS(Tcl)
84 CMAKE_FIND_FRAMEWORKS(Tk)
86 SET(TCL_FRAMEWORK_INCLUDES)
87 IF(Tcl_FRAMEWORKS)
88   IF(NOT TCL_INCLUDE_PATH)
89     FOREACH(dir ${Tcl_FRAMEWORKS})
90       SET(TCL_FRAMEWORK_INCLUDES ${TCL_FRAMEWORK_INCLUDES} ${dir}/Headers)
91     ENDFOREACH(dir)
92   ENDIF(NOT TCL_INCLUDE_PATH)
93 ENDIF(Tcl_FRAMEWORKS)
95 SET(TK_FRAMEWORK_INCLUDES)
96 IF(Tk_FRAMEWORKS)
97   IF(NOT TK_INCLUDE_PATH)
98     FOREACH(dir ${Tk_FRAMEWORKS})
99       SET(TK_FRAMEWORK_INCLUDES ${TK_FRAMEWORK_INCLUDES}
100         ${dir}/Headers ${dir}/PrivateHeaders)
101     ENDFOREACH(dir)
102   ENDIF(NOT TK_INCLUDE_PATH)
103 ENDIF(Tk_FRAMEWORKS)
105 GET_FILENAME_COMPONENT(TCL_LIBRARY_PATH "${TCL_LIBRARY}" PATH)
106 GET_FILENAME_COMPONENT(TK_LIBRARY_PATH "${TK_LIBRARY}" PATH)
108 SET (TCLTK_POSSIBLE_INCLUDE_PATHS
109   ${TCL_TCLSH_PATH}/../include
110   ${TK_WISH_PATH}/../include
111   "${TCL_LIBRARY_PATH}/../include"
112   "${TK_LIBRARY_PATH}/../include"
113   [HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.4;Root]/include
114   [HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.3;Root]/include
115   [HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.2;Root]/include
116   [HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.0;Root]/include
117   "C:/Program Files/Tcl/include"
118   C:/Tcl/include
119   /usr/include
120   /usr/local/include
121   /usr/include/tcl8.4
122   /usr/include/tcl8.3
123   /usr/include/tcl8.2
124   /usr/include/tcl8.0
127 FIND_PATH(TCL_INCLUDE_PATH tcl.h
128   ${TCL_FRAMEWORK_INCLUDES} ${TCLTK_POSSIBLE_INCLUDE_PATHS}
131 FIND_PATH(TK_INCLUDE_PATH tk.h
132   ${TK_FRAMEWORK_INCLUDES} ${TCLTK_POSSIBLE_INCLUDE_PATHS}
135 IF (WIN32)
136   FIND_PATH(TK_INTERNAL_PATH tkWinInt.h
137     ${TCLTK_POSSIBLE_INCLUDE_PATHS}
138   )
139   MARK_AS_ADVANCED(TK_INTERNAL_PATH)
141   MARK_AS_ADVANCED(
142     TCL_TCLSH_PATH
143     TK_WISH_PATH
144     TCL_INCLUDE_PATH
145     TK_INCLUDE_PATH
146     TCL_LIBRARY
147     TCL_LIBRARY_DEBUG
148     TK_LIBRARY  
149     TK_LIBRARY_DEBUG
150     )
151 ENDIF(WIN32)
153 IF(Tcl_FRAMEWORKS)
154   # If we are using the Tcl framework, link to it.
155   IF("${TCL_INCLUDE_PATH}" MATCHES "Tcl\\.framework")
156     SET(TCL_LIBRARY "")
157   ENDIF("${TCL_INCLUDE_PATH}" MATCHES "Tcl\\.framework")
158   IF(NOT TCL_LIBRARY)
159     SET (TCL_LIBRARY "-framework Tcl" CACHE FILEPATH "Tcl Framework" FORCE)
160   ENDIF(NOT TCL_LIBRARY)
161 ENDIF(Tcl_FRAMEWORKS)
163 IF(Tk_FRAMEWORKS)
164   # If we are using the Tk framework, link to it.
165   IF("${TK_INCLUDE_PATH}" MATCHES "Tk\\.framework")
166     SET(TK_LIBRARY "")
167   ENDIF("${TK_INCLUDE_PATH}" MATCHES "Tk\\.framework")
168   IF(NOT TK_LIBRARY)
169     SET (TK_LIBRARY "-framework Tk" CACHE FILEPATH "Tk Framework" FORCE)
170   ENDIF(NOT TK_LIBRARY)
171 ENDIF(Tk_FRAMEWORKS)
173 MARK_AS_ADVANCED(
174   TCL_STUB_LIBRARY
175   TCL_STUB_LIBRARY_DEBUG
176   TK_STUB_LIBRARY  
177   TK_STUB_LIBRARY_DEBUG
178   )
180 IF(TCL_INCLUDE_PATH)
181   IF(TK_INCLUDE_PATH)
182     IF(TCL_LIBRARY)
183       IF(TK_LIBRARY)
184         SET(TCL_FOUND 1)
185       ENDIF(TK_LIBRARY)
186     ENDIF(TCL_LIBRARY)
187   ENDIF(TK_INCLUDE_PATH)
188 ENDIF(TCL_INCLUDE_PATH)