Selaa lähdekoodia

Toolchain: Make `/path/comp;-argn' behave the same as 'comp;-argn'

When using `cmake ... -DCMAKE_C_COMPILER=gcc;-pipe` first invocation of
CMake worked correctly.

When using `cmake ... -DCMAKE_C_COMPILER=/path/to/gcc;-pipe` first
invocation  of CMake detected a change to CMAKE_C_COMPILER, printed "You
have changed variables" message, and re-ran the initial compiler tests
after configuration was complete and before generation of the project
files.

The difference was due to the cache being forced updated with the new
value of CMAKE_C_COMPILER so that the comparison check passes.
Fred Baksik 5 vuotta sitten
vanhempi
sitoutus
12ba89e142
1 muutettua tiedostoa jossa 7 lisäystä ja 0 poistoa
  1. 7 0
      Modules/CMakeDetermineCompiler.cmake

+ 7 - 0
Modules/CMakeDetermineCompiler.cmake

@@ -114,6 +114,7 @@ macro(_cmake_find_compiler_path lang)
     list(JOIN CMAKE_${lang}_COMPILER_ARG1 " " CMAKE_${lang}_COMPILER_ARG1)
 
     # find the compiler in the PATH if necessary
+    # if compiler (and arguments) comes from cache then synchronize cache with updated CMAKE_<LANG>_COMPILER
     get_filename_component(_CMAKE_USER_${lang}_COMPILER_PATH "${CMAKE_${lang}_COMPILER}" PATH)
     if(NOT _CMAKE_USER_${lang}_COMPILER_PATH)
       find_program(CMAKE_${lang}_COMPILER_WITH_PATH NAMES ${CMAKE_${lang}_COMPILER})
@@ -126,6 +127,12 @@ macro(_cmake_find_compiler_path lang)
         unset(_CMAKE_${lang}_COMPILER_CACHED)
       endif()
       unset(CMAKE_${lang}_COMPILER_WITH_PATH CACHE)
+    elseif (EXISTS ${CMAKE_${lang}_COMPILER})
+      get_property(_CMAKE_${lang}_COMPILER_CACHED CACHE CMAKE_${lang}_COMPILER PROPERTY TYPE)
+      if(_CMAKE_${lang}_COMPILER_CACHED)
+        set(CMAKE_${lang}_COMPILER "${CMAKE_${lang}_COMPILER}" CACHE STRING "${lang} compiler" FORCE)
+      endif()
+      unset(_CMAKE_${lang}_COMPILER_CACHED)
     endif()
   endif()
 endmacro()