Avoid unintended cached var in CMake's find_program (dotnet/coreclr#27322)
authorAdeel Mujahid <adeelbm@outlook.com>
Sun, 20 Oct 2019 18:21:02 +0000 (21:21 +0300)
committerJeremy Koritzinsky <jekoritz@microsoft.com>
Sun, 20 Oct 2019 18:21:02 +0000 (11:21 -0700)
Commit migrated from https://github.com/dotnet/coreclr/commit/2c22d9946b0f04c603a13cf7cc6196317e97442f

src/coreclr/configuretools.cmake
src/coreclr/src/pal/tools/find-gcc.sh

index 372309f..3c96e1a 100644 (file)
@@ -10,15 +10,16 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
   else()
     set(LLVM_PREFIX "llvm-")
   endif()
+
   function(locate_llvm_exec exec var)
-    find_program(EXEC_LOCATION
+    find_program(EXEC_LOCATION_${exec}
      NAMES
      "${LLVM_PREFIX}${exec}${CLR_CMAKE_COMPILER_FILE_NAME_VERSION}"
      "${LLVM_PREFIX}${exec}")
-    if (EXEC_LOCATION STREQUAL "EXEC_LOCATION-NOTFOUND")
+    if (EXEC_LOCATION_${exec} STREQUAL "EXEC_LOCATION_${exec}-NOTFOUND")
       message(FATAL_ERROR "Unable to find llvm tool for: ${exec}.")
     endif()
-    set(${var} ${EXEC_LOCATION} PARENT_SCOPE)
+    set(${var} ${EXEC_LOCATION_${exec}} PARENT_SCOPE)
   endfunction()
   locate_llvm_exec(ar CMAKE_AR)
   locate_llvm_exec(link CMAKE_LINKER)
@@ -34,20 +35,20 @@ elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
   endif()
 
   function(locate_gcc_exec exec var)
-    string(TOUPPER exec EXEC_UPPERCASE)
+    string(TOUPPER ${exec} EXEC_UPPERCASE)
     if(NOT "$ENV{CLR_${EXEC_UPPERCASE}}" STREQUAL "")
       set(${var} "$ENV{CLR_${EXEC_UPPERCASE}}" PARENT_SCOPE)
       return()
     endif()
 
-    find_program(EXEC_LOCATION
+    find_program(EXEC_LOCATION_${exec}
       NAMES
       "${GCC_PREFIX}${exec}${CLR_CMAKE_COMPILER_FILE_NAME_VERSION}"
       "${GCC_PREFIX}${exec}")
-    if (EXEC_LOCATION STREQUAL "EXEC_LOCATION-NOTFOUND")
+    if (EXEC_LOCATION_${exec} STREQUAL "EXEC_LOCATION_${exec}-NOTFOUND")
       message(FATAL_ERROR "Unable to find gcc tool for: ${exec}.")
     endif()
-    set(${var} ${EXEC_LOCATION} PARENT_SCOPE)
+    set(${var} ${EXEC_LOCATION_${exec}} PARENT_SCOPE)
   endfunction()
   locate_gcc_exec(ar CMAKE_AR)
   locate_gcc_exec(link CMAKE_LINKER)
index 0fbdfbd..f7acc76 100755 (executable)
@@ -6,7 +6,7 @@
 if [ $# -lt 2 ]
 then
   echo "Usage..."
-  echo "gen-buildsys-gcc.sh <GccMajorVersion> <GccMinorVersion>"
+  echo "find-gcc.sh <GccMajorVersion> <GccMinorVersion>"
   echo "Specify the Gcc version to use, split into major and minor version"
   exit 1
 fi