FindTclsh.cmake 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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. FindTclsh
  5. ---------
  6. Find tclsh
  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. TCLSH_FOUND = TRUE if tclsh has been found
  12. TCL_TCLSH = the path to the tclsh executable
  13. In cygwin, look for the cygwin version first. Don't look for it later
  14. to avoid finding the cygwin version on a Win32 build.
  15. #]=======================================================================]
  16. if(CYGWIN)
  17. find_program(TCL_TCLSH NAMES cygtclsh83 cygtclsh80)
  18. endif()
  19. get_filename_component(TK_WISH_PATH "${TK_WISH}" PATH)
  20. get_filename_component(TK_WISH_PATH_PARENT "${TK_WISH_PATH}" PATH)
  21. string(REGEX REPLACE
  22. "^.*wish([0-9]\\.*[0-9]).*$" "\\1" TK_WISH_VERSION "${TK_WISH}")
  23. get_filename_component(TCL_INCLUDE_PATH_PARENT "${TCL_INCLUDE_PATH}" PATH)
  24. get_filename_component(TK_INCLUDE_PATH_PARENT "${TK_INCLUDE_PATH}" PATH)
  25. get_filename_component(TCL_LIBRARY_PATH "${TCL_LIBRARY}" PATH)
  26. get_filename_component(TCL_LIBRARY_PATH_PARENT "${TCL_LIBRARY_PATH}" PATH)
  27. string(REGEX REPLACE
  28. "^.*tcl([0-9]\\.*[0-9]).*$" "\\1" TCL_LIBRARY_VERSION "${TCL_LIBRARY}")
  29. get_filename_component(TK_LIBRARY_PATH "${TK_LIBRARY}" PATH)
  30. get_filename_component(TK_LIBRARY_PATH_PARENT "${TK_LIBRARY_PATH}" PATH)
  31. string(REGEX REPLACE
  32. "^.*tk([0-9]\\.*[0-9]).*$" "\\1" TK_LIBRARY_VERSION "${TK_LIBRARY}")
  33. set(TCLTK_POSSIBLE_BIN_PATHS
  34. "${TCL_INCLUDE_PATH_PARENT}/bin"
  35. "${TK_INCLUDE_PATH_PARENT}/bin"
  36. "${TCL_LIBRARY_PATH_PARENT}/bin"
  37. "${TK_LIBRARY_PATH_PARENT}/bin"
  38. "${TK_WISH_PATH_PARENT}/bin"
  39. )
  40. if(WIN32)
  41. get_filename_component(
  42. ActiveTcl_CurrentVersion
  43. "[HKEY_LOCAL_MACHINE\\SOFTWARE\\ActiveState\\ActiveTcl;CurrentVersion]"
  44. NAME)
  45. set(TCLTK_POSSIBLE_BIN_PATHS ${TCLTK_POSSIBLE_BIN_PATHS}
  46. "[HKEY_LOCAL_MACHINE\\SOFTWARE\\ActiveState\\ActiveTcl\\${ActiveTcl_CurrentVersion}]/bin"
  47. "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.6;Root]/bin"
  48. "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.5;Root]/bin"
  49. "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.4;Root]/bin"
  50. "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.3;Root]/bin"
  51. "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.2;Root]/bin"
  52. "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.0;Root]/bin"
  53. )
  54. endif()
  55. set(TCL_TCLSH_NAMES
  56. tclsh
  57. tclsh${TCL_LIBRARY_VERSION} tclsh${TK_LIBRARY_VERSION} tclsh${TK_WISH_VERSION}
  58. tclsh87 tclsh8.7
  59. tclsh86 tclsh8.6
  60. tclsh85 tclsh8.5
  61. tclsh84 tclsh8.4
  62. tclsh83 tclsh8.3
  63. tclsh82 tclsh8.2
  64. tclsh80 tclsh8.0
  65. )
  66. find_program(TCL_TCLSH
  67. NAMES ${TCL_TCLSH_NAMES}
  68. HINTS ${TCLTK_POSSIBLE_BIN_PATHS}
  69. )
  70. if(TCL_TCLSH)
  71. execute_process(COMMAND "${CMAKE_COMMAND}" -E echo puts "\$tcl_version"
  72. COMMAND "${TCL_TCLSH}"
  73. OUTPUT_VARIABLE TCLSH_VERSION_STRING
  74. ERROR_QUIET
  75. OUTPUT_STRIP_TRAILING_WHITESPACE)
  76. endif()
  77. include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
  78. FIND_PACKAGE_HANDLE_STANDARD_ARGS(Tclsh
  79. REQUIRED_VARS TCL_TCLSH
  80. VERSION_VAR TCLSH_VERSION_STRING)
  81. mark_as_advanced(TCL_TCLSH)