FindTCL.cmake 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. # Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. # file Copyright.txt or https://cmake.org/licensing for details.
  3. #[=======================================================================[.rst:
  4. FindTCL
  5. -------
  6. TK_INTERNAL_PATH was removed.
  7. This module finds if Tcl is installed and determines where the include
  8. files and libraries are. It also determines what the name of the
  9. library is. This code sets the following variables:
  10. ::
  11. TCL_FOUND = Tcl was found
  12. TK_FOUND = Tk was found
  13. TCLTK_FOUND = Tcl and Tk were found
  14. TCL_LIBRARY = path to Tcl library (tcl tcl80)
  15. TCL_INCLUDE_PATH = path to where tcl.h can be found
  16. TCL_TCLSH = path to tclsh binary (tcl tcl80)
  17. TK_LIBRARY = path to Tk library (tk tk80 etc)
  18. TK_INCLUDE_PATH = path to where tk.h can be found
  19. TK_WISH = full path to the wish executable
  20. In an effort to remove some clutter and clear up some issues for
  21. people who are not necessarily Tcl/Tk gurus/developers, some
  22. variables were moved or removed. Changes compared to CMake 2.4 are:
  23. ::
  24. => they were only useful for people writing Tcl/Tk extensions.
  25. => these libs are not packaged by default with Tcl/Tk distributions.
  26. Even when Tcl/Tk is built from source, several flavors of debug libs
  27. are created and there is no real reason to pick a single one
  28. specifically (say, amongst tcl84g, tcl84gs, or tcl84sgx).
  29. Let's leave that choice to the user by allowing him to assign
  30. TCL_LIBRARY to any Tcl library, debug or not.
  31. => this ended up being only a Win32 variable, and there is a lot of
  32. confusion regarding the location of this file in an installed Tcl/Tk
  33. tree anyway (see 8.5 for example). If you need the internal path at
  34. this point it is safer you ask directly where the *source* tree is
  35. and dig from there.
  36. #]=======================================================================]
  37. include(${CMAKE_CURRENT_LIST_DIR}/CMakeFindFrameworks.cmake)
  38. include(${CMAKE_CURRENT_LIST_DIR}/FindTclsh.cmake)
  39. include(${CMAKE_CURRENT_LIST_DIR}/FindWish.cmake)
  40. if(TCLSH_VERSION_STRING)
  41. set(TCL_TCLSH_VERSION "${TCLSH_VERSION_STRING}")
  42. else()
  43. get_filename_component(TCL_TCLSH_PATH "${TCL_TCLSH}" PATH)
  44. get_filename_component(TCL_TCLSH_PATH_PARENT "${TCL_TCLSH_PATH}" PATH)
  45. string(REGEX REPLACE
  46. "^.*tclsh([0-9]\\.*[0-9]).*$" "\\1" TCL_TCLSH_VERSION "${TCL_TCLSH}")
  47. endif()
  48. get_filename_component(TK_WISH_PATH "${TK_WISH}" PATH)
  49. get_filename_component(TK_WISH_PATH_PARENT "${TK_WISH_PATH}" PATH)
  50. string(REGEX REPLACE
  51. "^.*wish([0-9]\\.*[0-9]).*$" "\\1" TK_WISH_VERSION "${TK_WISH}")
  52. get_filename_component(TCL_INCLUDE_PATH_PARENT "${TCL_INCLUDE_PATH}" PATH)
  53. get_filename_component(TK_INCLUDE_PATH_PARENT "${TK_INCLUDE_PATH}" PATH)
  54. get_filename_component(TCL_LIBRARY_PATH "${TCL_LIBRARY}" PATH)
  55. get_filename_component(TCL_LIBRARY_PATH_PARENT "${TCL_LIBRARY_PATH}" PATH)
  56. string(REGEX REPLACE
  57. "^.*tcl([0-9]\\.*[0-9]).*$" "\\1" TCL_LIBRARY_VERSION "${TCL_LIBRARY}")
  58. get_filename_component(TK_LIBRARY_PATH "${TK_LIBRARY}" PATH)
  59. get_filename_component(TK_LIBRARY_PATH_PARENT "${TK_LIBRARY_PATH}" PATH)
  60. string(REGEX REPLACE
  61. "^.*tk([0-9]\\.*[0-9]).*$" "\\1" TK_LIBRARY_VERSION "${TK_LIBRARY}")
  62. set(TCLTK_POSSIBLE_LIB_PATHS
  63. "${TCL_INCLUDE_PATH_PARENT}/lib"
  64. "${TK_INCLUDE_PATH_PARENT}/lib"
  65. "${TCL_LIBRARY_PATH}"
  66. "${TK_LIBRARY_PATH}"
  67. "${TCL_TCLSH_PATH_PARENT}/lib"
  68. "${TK_WISH_PATH_PARENT}/lib"
  69. )
  70. set(TCLTK_POSSIBLE_LIB_PATH_SUFFIXES
  71. lib/tcl/tcl8.7
  72. lib/tcl/tk8.7
  73. lib/tcl/tcl8.6
  74. lib/tcl/tk8.6
  75. lib/tcl/tcl8.5
  76. lib/tcl/tk8.5
  77. lib/tcl/tcl8.4
  78. lib/tcl/tk8.4
  79. )
  80. if(WIN32)
  81. get_filename_component(
  82. ActiveTcl_CurrentVersion
  83. "[HKEY_LOCAL_MACHINE\\SOFTWARE\\ActiveState\\ActiveTcl;CurrentVersion]"
  84. NAME)
  85. set(TCLTK_POSSIBLE_LIB_PATHS ${TCLTK_POSSIBLE_LIB_PATHS}
  86. "[HKEY_LOCAL_MACHINE\\SOFTWARE\\ActiveState\\ActiveTcl\\${ActiveTcl_CurrentVersion}]/lib"
  87. "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.6;Root]/lib"
  88. "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.5;Root]/lib"
  89. "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.4;Root]/lib"
  90. "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.3;Root]/lib"
  91. "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.2;Root]/lib"
  92. "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.0;Root]/lib"
  93. "$ENV{ProgramFiles}/Tcl/Lib"
  94. "C:/Program Files/Tcl/lib"
  95. "C:/Tcl/lib"
  96. )
  97. endif()
  98. find_library(TCL_LIBRARY
  99. NAMES
  100. tcl
  101. tcl${TCL_LIBRARY_VERSION} tcl${TCL_TCLSH_VERSION} tcl${TK_WISH_VERSION}
  102. tcl87 tcl8.7 tcl87t tcl8.7t
  103. tcl86 tcl8.6 tcl86t tcl8.6t
  104. tcl85 tcl8.5
  105. tcl84 tcl8.4
  106. tcl83 tcl8.3
  107. tcl82 tcl8.2
  108. tcl80 tcl8.0
  109. PATHS ${TCLTK_POSSIBLE_LIB_PATHS}
  110. PATH_SUFFIXES ${TCLTK_POSSIBLE_LIB_PATH_SUFFIXES}
  111. )
  112. find_library(TK_LIBRARY
  113. NAMES
  114. tk
  115. tk${TK_LIBRARY_VERSION} tk${TCL_TCLSH_VERSION} tk${TK_WISH_VERSION}
  116. tk87 tk8.7 tk87t tk8.7t
  117. tk86 tk8.6 tk86t tk8.6t
  118. tk85 tk8.5
  119. tk84 tk8.4
  120. tk83 tk8.3
  121. tk82 tk8.2
  122. tk80 tk8.0
  123. PATHS ${TCLTK_POSSIBLE_LIB_PATHS}
  124. PATH_SUFFIXES ${TCLTK_POSSIBLE_LIB_PATH_SUFFIXES}
  125. )
  126. CMAKE_FIND_FRAMEWORKS(Tcl)
  127. CMAKE_FIND_FRAMEWORKS(Tk)
  128. set(TCL_FRAMEWORK_INCLUDES)
  129. if(Tcl_FRAMEWORKS)
  130. if(NOT TCL_INCLUDE_PATH)
  131. foreach(dir ${Tcl_FRAMEWORKS})
  132. set(TCL_FRAMEWORK_INCLUDES ${TCL_FRAMEWORK_INCLUDES} ${dir}/Headers)
  133. endforeach()
  134. endif()
  135. endif()
  136. set(TK_FRAMEWORK_INCLUDES)
  137. if(Tk_FRAMEWORKS)
  138. if(NOT TK_INCLUDE_PATH)
  139. foreach(dir ${Tk_FRAMEWORKS})
  140. set(TK_FRAMEWORK_INCLUDES ${TK_FRAMEWORK_INCLUDES}
  141. ${dir}/Headers ${dir}/PrivateHeaders)
  142. endforeach()
  143. endif()
  144. endif()
  145. set(TCLTK_POSSIBLE_INCLUDE_PATHS
  146. "${TCL_LIBRARY_PATH_PARENT}/include"
  147. "${TK_LIBRARY_PATH_PARENT}/include"
  148. "${TCL_INCLUDE_PATH}"
  149. "${TK_INCLUDE_PATH}"
  150. ${TCL_FRAMEWORK_INCLUDES}
  151. ${TK_FRAMEWORK_INCLUDES}
  152. "${TCL_TCLSH_PATH_PARENT}/include"
  153. "${TK_WISH_PATH_PARENT}/include"
  154. )
  155. set(TCLTK_POSSIBLE_INCLUDE_PATH_SUFFIXES
  156. include/tcl${TK_LIBRARY_VERSION}
  157. include/tcl${TCL_LIBRARY_VERSION}
  158. include/tcl8.7
  159. include/tk8.7
  160. include/tcl8.6
  161. include/tk8.6
  162. include/tcl8.5
  163. include/tk8.5
  164. include/tcl8.4
  165. include/tk8.4
  166. include/tcl8.3
  167. include/tcl8.2
  168. include/tcl8.0
  169. )
  170. if(WIN32)
  171. set(TCLTK_POSSIBLE_INCLUDE_PATHS ${TCLTK_POSSIBLE_INCLUDE_PATHS}
  172. "[HKEY_LOCAL_MACHINE\\SOFTWARE\\ActiveState\\ActiveTcl\\${ActiveTcl_CurrentVersion}]/include"
  173. "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.6;Root]/include"
  174. "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.5;Root]/include"
  175. "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.4;Root]/include"
  176. "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.3;Root]/include"
  177. "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.2;Root]/include"
  178. "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.0;Root]/include"
  179. "$ENV{ProgramFiles}/Tcl/include"
  180. "C:/Program Files/Tcl/include"
  181. "C:/Tcl/include"
  182. )
  183. endif()
  184. find_path(TCL_INCLUDE_PATH
  185. NAMES tcl.h
  186. HINTS ${TCLTK_POSSIBLE_INCLUDE_PATHS}
  187. PATH_SUFFIXES ${TCLTK_POSSIBLE_INCLUDE_PATH_SUFFIXES}
  188. )
  189. find_path(TK_INCLUDE_PATH
  190. NAMES tk.h
  191. HINTS ${TCLTK_POSSIBLE_INCLUDE_PATHS}
  192. PATH_SUFFIXES ${TCLTK_POSSIBLE_INCLUDE_PATH_SUFFIXES}
  193. )
  194. include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
  195. FIND_PACKAGE_HANDLE_STANDARD_ARGS(TCL DEFAULT_MSG TCL_LIBRARY TCL_INCLUDE_PATH)
  196. set(TCLTK_FIND_REQUIRED ${TCL_FIND_REQUIRED})
  197. set(TCLTK_FIND_QUIETLY ${TCL_FIND_QUIETLY})
  198. FIND_PACKAGE_HANDLE_STANDARD_ARGS(TCLTK DEFAULT_MSG TCL_LIBRARY TCL_INCLUDE_PATH TK_LIBRARY TK_INCLUDE_PATH)
  199. set(TK_FIND_REQUIRED ${TCL_FIND_REQUIRED})
  200. set(TK_FIND_QUIETLY ${TCL_FIND_QUIETLY})
  201. FIND_PACKAGE_HANDLE_STANDARD_ARGS(TK DEFAULT_MSG TK_LIBRARY TK_INCLUDE_PATH)
  202. mark_as_advanced(
  203. TCL_INCLUDE_PATH
  204. TK_INCLUDE_PATH
  205. TCL_LIBRARY
  206. TK_LIBRARY
  207. )