ENH: update for Tcl/Tk 8.5
[cmake.git] / Modules / FindTCL.cmake
blob6af7ea7348b9871834f843f05c23c1abdd659e47
1 # - Find Tcl includes and libraries.
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:
5 #  TCL_FOUND              = Tcl was found
6 #  TK_FOUND               = Tk was found
7 #  TCLTK_FOUND            = Tcl and Tk were found
8 #  TCL_LIBRARY            = path to Tcl library (tcl tcl80)
9 #  TCL_INCLUDE_PATH       = path to where tcl.h can be found
10 #  TCL_TCLSH              = path to tclsh binary (tcl tcl80)
11 #  TK_LIBRARY             = path to Tk library (tk tk80 etc)
12 #  TK_INCLUDE_PATH        = path to where tk.h can be found
13 #  TK_WISH                = full path to the wish executable
15 # In an effort to remove some clutter and clear up some issues for people
16 # who are not necessarily Tcl/Tk gurus/developpers, some variables were
17 # moved or removed. Changes compared to CMake 2.4 are:
18 # - The stub libraries are now found in FindTclStub.cmake
19 #   => they were only useful for people writing Tcl/Tk extensions.
20 # - TCL_LIBRARY_DEBUG and TK_LIBRARY_DEBUG were removed.
21 #   => these libs are not packaged by default with Tcl/Tk distributions. 
22 #      Even when Tcl/Tk is built from source, several flavors of debug libs
23 #      are created and there is no real reason to pick a single one
24 #      specifically (say, amongst tcl84g, tcl84gs, or tcl84sgx). 
25 #      Let's leave that choice to the user by allowing him to assign 
26 #      TCL_LIBRARY to any Tcl library, debug or not.
27 # - TK_INTERNAL_PATH was removed.
28 #   => this ended up being only a Win32 variable, and there is a lot of
29 #      confusion regarding the location of this file in an installed Tcl/Tk
30 #      tree anyway (see 8.5 for example). If you need the internal path at
31 #      this point it is safer you ask directly where the *source* tree is
32 #      and dig from there.
34 INCLUDE(CMakeFindFrameworks)
35 INCLUDE(FindTclsh)
36 INCLUDE(FindWish)
38 GET_FILENAME_COMPONENT(TCL_TCLSH_PATH "${TCL_TCLSH}" PATH)
39 GET_FILENAME_COMPONENT(TCL_TCLSH_PATH_PARENT "${TCL_TCLSH_PATH}" PATH)
41 GET_FILENAME_COMPONENT(TK_WISH_PATH "${TK_WISH}" PATH)
42 GET_FILENAME_COMPONENT(TK_WISH_PATH_PARENT "${TK_WISH_PATH}" PATH)
44 GET_FILENAME_COMPONENT(TCL_INCLUDE_PATH_PARENT "${TCL_INCLUDE_PATH}" PATH)
45 GET_FILENAME_COMPONENT(TK_INCLUDE_PATH_PARENT "${TK_INCLUDE_PATH}" PATH)
47 GET_FILENAME_COMPONENT(TCL_LIBRARY_PATH "${TCL_LIBRARY}" PATH)
48 GET_FILENAME_COMPONENT(TCL_LIBRARY_PATH_PARENT "${TCL_LIBRARY_PATH}" PATH)
50 GET_FILENAME_COMPONENT(TK_LIBRARY_PATH "${TK_LIBRARY}" PATH)
51 GET_FILENAME_COMPONENT(TK_LIBRARY_PATH_PARENT "${TK_LIBRARY_PATH}" PATH)
53 SET(TCLTK_POSSIBLE_LIB_PATHS
54   "${TCL_INCLUDE_PATH_PARENT}/lib"
55   "${TK_INCLUDE_PATH_PARENT}/lib"
56   "${TCL_LIBRARY_PATH}"
57   "${TK_LIBRARY_PATH}"
58   "${TCL_TCLSH_PATH_PARENT}/lib"
59   "${TK_WISH_PATH_PARENT}/lib"
60   /usr/lib 
61   /usr/local/lib
62   )
64 IF(WIN32)
65   GET_FILENAME_COMPONENT(
66     ActiveTcl_CurrentVersion 
67     "[HKEY_LOCAL_MACHINE\\SOFTWARE\\ActiveState\\ActiveTcl;CurrentVersion]" 
68     NAME)
69   SET(TCLTK_POSSIBLE_LIB_PATHS ${TCLTK_POSSIBLE_LIB_PATHS}
70     "[HKEY_LOCAL_MACHINE\\SOFTWARE\\ActiveState\\ActiveTcl\\${ActiveTcl_CurrentVersion}]/lib"
71     "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.6;Root]/lib"
72     "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.5;Root]/lib"
73     "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.4;Root]/lib"
74     "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.3;Root]/lib"
75     "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.2;Root]/lib"
76     "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.0;Root]/lib"
77     "$ENV{ProgramFiles}/Tcl/Lib"
78     "C:/Program Files/Tcl/lib" 
79     "C:/Tcl/lib" 
80     )
81 ENDIF(WIN32)
83 FIND_LIBRARY(TCL_LIBRARY
84   NAMES tcl 
85   tcl86 tcl8.6 
86   tcl85 tcl8.5 
87   tcl84 tcl8.4 
88   tcl83 tcl8.3 
89   tcl82 tcl8.2 
90   tcl80 tcl8.0
91   PATHS ${TCLTK_POSSIBLE_LIB_PATHS}
92   )
94 FIND_LIBRARY(TK_LIBRARY 
95   NAMES tk 
96   tk86 tk8.6
97   tk85 tk8.5 
98   tk84 tk8.4 
99   tk83 tk8.3 
100   tk82 tk8.2 
101   tk80 tk8.0
102   PATHS ${TCLTK_POSSIBLE_LIB_PATHS}
103   )
105 CMAKE_FIND_FRAMEWORKS(Tcl)
106 CMAKE_FIND_FRAMEWORKS(Tk)
108 SET(TCL_FRAMEWORK_INCLUDES)
109 IF(Tcl_FRAMEWORKS)
110   IF(NOT TCL_INCLUDE_PATH)
111     FOREACH(dir ${Tcl_FRAMEWORKS})
112       SET(TCL_FRAMEWORK_INCLUDES ${TCL_FRAMEWORK_INCLUDES} ${dir}/Headers)
113     ENDFOREACH(dir)
114   ENDIF(NOT TCL_INCLUDE_PATH)
115 ENDIF(Tcl_FRAMEWORKS)
117 SET(TK_FRAMEWORK_INCLUDES)
118 IF(Tk_FRAMEWORKS)
119   IF(NOT TK_INCLUDE_PATH)
120     FOREACH(dir ${Tk_FRAMEWORKS})
121       SET(TK_FRAMEWORK_INCLUDES ${TK_FRAMEWORK_INCLUDES}
122         ${dir}/Headers ${dir}/PrivateHeaders)
123     ENDFOREACH(dir)
124   ENDIF(NOT TK_INCLUDE_PATH)
125 ENDIF(Tk_FRAMEWORKS)
127 SET(TCLTK_POSSIBLE_INCLUDE_PATHS
128   "${TCL_LIBRARY_PATH_PARENT}/include"
129   "${TK_LIBRARY_PATH_PARENT}/include"
130   "${TCL_INCLUDE_PATH}"
131   "${TK_INCLUDE_PATH}"
132   ${TCL_FRAMEWORK_INCLUDES} 
133   ${TK_FRAMEWORK_INCLUDES} 
134   "${TCL_TCLSH_PATH_PARENT}/include"
135   "${TK_WISH_PATH_PARENT}/include"
136   /usr/include
137   /usr/local/include
138   /usr/include/tcl8.6
139   /usr/include/tcl8.5
140   /usr/include/tcl8.4
141   /usr/include/tcl8.3
142   /usr/include/tcl8.2
143   /usr/include/tcl8.0
144   )
146 IF(WIN32)
147   SET(TCLTK_POSSIBLE_INCLUDE_PATHS ${TCLTK_POSSIBLE_INCLUDE_PATHS}
148     "[HKEY_LOCAL_MACHINE\\SOFTWARE\\ActiveState\\ActiveTcl\\${ActiveTcl_CurrentVersion}]/include"
149     "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.6;Root]/include"
150     "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.5;Root]/include"
151     "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.4;Root]/include"
152     "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.3;Root]/include"
153     "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.2;Root]/include"
154     "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.0;Root]/include"
155     "$ENV{ProgramFiles}/Tcl/include"
156     "C:/Program Files/Tcl/include"
157     "C:/Tcl/include"
158     )
159 ENDIF(WIN32)
161 FIND_PATH(TCL_INCLUDE_PATH 
162   NAMES tcl.h
163   PATHS ${TCLTK_POSSIBLE_INCLUDE_PATHS} 
164   NO_DEFAULT_PATH
165   )
166 FIND_PATH(TCL_INCLUDE_PATH 
167   NAMES tcl.h
168   PATHS ${TCLTK_POSSIBLE_INCLUDE_PATHS}
169   )
171 FIND_PATH(TK_INCLUDE_PATH 
172   NAMES tk.h
173   PATHS ${TCLTK_POSSIBLE_INCLUDE_PATHS} 
174   NO_DEFAULT_PATH
175   )
176 FIND_PATH(TK_INCLUDE_PATH 
177   NAMES tk.h
178   PATHS ${TCLTK_POSSIBLE_INCLUDE_PATHS}
179   )
181 # handle the QUIETLY and REQUIRED arguments and set TCL_FOUND to TRUE if 
182 # all listed variables are TRUE
183 INCLUDE(FindPackageHandleStandardArgs)
185 FIND_PACKAGE_HANDLE_STANDARD_ARGS(TCL DEFAULT_MSG TCL_LIBRARY TCL_INCLUDE_PATH)
186 SET(TCLTK_FIND_REQUIRED ${TCL_FIND_REQUIRED})
187 SET(TCLTK_FIND_QUIETLY  ${TCL_FIND_QUIETLY})
188 FIND_PACKAGE_HANDLE_STANDARD_ARGS(TCLTK DEFAULT_MSG TCL_LIBRARY TCL_INCLUDE_PATH TK_LIBRARY TK_INCLUDE_PATH)
189 SET(TK_FIND_REQUIRED ${TCL_FIND_REQUIRED})
190 SET(TK_FIND_QUIETLY  ${TCL_FIND_QUIETLY})
191 FIND_PACKAGE_HANDLE_STANDARD_ARGS(TK DEFAULT_MSG TK_LIBRARY TK_INCLUDE_PATH)
193 MARK_AS_ADVANCED(
194   TCL_TCLSH_PATH
195   TK_WISH_PATH
196   TCL_INCLUDE_PATH
197   TK_INCLUDE_PATH
198   TCL_LIBRARY
199   TK_LIBRARY
200   )