Merge pull request #351 from rolk/351_cxx
Alternate compiler cannot be set with environment variables
This commit is contained in:
commit
76a7cba75e
85
cmake/Scripts/configure
vendored
85
cmake/Scripts/configure
vendored
@ -97,6 +97,15 @@ invalid_opt () {
|
||||
|
||||
# default values
|
||||
prefix=/usr/local
|
||||
#c_compiler=" -DCMAKE_C_COMPILER=cc"
|
||||
c_compiler=
|
||||
c_opts=
|
||||
#cxx_compiler=" -DCMAKE_CXX_COMPILER=c++"
|
||||
cxx_compiler=
|
||||
cxx_opts=
|
||||
#fort_compiler=" -DCMAKE_Fortran_COMPILER=fc"
|
||||
fort_compiler=
|
||||
fort_opts=
|
||||
#buildtype=" -DCMAKE_BUILD_TYPE=Debug"
|
||||
buildtype=
|
||||
#pch_use=" -DPRECOMPILE_HEADERS:BOOL=ON"
|
||||
@ -120,6 +129,10 @@ use_samples=
|
||||
use_ninja=
|
||||
#use_underscoring=" -DUSE_UNDERSCORING=OFF"
|
||||
use_underscoring=
|
||||
# boost_root=""
|
||||
boost_root=
|
||||
boost_libdir=
|
||||
boost_opts=
|
||||
|
||||
# default is to warn for unknown options, but this can be disabled
|
||||
option_check=yes
|
||||
@ -199,8 +212,16 @@ for OPT in "$@"; do
|
||||
mpi-prefix)
|
||||
rootvar="_MPI_PREFIX_PATH"
|
||||
;;
|
||||
boost)
|
||||
# special handling of this package, see further below
|
||||
boost_root="${pkgloc}"
|
||||
rootvar=""
|
||||
;;
|
||||
boost-libdir)
|
||||
boost_libdir="${pkgloc}"
|
||||
rootvar=""
|
||||
;;
|
||||
alugrid |\
|
||||
boost |\
|
||||
eigen3 |\
|
||||
ert |\
|
||||
metis |\
|
||||
@ -405,15 +426,67 @@ done
|
||||
# remove all arguments processed by getopts
|
||||
shift $((OPTIND-1))
|
||||
|
||||
# remove Autotools-specific variables. notice the usage of a quoted
|
||||
# array: each element will be returned even with spaces.
|
||||
# special handling of Boost: if --with-boost-libdir has been used,
|
||||
# then the --with-boost turns into specifying the header directory
|
||||
# and not the search root. this mirrors the functionality in the
|
||||
# Autotools ax_boost_base.m4. necessary because FindBoost in CMake
|
||||
# uses two different variables if you want to specify them separately
|
||||
if [ -n "${boost_libdir}" ]; then
|
||||
boost_opts=" -DBOOST_LIBRARYDIR=\"${boost_libdir}\""
|
||||
if [ -n "${boost_root}" ]; then
|
||||
boost_opts="${boost_opts} -DBOOST_INCLUDEDIR=\"${boost_root}\""
|
||||
fi
|
||||
else
|
||||
if [ -n "${boost_root}" ]; then
|
||||
boost_opts=" -DBOOST_ROOT=\"${boost_root}\""
|
||||
else
|
||||
boost_opts=""
|
||||
fi
|
||||
fi
|
||||
|
||||
# notice the usage of a quoted array: each element will be returned
|
||||
# even with spaces.
|
||||
for a in "${VARS[@]}"; do
|
||||
a="${a/ACLOCAL_*=*/}"
|
||||
[ -n "$a" ] && ENVVARS="$ENVVARS \"${a/\"/\\\"}\""
|
||||
case "$a" in
|
||||
ACLOCAL_*=*)
|
||||
# remove Autotools-specific variables.
|
||||
;;
|
||||
CC=*)
|
||||
# special processing for compiler options
|
||||
a=${a#CC=}
|
||||
c_compiler=" -DCMAKE_C_COMPILER=\"${a/\"/\\\"}\""
|
||||
;;
|
||||
CXX=*)
|
||||
a=${a#CXX=}
|
||||
cxx_compiler=" -DCMAKE_CXX_COMPILER=\"${a/\"/\\\"}\""
|
||||
;;
|
||||
CFLAGS=*)
|
||||
a=${a#CFLAGS=}
|
||||
c_opts=" -DCMAKE_C_FLAGS=\"${a/\"/\\\"}\""
|
||||
;;
|
||||
CXXFLAGS=*)
|
||||
a=${a#CXXFLAGS=}
|
||||
cxx_opts=" -DCMAKE_CXX_FLAGS=\"${a/\"/\\\"}\""
|
||||
;;
|
||||
FC=*)
|
||||
a=${a#FC=}
|
||||
fort_compiler=" -DCMAKE_Fortran_COMPILER=\"${a/\"/\\\"}\""
|
||||
;;
|
||||
FFLAGS=*)
|
||||
a=${a#FFLAGS=}
|
||||
fort_opts=" -DCMAKE_Fortran_FLAGS=\"${a/\"/\\\"}\""
|
||||
;;
|
||||
*)
|
||||
ENVVARS="$ENVVARS \"${a/\"/\\\"}\""
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# only wrap in env command if any variable were actually passed
|
||||
[ -n "${ENVVARS}" ] && ENVVARS="env ${ENVVARS} "
|
||||
|
||||
# pass everything on to CMake
|
||||
CMDLINE="env ${ENVVARS} ${CMAKE_COMMAND} \"${srcdir}\" ${use_ninja}\"-DCMAKE_INSTALL_PREFIX=$prefix\"${buildtype}${pch_use}${silent_rules}${debug_loc}${use_openmp}${use_mpi}${use_lto}${use_runpath}${use_tests}${use_samples}${use_underscoring} ${FEATURES}"
|
||||
CMDLINE="${ENVVARS}${CMAKE_COMMAND} \"${srcdir}\" ${use_ninja}\"-DCMAKE_INSTALL_PREFIX=$prefix\"${buildtype}${pch_use}${silent_rules}${debug_loc}${use_openmp}${use_mpi}${use_lto}${use_runpath}${use_tests}${use_samples}${use_underscoring}${c_compiler}${c_opts}${cxx_compiler}${cxx_opts}${fort_compiler}${fort_opts}${boost_opts} ${FEATURES}"
|
||||
echo --- calling CMake ---
|
||||
echo ${CMDLINE}
|
||||
eval exec ${CMDLINE}
|
||||
|
Loading…
Reference in New Issue
Block a user