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
34 #=============================================================================
35 # Copyright 2001-2009 Kitware, Inc.
37 # Distributed under the OSI-approved BSD License (the "License");
38 # see accompanying file Copyright.txt for details.
40 # This software is distributed WITHOUT ANY WARRANTY; without even the
41 # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
42 # See the License for more information.
43 #=============================================================================
44 # (To distribute this file outside of CMake, substitute the full
45 # License text for the above reference.)
47 include(CMakeFindFrameworks)
51 if(TCLSH_VERSION_STRING)
52 set(TCL_TCLSH_VERSION "${TCLSH_VERSION_STRING}")
54 get_filename_component(TCL_TCLSH_PATH "${TCL_TCLSH}" PATH)
55 get_filename_component(TCL_TCLSH_PATH_PARENT "${TCL_TCLSH_PATH}" PATH)
57 "^.*tclsh([0-9]\\.*[0-9]).*$" "\\1" TCL_TCLSH_VERSION "${TCL_TCLSH}")
60 get_filename_component(TK_WISH_PATH "${TK_WISH}" PATH)
61 get_filename_component(TK_WISH_PATH_PARENT "${TK_WISH_PATH}" PATH)
63 "^.*wish([0-9]\\.*[0-9]).*$" "\\1" TK_WISH_VERSION "${TK_WISH}")
65 get_filename_component(TCL_INCLUDE_PATH_PARENT "${TCL_INCLUDE_PATH}" PATH)
66 get_filename_component(TK_INCLUDE_PATH_PARENT "${TK_INCLUDE_PATH}" PATH)
68 get_filename_component(TCL_LIBRARY_PATH "${TCL_LIBRARY}" PATH)
69 get_filename_component(TCL_LIBRARY_PATH_PARENT "${TCL_LIBRARY_PATH}" PATH)
71 "^.*tcl([0-9]\\.*[0-9]).*$" "\\1" TCL_LIBRARY_VERSION "${TCL_LIBRARY}")
73 get_filename_component(TK_LIBRARY_PATH "${TK_LIBRARY}" PATH)
74 get_filename_component(TK_LIBRARY_PATH_PARENT "${TK_LIBRARY_PATH}" PATH)
76 "^.*tk([0-9]\\.*[0-9]).*$" "\\1" TK_LIBRARY_VERSION "${TK_LIBRARY}")
78 set(TCLTK_POSSIBLE_LIB_PATHS
79 "${TCL_INCLUDE_PATH_PARENT}/lib"
80 "${TK_INCLUDE_PATH_PARENT}/lib"
83 "${TCL_TCLSH_PATH_PARENT}/lib"
84 "${TK_WISH_PATH_PARENT}/lib"
88 get_filename_component(
89 ActiveTcl_CurrentVersion
90 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\ActiveState\\ActiveTcl;CurrentVersion]"
92 set(TCLTK_POSSIBLE_LIB_PATHS ${TCLTK_POSSIBLE_LIB_PATHS}
93 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\ActiveState\\ActiveTcl\\${ActiveTcl_CurrentVersion}]/lib"
94 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.6;Root]/lib"
95 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.5;Root]/lib"
96 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.4;Root]/lib"
97 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.3;Root]/lib"
98 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.2;Root]/lib"
99 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.0;Root]/lib"
100 "$ENV{ProgramFiles}/Tcl/Lib"
101 "C:/Program Files/Tcl/lib"
106 find_library(TCL_LIBRARY
109 tcl${TCL_LIBRARY_VERSION} tcl${TCL_TCLSH_VERSION} tcl${TK_WISH_VERSION}
116 PATHS ${TCLTK_POSSIBLE_LIB_PATHS}
119 find_library(TK_LIBRARY
122 tk${TK_LIBRARY_VERSION} tk${TCL_TCLSH_VERSION} tk${TK_WISH_VERSION}
129 PATHS ${TCLTK_POSSIBLE_LIB_PATHS}
132 CMAKE_FIND_FRAMEWORKS(Tcl)
133 CMAKE_FIND_FRAMEWORKS(Tk)
135 set(TCL_FRAMEWORK_INCLUDES)
137 if(NOT TCL_INCLUDE_PATH)
138 foreach(dir ${Tcl_FRAMEWORKS})
139 set(TCL_FRAMEWORK_INCLUDES ${TCL_FRAMEWORK_INCLUDES} ${dir}/Headers)
144 set(TK_FRAMEWORK_INCLUDES)
146 if(NOT TK_INCLUDE_PATH)
147 foreach(dir ${Tk_FRAMEWORKS})
148 set(TK_FRAMEWORK_INCLUDES ${TK_FRAMEWORK_INCLUDES}
149 ${dir}/Headers ${dir}/PrivateHeaders)
154 set(TCLTK_POSSIBLE_INCLUDE_PATHS
155 "${TCL_LIBRARY_PATH_PARENT}/include"
156 "${TK_LIBRARY_PATH_PARENT}/include"
157 "${TCL_INCLUDE_PATH}"
159 ${TCL_FRAMEWORK_INCLUDES}
160 ${TK_FRAMEWORK_INCLUDES}
161 "${TCL_TCLSH_PATH_PARENT}/include"
162 "${TK_WISH_PATH_PARENT}/include"
163 /usr/include/tcl${TK_LIBRARY_VERSION}
164 /usr/include/tcl${TCL_LIBRARY_VERSION}
174 set(TCLTK_POSSIBLE_INCLUDE_PATHS ${TCLTK_POSSIBLE_INCLUDE_PATHS}
175 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\ActiveState\\ActiveTcl\\${ActiveTcl_CurrentVersion}]/include"
176 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.6;Root]/include"
177 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.5;Root]/include"
178 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.4;Root]/include"
179 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.3;Root]/include"
180 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.2;Root]/include"
181 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.0;Root]/include"
182 "$ENV{ProgramFiles}/Tcl/include"
183 "C:/Program Files/Tcl/include"
188 find_path(TCL_INCLUDE_PATH
190 HINTS ${TCLTK_POSSIBLE_INCLUDE_PATHS}
193 find_path(TK_INCLUDE_PATH
195 HINTS ${TCLTK_POSSIBLE_INCLUDE_PATHS}
198 # handle the QUIETLY and REQUIRED arguments and set TCL_FOUND to TRUE if
199 # all listed variables are TRUE
200 include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
202 FIND_PACKAGE_HANDLE_STANDARD_ARGS(TCL DEFAULT_MSG TCL_LIBRARY TCL_INCLUDE_PATH)
203 set(TCLTK_FIND_REQUIRED ${TCL_FIND_REQUIRED})
204 set(TCLTK_FIND_QUIETLY ${TCL_FIND_QUIETLY})
205 FIND_PACKAGE_HANDLE_STANDARD_ARGS(TCLTK DEFAULT_MSG TCL_LIBRARY TCL_INCLUDE_PATH TK_LIBRARY TK_INCLUDE_PATH)
206 set(TK_FIND_REQUIRED ${TCL_FIND_REQUIRED})
207 set(TK_FIND_QUIETLY ${TCL_FIND_QUIETLY})
208 FIND_PACKAGE_HANDLE_STANDARD_ARGS(TK DEFAULT_MSG TK_LIBRARY TK_INCLUDE_PATH)