From e519a6c5908518a7ef41e03eda1a1aebc2977eb6 Mon Sep 17 00:00:00 2001 From: Andre Anjos <andre.anjos@idiap.ch> Date: Tue, 24 Jan 2017 16:05:12 +0100 Subject: [PATCH] Clever setup of variables --- gitlab/functions.sh | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/gitlab/functions.sh b/gitlab/functions.sh index 6a9b28f..cbfea14 100644 --- a/gitlab/functions.sh +++ b/gitlab/functions.sh @@ -203,6 +203,18 @@ prepare_build_env() { } +# Appends a value to a variable if that is not already set +# $1: variable name to append the value +# $2: the value to be appended +append_if_not_set() { + if [ -z "${1+abc}" ]; then + eval $1="$2" + elif [[ "${!1}" != "*${2}*" ]]; then + eval $1="${!1} $2" + fi +} + + # Checks if an array contains a value # taken from here: https://stackoverflow.com/questions/3685970/check-if-an-array-contains-a-value # Parameters: <value-to-check> <array-variable> @@ -300,12 +312,12 @@ else fi if [ "${OSNAME}" == "macosx" ]; then + CC=gcc + export_env CC + CXX=g++ + export_env CXX MACOSX_DEPLOYMENT_TARGET="10.7" export_env MACOSX_DEPLOYMENT_TARGET - if [ -n "${CPPFLAGS}" ]; then - CPPFLAGS="${CPPFLAGS} -DBOOST_NO_CXX11_RVALUE_REFERENCES" - else - CPPFLAGS="-DBOOST_NO_CXX11_RVALUE_REFERENCES" - fi + append_if_not_set CPPFLAGS "-DBOOST_NO_CXX11_RVALUE_REFERENCES" export_env CPPFLAGS fi -- GitLab