FindWish.cmake 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. FindWish
  5. --------
  6. Find wish installation
  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. TK_WISH = the path to the wish executable
  12. if UNIX is defined, then it will look for the cygwin version first
  13. #]=======================================================================]
  14. if(UNIX)
  15. find_program(TK_WISH cygwish80 )
  16. endif()
  17. get_filename_component(TCL_TCLSH_PATH "${TCL_TCLSH}" PATH)
  18. get_filename_component(TCL_TCLSH_PATH_PARENT "${TCL_TCLSH_PATH}" PATH)
  19. string(REGEX REPLACE
  20. "^.*tclsh([0-9]\\.*[0-9]).*$" "\\1" TCL_TCLSH_VERSION "${TCL_TCLSH}")
  21. get_filename_component(TCL_INCLUDE_PATH_PARENT "${TCL_INCLUDE_PATH}" PATH)
  22. get_filename_component(TK_INCLUDE_PATH_PARENT "${TK_INCLUDE_PATH}" PATH)
  23. get_filename_component(TCL_LIBRARY_PATH "${TCL_LIBRARY}" PATH)
  24. get_filename_component(TCL_LIBRARY_PATH_PARENT "${TCL_LIBRARY_PATH}" PATH)
  25. string(REGEX REPLACE
  26. "^.*tcl([0-9]\\.*[0-9]).*$" "\\1" TCL_LIBRARY_VERSION "${TCL_LIBRARY}")
  27. get_filename_component(TK_LIBRARY_PATH "${TK_LIBRARY}" PATH)
  28. get_filename_component(TK_LIBRARY_PATH_PARENT "${TK_LIBRARY_PATH}" PATH)
  29. string(REGEX REPLACE
  30. "^.*tk([0-9]\\.*[0-9]).*$" "\\1" TK_LIBRARY_VERSION "${TK_LIBRARY}")
  31. set(TCLTK_POSSIBLE_BIN_PATHS
  32. "${TCL_INCLUDE_PATH_PARENT}/bin"
  33. "${TK_INCLUDE_PATH_PARENT}/bin"
  34. "${TCL_LIBRARY_PATH_PARENT}/bin"
  35. "${TK_LIBRARY_PATH_PARENT}/bin"
  36. "${TCL_TCLSH_PATH_PARENT}/bin"
  37. )
  38. if(WIN32)
  39. get_filename_component(
  40. ActiveTcl_CurrentVersion
  41. "[HKEY_LOCAL_MACHINE\\SOFTWARE\\ActiveState\\ActiveTcl;CurrentVersion]"
  42. NAME)
  43. set(TCLTK_POSSIBLE_BIN_PATHS ${TCLTK_POSSIBLE_BIN_PATHS}
  44. "[HKEY_LOCAL_MACHINE\\SOFTWARE\\ActiveState\\ActiveTcl\\${ActiveTcl_CurrentVersion}]/bin"
  45. "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.6;Root]/bin"
  46. "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.5;Root]/bin"
  47. "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.4;Root]/bin"
  48. "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.3;Root]/bin"
  49. "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.2;Root]/bin"
  50. "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.0;Root]/bin"
  51. )
  52. endif()
  53. set(TK_WISH_NAMES
  54. wish
  55. wish${TCL_LIBRARY_VERSION} wish${TK_LIBRARY_VERSION} wish${TCL_TCLSH_VERSION}
  56. wish86 wish8.6
  57. wish85 wish8.5
  58. wish84 wish8.4
  59. wish83 wish8.3
  60. wish82 wish8.2
  61. wish80 wish8.0
  62. )
  63. find_program(TK_WISH
  64. NAMES ${TK_WISH_NAMES}
  65. HINTS ${TCLTK_POSSIBLE_BIN_PATHS}
  66. )
  67. mark_as_advanced(TK_WISH)