BASIS  r3148
FindBASH.cmake
Go to the documentation of this file.
00001 ##############################################################################
00002 # @file  FindBASH.cmake
00003 # @brief Find BASH interpreter.
00004 #
00005 # Sets the CMake variables @c BASH_FOUND, @c BASH_EXECUTABLE,
00006 # @c BASH_VERSION_STRING, @c BASH_VERSION_MAJOR, @c BASH_VERSION_MINOR, and
00007 # @c BASH_VERSION_PATCH.
00008 #
00009 # Copyright (c) 2012 University of Pennsylvania. All rights reserved.<br />
00010 # See https://www.cbica.upenn.edu/sbia/software/license.html or COPYING file.
00011 #
00012 # Contact: SBIA Group <sbia-software at uphs.upenn.edu>
00013 #
00014 # @ingroup CMakeFindModules
00015 ##############################################################################
00016 
00017 # ----------------------------------------------------------------------------
00018 # find BASH executable
00019 find_program (BASH_EXECUTABLE bash)
00020 mark_as_advanced (BASH_EXECUTABLE)
00021 
00022 # ----------------------------------------------------------------------------
00023 # get version of found BASH executable
00024 if (BASH_EXECUTABLE)
00025   execute_process (COMMAND "${BASH_EXECUTABLE}" --version OUTPUT_VARIABLE _BASH_STDOUT ERROR_VARIABLE _BASH_STDERR)
00026   if (_BASH_STDOUT MATCHES "version ([0-9]+)\\.([0-9]+)\\.([0-9]+)")
00027     set (BASH_VERSION_MAJOR "${CMAKE_MATCH_1}")
00028     set (BASH_VERSION_MINOR "${CMAKE_MATCH_2}")
00029     set (BASH_VERSION_PATCH "${CMAKE_MATCH_3}")
00030     set (BASH_VERSION_STRING "${BASH_VERSION_MAJOR}.${BASH_VERSION_MINOR}.${BASH_VERSION_PATCH}")
00031   else ()
00032     message (WARNING "Failed to determine version of Bash interpreter (${BASH_EXECUTABLE})! Error:\n${_BASH_STDERR}")
00033   endif ()
00034   unset (_BASH_STDOUT)
00035   unset (_BASH_STDERR)
00036 endif ()
00037 
00038 # ----------------------------------------------------------------------------
00039 # handle the QUIETLY and REQUIRED arguments and set *_FOUND to TRUE
00040 # if all listed variables are found or TRUE
00041 include (FindPackageHandleStandardArgs)
00042 
00043 find_package_handle_standard_args (
00044   BASH
00045   REQUIRED_VARS
00046     BASH_EXECUTABLE
00047 )