FindTCL.cmake 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. #
  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. #
  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)
  19. #
  20. INCLUDE(CMakeFindFrameworks)
  21. INCLUDE(FindTclsh)
  22. INCLUDE(FindWish)
  23. GET_FILENAME_COMPONENT(TCL_TCLSH_PATH "${TCL_TCLSH}" PATH)
  24. GET_FILENAME_COMPONENT(TK_WISH_PATH "${TK_WISH}" PATH)
  25. SET (TCLTK_POSSIBLE_LIB_PATHS
  26. "${TCL_TCLSH_PATH}/../lib"
  27. "${TK_WISH_PATH}/../lib"
  28. "${TCL_INCLUDE_PATH}/../lib"
  29. "${TK_INCLUDE_PATH}/../lib"
  30. "C:/Program Files/Tcl/lib"
  31. "C:/Tcl/lib"
  32. [HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.4;Root]/lib
  33. [HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.3;Root]/lib
  34. [HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.2;Root]/lib
  35. [HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.0;Root]/lib
  36. /usr/lib
  37. /usr/local/lib
  38. )
  39. FIND_LIBRARY(TCL_LIBRARY
  40. NAMES tcl tcl84 tcl8.4 tcl83 tcl8.3 tcl82 tcl8.2 tcl80 tcl8.0
  41. PATHS ${TCLTK_POSSIBLE_LIB_PATHS}
  42. )
  43. FIND_LIBRARY(TCL_LIBRARY_DEBUG
  44. NAMES tcld tcl84d tcl8.4d tcl83d tcl8.3d tcl82d tcl8.2d tcl80d tcl8.0d
  45. PATHS ${TCLTK_POSSIBLE_LIB_PATHS}
  46. )
  47. FIND_LIBRARY(TCL_STUB_LIBRARY
  48. NAMES tclstub tclstub84 tclstub8.4 tclstub83 tclstub8.3 tclstub82 tclstub8.2 tclstub80 tclstub8.0
  49. PATHS ${TCLTK_POSSIBLE_LIB_PATHS}
  50. )
  51. FIND_LIBRARY(TCL_STUB_LIBRARY_DEBUG
  52. NAMES tclstubd tclstub84d tclstub8.4d tclstub83d tclstub8.3d tclstub82d tclstub8.2d tclstub80d tclstub8.0d
  53. PATHS ${TCLTK_POSSIBLE_LIB_PATHS}
  54. )
  55. FIND_LIBRARY(TK_LIBRARY
  56. NAMES tk tk84 tk8.4 tk83 tk8.3 tk82 tk8.2 tk80 tk8.0
  57. PATHS ${TCLTK_POSSIBLE_LIB_PATHS}
  58. )
  59. FIND_LIBRARY(TK_LIBRARY_DEBUG
  60. NAMES tkd tk84d tk8.4d tk83d tk8.3d tk82d tk8.2d tk80d tk8.0d
  61. PATHS ${TCLTK_POSSIBLE_LIB_PATHS}
  62. )
  63. FIND_LIBRARY(TK_STUB_LIBRARY
  64. NAMES tkstub tkstub84 tkstub8.4 tkstub83 tkstub8.3 tkstub82 tkstub8.2 tkstub80 tkstub8.0
  65. PATHS ${TCLTK_POSSIBLE_LIB_PATHS}
  66. )
  67. FIND_LIBRARY(TK_STUB_LIBRARY_DEBUG
  68. NAMES tkstubd tkstub84d tkstub8.4d tkstub83d tkstub8.3d tkstub82d tkstub8.2d tkstub80d tkstub8.0d
  69. PATHS ${TCLTK_POSSIBLE_LIB_PATHS}
  70. )
  71. CMAKE_FIND_FRAMEWORKS(Tcl)
  72. CMAKE_FIND_FRAMEWORKS(Tk)
  73. SET(TCL_FRAMEWORK_INCLUDES)
  74. IF(Tcl_FRAMEWORKS)
  75. IF(NOT TCL_INCLUDE_PATH)
  76. FOREACH(dir ${Tcl_FRAMEWORKS})
  77. SET(TCL_FRAMEWORK_INCLUDES ${TCL_FRAMEWORK_INCLUDES} ${dir}/Headers)
  78. ENDFOREACH(dir)
  79. ENDIF(NOT TCL_INCLUDE_PATH)
  80. ENDIF(Tcl_FRAMEWORKS)
  81. SET(TK_FRAMEWORK_INCLUDES)
  82. IF(Tk_FRAMEWORKS)
  83. IF(NOT TK_INCLUDE_PATH)
  84. FOREACH(dir ${Tk_FRAMEWORKS})
  85. SET(TK_FRAMEWORK_INCLUDES ${TK_FRAMEWORK_INCLUDES}
  86. ${dir}/Headers ${dir}/PrivateHeaders)
  87. ENDFOREACH(dir)
  88. ENDIF(NOT TK_INCLUDE_PATH)
  89. ENDIF(Tk_FRAMEWORKS)
  90. GET_FILENAME_COMPONENT(TCL_LIBRARY_PATH "${TCL_LIBRARY}" PATH)
  91. GET_FILENAME_COMPONENT(TK_LIBRARY_PATH "${TK_LIBRARY}" PATH)
  92. SET (TCLTK_POSSIBLE_INCLUDE_PATHS
  93. ${TCL_TCLSH_PATH}/../include
  94. ${TK_WISH_PATH}/../include
  95. "${TCL_LIBRARY_PATH}/../include"
  96. "${TK_LIBRARY_PATH}/../include"
  97. [HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.4;Root]/include
  98. [HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.3;Root]/include
  99. [HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.2;Root]/include
  100. [HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.0;Root]/include
  101. "C:/Program Files/Tcl/include"
  102. C:/Tcl/include
  103. /usr/include
  104. /usr/local/include
  105. /usr/include/tcl8.4
  106. /usr/include/tcl8.3
  107. /usr/include/tcl8.2
  108. /usr/include/tcl8.0
  109. )
  110. FIND_PATH(TCL_INCLUDE_PATH tcl.h
  111. ${TCL_FRAMEWORK_INCLUDES} ${TCLTK_POSSIBLE_INCLUDE_PATHS}
  112. )
  113. FIND_PATH(TK_INCLUDE_PATH tk.h
  114. ${TK_FRAMEWORK_INCLUDES} ${TCLTK_POSSIBLE_INCLUDE_PATHS}
  115. )
  116. IF (WIN32)
  117. FIND_PATH(TK_INTERNAL_PATH tkWinInt.h
  118. ${TCLTK_POSSIBLE_INCLUDE_PATHS}
  119. )
  120. MARK_AS_ADVANCED(TK_INTERNAL_PATH)
  121. MARK_AS_ADVANCED(
  122. TCL_TCLSH_PATH
  123. TK_WISH_PATH
  124. TCL_INCLUDE_PATH
  125. TK_INCLUDE_PATH
  126. TCL_LIBRARY
  127. TCL_LIBRARY_DEBUG
  128. TK_LIBRARY
  129. TK_LIBRARY_DEBUG
  130. )
  131. ENDIF(WIN32)
  132. IF(Tcl_FRAMEWORKS)
  133. # If we are using the Tcl framework, link to it.
  134. IF("${TCL_INCLUDE_PATH}" MATCHES "Tcl\\.framework")
  135. SET(TCL_LIBRARY "")
  136. ENDIF("${TCL_INCLUDE_PATH}" MATCHES "Tcl\\.framework")
  137. IF(NOT TCL_LIBRARY)
  138. SET (TCL_LIBRARY "-framework Tcl" CACHE FILEPATH "Tcl Framework" FORCE)
  139. ENDIF(NOT TCL_LIBRARY)
  140. ENDIF(Tcl_FRAMEWORKS)
  141. IF(Tk_FRAMEWORKS)
  142. # If we are using the Tk framework, link to it.
  143. IF("${TK_INCLUDE_PATH}" MATCHES "Tk\\.framework")
  144. SET(TK_LIBRARY "")
  145. ENDIF("${TK_INCLUDE_PATH}" MATCHES "Tk\\.framework")
  146. IF(NOT TK_LIBRARY)
  147. SET (TK_LIBRARY "-framework Tk" CACHE FILEPATH "Tk Framework" FORCE)
  148. ENDIF(NOT TK_LIBRARY)
  149. ENDIF(Tk_FRAMEWORKS)
  150. MARK_AS_ADVANCED(
  151. TCL_STUB_LIBRARY
  152. TCL_STUB_LIBRARY_DEBUG
  153. TK_STUB_LIBRARY
  154. TK_STUB_LIBRARY_DEBUG
  155. )
  156. IF(TCL_INCLUDE_PATH)
  157. IF(TK_INCLUDE_PATH)
  158. IF(TCL_LIBRARY)
  159. IF(TK_LIBRARY)
  160. SET(TCL_FOUND 1)
  161. ENDIF(TK_LIBRARY)
  162. ENDIF(TCL_LIBRARY)
  163. ENDIF(TK_INCLUDE_PATH)
  164. ENDIF(TCL_INCLUDE_PATH)