ENH: fix bug where sharedforward would not work if there was a space in the path...
[cmake.git] / Modules / FindTclsh.cmake
blob129c11ac234ccb00f3bccbb85f3d552d6c3ce1d2
1 # - Find tclsh
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 #  TCLSH_FOUND = TRUE if tclsh has been found
6 #  TCL_TCLSH = the path to the tclsh executable
7 # In cygwin, look for the cygwin version first.  Don't look for it later to
8 # avoid finding the cygwin version on a Win32 build.
10 IF(WIN32 AND UNIX)
11   FIND_PROGRAM(TCL_TCLSH NAMES cygtclsh83 cygtclsh80)
12 ENDIF(WIN32 AND UNIX)
14 GET_FILENAME_COMPONENT(TK_WISH_PATH "${TK_WISH}" PATH)
15 GET_FILENAME_COMPONENT(TK_WISH_PATH_PARENT "${TK_WISH_PATH}" PATH)
16 STRING(REGEX REPLACE 
17   "^.*wish([0-9]\\.*[0-9]).*$" "\\1" TK_WISH_VERSION "${TK_WISH}")
19 GET_FILENAME_COMPONENT(TCL_INCLUDE_PATH_PARENT "${TCL_INCLUDE_PATH}" PATH)
20 GET_FILENAME_COMPONENT(TK_INCLUDE_PATH_PARENT "${TK_INCLUDE_PATH}" PATH)
22 GET_FILENAME_COMPONENT(TCL_LIBRARY_PATH "${TCL_LIBRARY}" PATH)
23 GET_FILENAME_COMPONENT(TCL_LIBRARY_PATH_PARENT "${TCL_LIBRARY_PATH}" PATH)
24 STRING(REGEX REPLACE 
25   "^.*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}")
32 SET(TCLTK_POSSIBLE_BIN_PATHS
33   "${TCL_INCLUDE_PATH_PARENT}/bin"
34   "${TK_INCLUDE_PATH_PARENT}/bin"
35   "${TCL_LIBRARY_PATH_PARENT}/bin"
36   "${TK_LIBRARY_PATH_PARENT}/bin"
37   "${TK_WISH_PATH_PARENT}/bin"
38   )
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(WIN32)
56 SET(TCL_TCLSH_NAMES
57   tclsh
58   tclsh${TCL_LIBRARY_VERSION} tclsh${TK_LIBRARY_VERSION} tclsh${TK_WISH_VERSION}
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   )
67 FIND_PROGRAM(TCL_TCLSH
68   NAMES ${TCL_TCLSH_NAMES}
69   HINTS ${TCLTK_POSSIBLE_BIN_PATHS}
70   )
72 # handle the QUIETLY and REQUIRED arguments and set TIFF_FOUND to TRUE if 
73 # all listed variables are TRUE
74 INCLUDE(FindPackageHandleStandardArgs)
75 FIND_PACKAGE_HANDLE_STANDARD_ARGS(Tclsh DEFAULT_MSG TCL_TCLSH)
77 MARK_AS_ADVANCED(TCL_TCLSH)