Browse Source

Rebuild on compiler switch

Kajetan Johannes Hammerle 1 month ago
parent
commit
585118c1b6
1 changed files with 10 additions and 1 deletions
  1. 10 1
      tasks

+ 10 - 1
tasks

@@ -45,9 +45,13 @@ stats=false
 
 export CMAKE_EXPORT_COMPILE_COMMANDS=true
 
+cleanFolders() {
+    rm -rf build_debug build_profile build_release install
+}
+
 # parsing
 if [ "$task" = "clean" ]; then
-    rm -rf build_debug build_profile build_release install
+    cleanFolders
 elif [ "$task" = "build" ]; then
     type=$2
     if [ "$type" = "debug" ]; then
@@ -125,6 +129,11 @@ fi
 buildProfile() {
     folder=$1
     shift 1
+    if [ -e "$folder" ]; then
+	if ! cat $folder/CMakeCache.txt | grep "CMAKE_C_COMPILER:" | grep $compiler > /dev/null; then
+	    cleanFolders
+	fi
+    fi
     if [ ! -e "$folder" ]; then
         cmake -B "$folder" -S . -G Ninja -DCMAKE_C_COMPILER="${compiler}" -DCMAKE_INSTALL_PREFIX=../install "$@"
     fi