FindBASH.cmake
Go to the documentation of this file.
1 ##############################################################################
2 # @file FindBASH.cmake
3 # @brief Find BASH interpreter.
4 #
5 # Sets the CMake variables @c BASH_FOUND, @c BASH_EXECUTABLE,
6 # @c BASH_VERSION_STRING, @c BASH_VERSION_MAJOR, @c BASH_VERSION_MINOR, and
7 # @c BASH_VERSION_PATCH.
8 #
9 # @ingroup CMakeFindModules
10 ##############################################################################
11 
12 #=============================================================================
13 # Copyright 2011-2012 University of Pennsylvania
14 # Copyright 2013-2016 Andreas Schuh <andreas.schuh.84@gmail.com>
15 #
16 # Distributed under the OSI-approved BSD License (the "License");
17 # see accompanying file Copyright.txt for details.
18 #
19 # This software is distributed WITHOUT ANY WARRANTY; without even the
20 # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
21 # See the License for more information.
22 #=============================================================================
23 # (To distribute this file outside of CMake, substitute the full
24 # License text for the above reference.)
25 
26 # ----------------------------------------------------------------------------
27 # find BASH executable
28 find_program (BASH_EXECUTABLE bash)
29 mark_as_advanced (BASH_EXECUTABLE)
30 
31 # ----------------------------------------------------------------------------
32 # get version of found BASH executable
33 if (BASH_EXECUTABLE)
34  execute_process (COMMAND "${BASH_EXECUTABLE}" --version OUTPUT_VARIABLE _BASH_STDOUT ERROR_VARIABLE _BASH_STDERR)
35  if (_BASH_STDOUT MATCHES "version ([0-9]+)\\.([0-9]+)\\.([0-9]+)")
36  set (BASH_VERSION_MAJOR "${CMAKE_MATCH_1}")
37  set (BASH_VERSION_MINOR "${CMAKE_MATCH_2}")
38  set (BASH_VERSION_PATCH "${CMAKE_MATCH_3}")
39  set (BASH_VERSION_STRING "${BASH_VERSION_MAJOR}.${BASH_VERSION_MINOR}.${BASH_VERSION_PATCH}")
40  else ()
41  message (WARNING "Failed to determine version of Bash interpreter (${BASH_EXECUTABLE})! Error:\n${_BASH_STDERR}")
42  endif ()
43  unset (_BASH_STDOUT)
44  unset (_BASH_STDERR)
45 endif ()
46 
47 # ----------------------------------------------------------------------------
48 # handle the QUIETLY and REQUIRED arguments and set *_FOUND to TRUE
49 # if all listed variables are found or TRUE
50 include (FindPackageHandleStandardArgs)
51 
52 find_package_handle_standard_args (
53  BASH
54  REQUIRED_VARS
55  BASH_EXECUTABLE
56 )
cmake BASH_VERSION_MAJOR
Definition: FindBASH.cmake:12
cmake BASH_VERSION_STRING
Definition: FindBASH.cmake:39
cmake BASH_VERSION_PATCH
Definition: FindBASH.cmake:38
cmake BASH_VERSION_MINOR
Definition: FindBASH.cmake:37
cmake COMMAND