Test for executable and preserve erroneous path for messages

If an alternate compiler is specified, then check if this is actually
executable before assigning it so that we don't end up with specifying
an empty name to CMake. If the path does not exist, it will be preserved
so that CMake will complain with an easily identifiable error message.
This commit is contained in:
Roland Kaufmann 2013-09-10 08:55:25 +02:00
parent bc13496fa2
commit 7285bd8fdf

View File

@ -145,7 +145,7 @@ VARS=()
# command that launches cmake; look for 2.8 if available # command that launches cmake; look for 2.8 if available
if [ "${CMAKE_COMMAND}" = "" ]; then if [ "${CMAKE_COMMAND}" = "" ]; then
if test -n "$(command -v cmake28)"; then if [ -x "$(command -v cmake28)" ]; then
CMAKE_COMMAND=cmake28 CMAKE_COMMAND=cmake28
else else
CMAKE_COMMAND=cmake CMAKE_COMMAND=cmake
@ -453,11 +453,13 @@ for a in "${VARS[@]}"; do
;; ;;
CC=*) CC=*)
# special processing for compiler options # special processing for compiler options
a=$(command -v ${a#CC=}) a=${a#CC=}
[ -x "$(command -v $a)" ] && a=$(command -v "$a")
c_compiler=" -DCMAKE_C_COMPILER=\"${a/\"/\\\"}\"" c_compiler=" -DCMAKE_C_COMPILER=\"${a/\"/\\\"}\""
;; ;;
CXX=*) CXX=*)
a=$(command -v ${a#CXX=}) a=${a#CXX=}
[ -x "$(command -v $a)" ] && a=$(command -v "$a")
cxx_compiler=" -DCMAKE_CXX_COMPILER=\"${a/\"/\\\"}\"" cxx_compiler=" -DCMAKE_CXX_COMPILER=\"${a/\"/\\\"}\""
;; ;;
CFLAGS=*) CFLAGS=*)
@ -469,7 +471,8 @@ for a in "${VARS[@]}"; do
cxx_opts=" -DCMAKE_CXX_FLAGS=\"${a/\"/\\\"}\"" cxx_opts=" -DCMAKE_CXX_FLAGS=\"${a/\"/\\\"}\""
;; ;;
FC=*) FC=*)
a=$(command -v ${a#FC=}) a=${a#FC=}
[ -x "$(command -v $a)" ] && a=$(command -v "$a")
fort_compiler=" -DCMAKE_Fortran_COMPILER=\"${a/\"/\\\"}\"" fort_compiler=" -DCMAKE_Fortran_COMPILER=\"${a/\"/\\\"}\""
;; ;;
FFLAGS=*) FFLAGS=*)