diff --git a/Help/release/dev/find-modules.rst b/Help/release/dev/find-modules.rst index b6a2c35421..a970598835 100644 --- a/Help/release/dev/find-modules.rst +++ b/Help/release/dev/find-modules.rst @@ -99,6 +99,9 @@ Find Modules result variable. The ``Subversion_VERSION_SVN`` result variable is deprecated. +* The :module:`FindTclsh` module now provides a ``Tclsh_VERSION`` result + variable. The ``TCLSH_VERSION_STRING`` result variable is deprecated. + * The :module:`FindTIFF` module now provides a ``TIFF_VERSION`` result variable. The ``TIFF_VERSION_STRING`` result variable is deprecated. diff --git a/Modules/FindTCL.cmake b/Modules/FindTCL.cmake index d0208d3d58..7765c9e1a6 100644 --- a/Modules/FindTCL.cmake +++ b/Modules/FindTCL.cmake @@ -79,8 +79,8 @@ endblock() include(${CMAKE_CURRENT_LIST_DIR}/FindTclsh.cmake) include(${CMAKE_CURRENT_LIST_DIR}/FindWish.cmake) -if(TCLSH_VERSION_STRING) - set(TCL_TCLSH_VERSION "${TCLSH_VERSION_STRING}") +if(Tclsh_VERSION) + set(TCL_TCLSH_VERSION "${Tclsh_VERSION}") else() get_filename_component(TCL_TCLSH_PATH "${TCL_TCLSH}" PATH) get_filename_component(TCL_TCLSH_PATH_PARENT "${TCL_TCLSH_PATH}" PATH) diff --git a/Modules/FindTclsh.cmake b/Modules/FindTclsh.cmake index 976547630e..334616dfb8 100644 --- a/Modules/FindTclsh.cmake +++ b/Modules/FindTclsh.cmake @@ -10,7 +10,7 @@ Finds the Tcl shell command-line executable (``tclsh``), which includes the Tcl .. code-block:: cmake - find_package(Tclsh [...]) + find_package(Tclsh [] [...]) Result Variables ^^^^^^^^^^^^^^^^ @@ -18,9 +18,14 @@ Result Variables This module defines the following variables: ``Tclsh_FOUND`` - Boolean indicating whether the ``tclsh`` executable (and the requested - version, if specified) is found. For backward compatibility, the - ``TCLSH_FOUND`` variable is also set to the same value. + Boolean indicating whether the (requested version of) ``tclsh`` executable + is found. For backward compatibility, the ``TCLSH_FOUND`` variable is + also set to the same value. + +``Tclsh_VERSION`` + .. versionadded:: 4.2 + + The version of ``tclsh`` found. Cache Variables ^^^^^^^^^^^^^^^ @@ -30,14 +35,30 @@ The following cache variables may also be set: ``TCL_TCLSH`` The path to the ``tclsh`` executable. +Deprecated Variables +^^^^^^^^^^^^^^^^^^^^ + +The following variables are provided for backward compatibility: + +``TCLSH_VERSION_STRING`` + .. deprecated:: 4.2 + Use ``Tclsh_VERSION``, which has the same value. + + The version of ``tclsh`` found. + Examples ^^^^^^^^ -Finding the ``tclsh`` command-line executable: +In the following example, this module is used to find the ``tclsh`` +command-line executable, which is then executed in a process to evaluate +TCL code from the script file located in the project source directory: .. code-block:: cmake find_package(Tclsh) + if(Tclsh_FOUND) + execute_process(COMMAND ${TCL_TCLSH} example-script.tcl) + endif() See Also ^^^^^^^^ @@ -108,9 +129,10 @@ find_program(TCL_TCLSH if(TCL_TCLSH) execute_process(COMMAND "${CMAKE_COMMAND}" -E echo puts "\$tcl_version" COMMAND "${TCL_TCLSH}" - OUTPUT_VARIABLE TCLSH_VERSION_STRING + OUTPUT_VARIABLE Tclsh_VERSION ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) + set(TCLSH_VERSION_STRING "${Tclsh_VERSION}") endif() include(FindPackageHandleStandardArgs) @@ -124,7 +146,7 @@ if (CMAKE_FIND_PACKAGE_NAME STREQUAL "TCL" OR endif () find_package_handle_standard_args(Tclsh REQUIRED_VARS TCL_TCLSH - VERSION_VAR TCLSH_VERSION_STRING) + VERSION_VAR Tclsh_VERSION) unset(FPHSA_NAME_MISMATCHED) mark_as_advanced(TCL_TCLSH) diff --git a/Tests/CMakeOnly/AllFindModules/CMakeLists.txt b/Tests/CMakeOnly/AllFindModules/CMakeLists.txt index 7e13003a68..32e2a01892 100644 --- a/Tests/CMakeOnly/AllFindModules/CMakeLists.txt +++ b/Tests/CMakeOnly/AllFindModules/CMakeLists.txt @@ -104,7 +104,7 @@ foreach( LIBLZMA LIBXML2 LIBXSLT LTTNGUST PERL PKG_CONFIG PNG PostgreSQL SDL - TIFF + TCLSH TIFF wxWidgets ZLIB ) @@ -127,7 +127,7 @@ foreach( Perl PerlLibs PkgConfig PNG PostgreSQL Protobuf Ruby RUBY SDL SWIG - TIFF + Tclsh TIFF wxWidgets ZLIB )