ENH: fix advanced bug
[cmake.git] / Modules / FindWish.cmake
blob86e9c67610e13ba804a32df15630b29180d5876c
1 # - Find wish installation
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:
6 #  TK_WISH = the path to the wish executable
8 # if UNIX is defined, then it will look for the cygwin version first
9 IF(UNIX)
10   FIND_PROGRAM(TK_WISH cygwish80 )
11 ENDIF(UNIX)
13 GET_FILENAME_COMPONENT(TCL_TCLSH_PATH "${TCL_TCLSH}" PATH)
14 GET_FILENAME_COMPONENT(TCL_TCLSH_PATH_PARENT "${TCL_TCLSH_PATH}" PATH)
15 STRING(REGEX REPLACE 
16   "^.*tclsh([0-9]\\.*[0-9]).*$" "\\1" TCL_TCLSH_VERSION "${TCL_TCLSH}")
18 GET_FILENAME_COMPONENT(TCL_INCLUDE_PATH_PARENT "${TCL_INCLUDE_PATH}" PATH)
19 GET_FILENAME_COMPONENT(TK_INCLUDE_PATH_PARENT "${TK_INCLUDE_PATH}" PATH)
21 GET_FILENAME_COMPONENT(TCL_LIBRARY_PATH "${TCL_LIBRARY}" PATH)
22 GET_FILENAME_COMPONENT(TCL_LIBRARY_PATH_PARENT "${TCL_LIBRARY_PATH}" PATH)
23 STRING(REGEX REPLACE 
24   "^.*tcl([0-9]\\.*[0-9]).*$" "\\1" TCL_LIBRARY_VERSION "${TCL_LIBRARY}")
26 GET_FILENAME_COMPONENT(TK_LIBRARY_PATH "${TK_LIBRARY}" PATH)
27 GET_FILENAME_COMPONENT(TK_LIBRARY_PATH_PARENT "${TK_LIBRARY_PATH}" PATH)
28 STRING(REGEX REPLACE 
29   "^.*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   )
39 IF(WIN32)
40   GET_FILENAME_COMPONENT(
41     ActiveTcl_CurrentVersion 
42     "[HKEY_LOCAL_MACHINE\\SOFTWARE\\ActiveState\\ActiveTcl;CurrentVersion]" 
43     NAME)
44   SET(TCLTK_POSSIBLE_BIN_PATHS ${TCLTK_POSSIBLE_BIN_PATHS}
45     "[HKEY_LOCAL_MACHINE\\SOFTWARE\\ActiveState\\ActiveTcl\\${ActiveTcl_CurrentVersion}]/bin"
46     "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.6;Root]/bin"
47     "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.5;Root]/bin"
48     "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.4;Root]/bin"
49     "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.3;Root]/bin"
50     "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.2;Root]/bin"
51     "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.0;Root]/bin"
52     )
53 ENDIF(WIN32)
55 SET(TK_WISH_NAMES
56   wish 
57   wish${TCL_LIBRARY_VERSION} wish${TK_LIBRARY_VERSION} wish${TCL_TCLSH_VERSION}
58   wish86 wish8.6
59   wish85 wish8.5 
60   wish84 wish8.4 
61   wish83 wish8.3 
62   wish82 wish8.2 
63   wish80 wish8.0
64   )
66 FIND_PROGRAM(TK_WISH
67   NAMES ${TK_WISH_NAMES}
68   PATHS ${TCLTK_POSSIBLE_BIN_PATHS} NO_DEFAULT_PATH
69   )
70 FIND_PROGRAM(TK_WISH
71   NAMES ${TK_WISH_NAMES}
72   PATHS ${TCLTK_POSSIBLE_BIN_PATHS}
73   )
75 MARK_AS_ADVANCED(TK_WISH)