ENH: update for Tcl/Tk 8.5
[cmake.git] / Modules / FindTCL.cmake
blob2d3e23f69e89d7e7c4ffdac8bc148d3819fdba2b
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 GET_FILENAME_COMPONENT(
54   ActiveTcl_CurrentVersion 
55   "[HKEY_LOCAL_MACHINE\\SOFTWARE\\ActiveState\\ActiveTcl;CurrentVersion]" 
56   NAME)
58 SET (TCLTK_POSSIBLE_LIB_PATHS
59   "${TCL_INCLUDE_PATH_PARENT}/lib"
60   "${TK_INCLUDE_PATH_PARENT}/lib"
61   "${TCL_LIBRARY_PATH}"
62   "${TK_LIBRARY_PATH}"
63   "${TCL_TCLSH_PATH_PARENT}/lib"
64   "${TK_WISH_PATH_PARENT}/lib"
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   /usr/lib 
76   /usr/local/lib
79 FIND_LIBRARY(TCL_LIBRARY
80   NAMES tcl 
81   tcl86 tcl8.6 
82   tcl85 tcl8.5 
83   tcl84 tcl8.4 
84   tcl83 tcl8.3 
85   tcl82 tcl8.2 
86   tcl80 tcl8.0
87   PATHS ${TCLTK_POSSIBLE_LIB_PATHS}
90 FIND_LIBRARY(TK_LIBRARY 
91   NAMES tk 
92   tk86 tk8.6
93   tk85 tk8.5 
94   tk84 tk8.4 
95   tk83 tk8.3 
96   tk82 tk8.2 
97   tk80 tk8.0
98   PATHS ${TCLTK_POSSIBLE_LIB_PATHS}
101 CMAKE_FIND_FRAMEWORKS(Tcl)
102 CMAKE_FIND_FRAMEWORKS(Tk)
104 SET(TCL_FRAMEWORK_INCLUDES)
105 IF(Tcl_FRAMEWORKS)
106   IF(NOT TCL_INCLUDE_PATH)
107     FOREACH(dir ${Tcl_FRAMEWORKS})
108       SET(TCL_FRAMEWORK_INCLUDES ${TCL_FRAMEWORK_INCLUDES} ${dir}/Headers)
109     ENDFOREACH(dir)
110   ENDIF(NOT TCL_INCLUDE_PATH)
111 ENDIF(Tcl_FRAMEWORKS)
113 SET(TK_FRAMEWORK_INCLUDES)
114 IF(Tk_FRAMEWORKS)
115   IF(NOT TK_INCLUDE_PATH)
116     FOREACH(dir ${Tk_FRAMEWORKS})
117       SET(TK_FRAMEWORK_INCLUDES ${TK_FRAMEWORK_INCLUDES}
118         ${dir}/Headers ${dir}/PrivateHeaders)
119     ENDFOREACH(dir)
120   ENDIF(NOT TK_INCLUDE_PATH)
121 ENDIF(Tk_FRAMEWORKS)
123 SET (TCLTK_POSSIBLE_INCLUDE_PATHS
124   "${TCL_LIBRARY_PATH_PARENT}/include"
125   "${TK_LIBRARY_PATH_PARENT}/include"
126   "${TCL_INCLUDE_PATH}"
127   "${TK_INCLUDE_PATH}"
128   "${TCL_TCLSH_PATH_PARENT}/include"
129   "${TK_WISH_PATH_PARENT}/include"
130   "[HKEY_LOCAL_MACHINE\\SOFTWARE\\ActiveState\\ActiveTcl\\${ActiveTcl_CurrentVersion}]/include"
131   "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.6;Root]/include"
132   "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.5;Root]/include"
133   "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.4;Root]/include"
134   "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.3;Root]/include"
135   "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.2;Root]/include"
136   "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.0;Root]/include"
137   "$ENV{ProgramFiles}/Tcl/include"
138   "C:/Program Files/Tcl/include"
139   "C:/Tcl/include"
140   /usr/include
141   /usr/local/include
142   /usr/include/tcl8.6
143   /usr/include/tcl8.5
144   /usr/include/tcl8.4
145   /usr/include/tcl8.3
146   /usr/include/tcl8.2
147   /usr/include/tcl8.0
150 FIND_PATH(TCL_INCLUDE_PATH tcl.h
151   ${TCL_FRAMEWORK_INCLUDES} ${TCLTK_POSSIBLE_INCLUDE_PATHS}
154 FIND_PATH(TK_INCLUDE_PATH tk.h
155   ${TK_FRAMEWORK_INCLUDES} ${TCLTK_POSSIBLE_INCLUDE_PATHS}
158 # handle the QUIETLY and REQUIRED arguments and set TCL_FOUND to TRUE if 
159 # all listed variables are TRUE
160 INCLUDE(FindPackageHandleStandardArgs)
162 FIND_PACKAGE_HANDLE_STANDARD_ARGS(TCL DEFAULT_MSG TCL_LIBRARY TCL_INCLUDE_PATH)
163 SET(TCLTK_FIND_REQUIRED ${TCL_FIND_REQUIRED})
164 SET(TCLTK_FIND_QUIETLY  ${TCL_FIND_QUIETLY})
165 FIND_PACKAGE_HANDLE_STANDARD_ARGS(TCLTK DEFAULT_MSG TCL_LIBRARY TCL_INCLUDE_PATH TK_LIBRARY TK_INCLUDE_PATH)
166 SET(TK_FIND_REQUIRED ${TCL_FIND_REQUIRED})
167 SET(TK_FIND_QUIETLY  ${TCL_FIND_QUIETLY})
168 FIND_PACKAGE_HANDLE_STANDARD_ARGS(TK DEFAULT_MSG TK_LIBRARY TK_INCLUDE_PATH)
170 MARK_AS_ADVANCED(
171   TCL_TCLSH_PATH
172   TK_WISH_PATH
173   TCL_INCLUDE_PATH
174   TK_INCLUDE_PATH
175   TCL_LIBRARY
176   TK_LIBRARY
177   )