FindTclStub.cmake 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  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. FindTclStub
  5. -----------
  6. TCL_STUB_LIBRARY_DEBUG and TK_STUB_LIBRARY_DEBUG were removed.
  7. This module finds Tcl stub libraries. It first finds Tcl include
  8. files and libraries by calling FindTCL.cmake. How to Use the Tcl
  9. Stubs Library:
  10. ::
  11. http://tcl.activestate.com/doc/howto/stubs.html
  12. Using Stub Libraries:
  13. ::
  14. http://safari.oreilly.com/0130385603/ch48lev1sec3
  15. This code sets the following variables:
  16. ::
  17. TCL_STUB_LIBRARY = path to Tcl stub library
  18. TK_STUB_LIBRARY = path to Tk stub library
  19. TTK_STUB_LIBRARY = path to ttk stub library
  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. => these libs are not packaged by default with Tcl/Tk distributions.
  25. Even when Tcl/Tk is built from source, several flavors of debug libs
  26. are created and there is no real reason to pick a single one
  27. specifically (say, amongst tclstub84g, tclstub84gs, or tclstub84sgx).
  28. Let's leave that choice to the user by allowing him to assign
  29. TCL_STUB_LIBRARY to any Tcl library, debug or not.
  30. #]=======================================================================]
  31. include(${CMAKE_CURRENT_LIST_DIR}/FindTCL.cmake)
  32. get_filename_component(TCL_TCLSH_PATH "${TCL_TCLSH}" PATH)
  33. get_filename_component(TCL_TCLSH_PATH_PARENT "${TCL_TCLSH_PATH}" PATH)
  34. string(REGEX REPLACE
  35. "^.*tclsh([0-9]\\.*[0-9]).*$" "\\1" TCL_TCLSH_VERSION "${TCL_TCLSH}")
  36. get_filename_component(TK_WISH_PATH "${TK_WISH}" PATH)
  37. get_filename_component(TK_WISH_PATH_PARENT "${TK_WISH_PATH}" PATH)
  38. string(REGEX REPLACE
  39. "^.*wish([0-9]\\.*[0-9]).*$" "\\1" TK_WISH_VERSION "${TK_WISH}")
  40. get_filename_component(TCL_INCLUDE_PATH_PARENT "${TCL_INCLUDE_PATH}" PATH)
  41. get_filename_component(TK_INCLUDE_PATH_PARENT "${TK_INCLUDE_PATH}" PATH)
  42. get_filename_component(TCL_LIBRARY_PATH "${TCL_LIBRARY}" PATH)
  43. get_filename_component(TCL_LIBRARY_PATH_PARENT "${TCL_LIBRARY_PATH}" PATH)
  44. string(REGEX REPLACE
  45. "^.*tcl([0-9]\\.*[0-9]).*$" "\\1" TCL_LIBRARY_VERSION "${TCL_LIBRARY}")
  46. get_filename_component(TK_LIBRARY_PATH "${TK_LIBRARY}" PATH)
  47. get_filename_component(TK_LIBRARY_PATH_PARENT "${TK_LIBRARY_PATH}" PATH)
  48. string(REGEX REPLACE
  49. "^.*tk([0-9]\\.*[0-9]).*$" "\\1" TK_LIBRARY_VERSION "${TK_LIBRARY}")
  50. set(TCLTK_POSSIBLE_LIB_PATHS
  51. "${TCL_INCLUDE_PATH_PARENT}/lib"
  52. "${TK_INCLUDE_PATH_PARENT}/lib"
  53. "${TCL_LIBRARY_PATH}"
  54. "${TK_LIBRARY_PATH}"
  55. "${TCL_TCLSH_PATH_PARENT}/lib"
  56. "${TK_WISH_PATH_PARENT}/lib"
  57. )
  58. if(WIN32)
  59. get_filename_component(
  60. ActiveTcl_CurrentVersion
  61. "[HKEY_LOCAL_MACHINE\\SOFTWARE\\ActiveState\\ActiveTcl;CurrentVersion]"
  62. NAME)
  63. set(TCLTK_POSSIBLE_LIB_PATHS ${TCLTK_POSSIBLE_LIB_PATHS}
  64. "[HKEY_LOCAL_MACHINE\\SOFTWARE\\ActiveState\\ActiveTcl\\${ActiveTcl_CurrentVersion}]/lib"
  65. "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.6;Root]/lib"
  66. "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.5;Root]/lib"
  67. "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.4;Root]/lib"
  68. "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.3;Root]/lib"
  69. "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.2;Root]/lib"
  70. "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.0;Root]/lib"
  71. "$ENV{ProgramFiles}/Tcl/Lib"
  72. "C:/Program Files/Tcl/lib"
  73. "C:/Tcl/lib"
  74. )
  75. endif()
  76. find_library(TCL_STUB_LIBRARY
  77. NAMES
  78. tclstub
  79. tclstub${TK_LIBRARY_VERSION} tclstub${TCL_TCLSH_VERSION} tclstub${TK_WISH_VERSION}
  80. tclstub87 tclstub8.7
  81. tclstub86 tclstub8.6
  82. tclstub85 tclstub8.5
  83. tclstub84 tclstub8.4
  84. tclstub83 tclstub8.3
  85. tclstub82 tclstub8.2
  86. tclstub80 tclstub8.0
  87. PATHS ${TCLTK_POSSIBLE_LIB_PATHS}
  88. )
  89. find_library(TK_STUB_LIBRARY
  90. NAMES
  91. tkstub
  92. tkstub${TCL_LIBRARY_VERSION} tkstub${TCL_TCLSH_VERSION} tkstub${TK_WISH_VERSION}
  93. tkstub87 tkstub8.7
  94. tkstub86 tkstub8.6
  95. tkstub85 tkstub8.5
  96. tkstub84 tkstub8.4
  97. tkstub83 tkstub8.3
  98. tkstub82 tkstub8.2
  99. tkstub80 tkstub8.0
  100. PATHS ${TCLTK_POSSIBLE_LIB_PATHS}
  101. )
  102. find_library(TTK_STUB_LIBRARY
  103. NAMES
  104. ttkstub
  105. ttkstub${TCL_LIBRARY_VERSION} ttkstub${TCL_TCLSH_VERSION} ttkstub${TK_WISH_VERSION}
  106. ttkstub88 ttkstub8.8
  107. ttkstub87 ttkstub8.7
  108. ttkstub86 ttkstub8.6
  109. ttkstub85 ttkstub8.5
  110. PATHS ${TCLTK_POSSIBLE_LIB_PATHS}
  111. )
  112. mark_as_advanced(
  113. TCL_STUB_LIBRARY
  114. TK_STUB_LIBRARY
  115. )