FindTclsh: support version selection

This commit is contained in:
Rolf Eike Beer 2012-01-25 18:37:00 +01:00
parent 731f996ce0
commit e01fe583b8
2 changed files with 19 additions and 5 deletions

View File

@ -48,10 +48,14 @@ INCLUDE(CMakeFindFrameworks)
INCLUDE(FindTclsh) INCLUDE(FindTclsh)
INCLUDE(FindWish) INCLUDE(FindWish)
GET_FILENAME_COMPONENT(TCL_TCLSH_PATH "${TCL_TCLSH}" PATH) IF(TCLSH_VERSION_STRING)
GET_FILENAME_COMPONENT(TCL_TCLSH_PATH_PARENT "${TCL_TCLSH_PATH}" PATH) SET(TCL_TCLSH_VERSION "${TCLSH_VERSION_STRING}")
STRING(REGEX REPLACE ELSE(TCLSH_VERSION_STRING)
"^.*tclsh([0-9]\\.*[0-9]).*$" "\\1" TCL_TCLSH_VERSION "${TCL_TCLSH}") GET_FILENAME_COMPONENT(TCL_TCLSH_PATH "${TCL_TCLSH}" PATH)
GET_FILENAME_COMPONENT(TCL_TCLSH_PATH_PARENT "${TCL_TCLSH_PATH}" PATH)
STRING(REGEX REPLACE
"^.*tclsh([0-9]\\.*[0-9]).*$" "\\1" TCL_TCLSH_VERSION "${TCL_TCLSH}")
ENDIF(TCLSH_VERSION_STRING)
GET_FILENAME_COMPONENT(TK_WISH_PATH "${TK_WISH}" PATH) GET_FILENAME_COMPONENT(TK_WISH_PATH "${TK_WISH}" PATH)
GET_FILENAME_COMPONENT(TK_WISH_PATH_PARENT "${TK_WISH_PATH}" PATH) GET_FILENAME_COMPONENT(TK_WISH_PATH_PARENT "${TK_WISH_PATH}" PATH)

View File

@ -82,9 +82,19 @@ FIND_PROGRAM(TCL_TCLSH
HINTS ${TCLTK_POSSIBLE_BIN_PATHS} HINTS ${TCLTK_POSSIBLE_BIN_PATHS}
) )
IF(TCL_TCLSH)
EXECUTE_PROCESS(COMMAND "${CMAKE_COMMAND}" -E echo puts "\$tcl_version"
COMMAND "${TCL_TCLSH}"
OUTPUT_VARIABLE TCLSH_VERSION_STRING
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)
ENDIF(TCL_TCLSH)
# handle the QUIETLY and REQUIRED arguments and set TIFF_FOUND to TRUE if # handle the QUIETLY and REQUIRED arguments and set TIFF_FOUND to TRUE if
# all listed variables are TRUE # all listed variables are TRUE
INCLUDE(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) INCLUDE(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Tclsh DEFAULT_MSG TCL_TCLSH) FIND_PACKAGE_HANDLE_STANDARD_ARGS(Tclsh
REQUIRED_VARS TCL_TCLSH
VERSION_VAR TCLSH_VERSION_STRING)
MARK_AS_ADVANCED(TCL_TCLSH) MARK_AS_ADVANCED(TCL_TCLSH)