From da9372fb70b1b917ca4ffb30561d99df9982a5b7 Mon Sep 17 00:00:00 2001 From: Doron Behar Date: Sun, 20 May 2018 11:30:33 +0300 Subject: [PATCH] refactor(build.sh): Add gcc over clang option(#1249) There was no way to build with gcc when clang was installed using build.sh --- build.sh | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/build.sh b/build.sh index 2760cceb..39dbe47a 100755 --- a/build.sh +++ b/build.sh @@ -38,9 +38,11 @@ function main msg "Setting build options" + read -r -p "$(msg "Use GCC even if Clang is installed -------------------------------- [y/N]: ")" -n 1 p && echo + [[ "${p^^}" != "Y" ]] && try_to_use_clang="ON" read -r -p "$(msg "Include support for \"internal/i3\" (requires i3) ------------------- [y/N]: ")" -n 1 p && echo [[ "${p^^}" != "Y" ]] && enable_i3="OFF" - read -r -p "$(msg "Include support for \"internal/alsa\" (requires alsalib) ---------- [y/N]: ")" -n 1 p && echo + read -r -p "$(msg "Include support for \"internal/alsa\" (requires alsalib) ------------ [y/N]: ")" -n 1 p && echo [[ "${p^^}" != "Y" ]] && enable_alsa="OFF" read -r -p "$(msg "Include support for \"internal/pulseaudio\" (requires libpulse) ----- [y/N]: ")" -n 1 p && echo [[ "${p^^}" != "Y" ]] && enable_pulseaudio="OFF" @@ -56,14 +58,19 @@ function main local cxx="c++" local cc="cc" - if command -v clang++ >/dev/null; then - msg "Using compiler: clang++/clang" - cxx="clang++" - cc="clang" - elif command -v g++ >/dev/null; then - msg "Using compiler: g++/gcc" - cxx="g++" - cc="gcc" + if [[ "${try_to_use_clang}" == "ON" ]]; then + if command -v clang++ >/dev/null; then + msg "Using compiler: clang++/clang" + cxx="clang++" + cc="clang" + elif command -v g++ >/dev/null; then + msg "Using compiler: g++/gcc" + cxx="g++" + cc="gcc" + fi + else + cxx="g++" + cc="gcc" fi msg "Executing cmake command"