diff --git a/Code/Mantid/Build/Jenkins/buildscript b/Code/Mantid/Build/Jenkins/buildscript
index 98a3b2004b9450a4b3ef692be2e2a60cb49e7469..6b9962e7cf97a8a8ec9907378d50835047274564 100755
--- a/Code/Mantid/Build/Jenkins/buildscript
+++ b/Code/Mantid/Build/Jenkins/buildscript
@@ -21,8 +21,8 @@ if [[ ${JOB_NAME} == *clang* ]]; then
   clang --version
   export CC=clang
   export CXX=clang++
-  GCCVERSION=`grep 'GCC_COMPILER_VERSION' $WORKSPACE/build/CMakeCache.txt` 
-  if [[ $GCCVERSION != "" ]]; then 
+  COMPILERFILEPATH=`grep 'CMAKE_CXX_COMPILER:FILEPATH' $WORKSPACE/build/CMakeCache.txt` 
+  if [[ $COMPILERFILEPATH != *clang++* ]]; then 
     # Removing the build directory entirely guarantees clang is used.
     rm -rf $WORKSPACE/build
   fi