summaryrefslogtreecommitdiffstats
path: root/Modules/CMakeDetermineCompiler.cmake
diff options
context:
space:
mode:
Diffstat (limited to 'Modules/CMakeDetermineCompiler.cmake')
-rw-r--r--Modules/CMakeDetermineCompiler.cmake12
1 files changed, 9 insertions, 3 deletions
diff --git a/Modules/CMakeDetermineCompiler.cmake b/Modules/CMakeDetermineCompiler.cmake
index aec86d9..ec2a865 100644
--- a/Modules/CMakeDetermineCompiler.cmake
+++ b/Modules/CMakeDetermineCompiler.cmake
@@ -119,9 +119,15 @@ macro(_cmake_find_compiler_path lang)
# (e.g. via ctest) or set in CMAKE_TOOLCHAIN_FILE
# if CMAKE_${lang}_COMPILER is a list, use the first item as
# CMAKE_${lang}_COMPILER and the rest as CMAKE_${lang}_COMPILER_ARG1
- set(CMAKE_${lang}_COMPILER_ARG1 "${CMAKE_${lang}_COMPILER}")
- list(POP_FRONT CMAKE_${lang}_COMPILER_ARG1 CMAKE_${lang}_COMPILER)
- list(JOIN CMAKE_${lang}_COMPILER_ARG1 " " CMAKE_${lang}_COMPILER_ARG1)
+ # Otherwise, preserve any existing CMAKE_${lang}_COMPILER_ARG1 that might
+ # have been saved by CMakeDetermine${lang}Compiler in a previous run.
+ list(LENGTH CMAKE_${lang}_COMPILER _CMAKE_${lang}_COMPILER_LENGTH)
+ if(_CMAKE_${lang}_COMPILER_LENGTH GREATER 1)
+ set(CMAKE_${lang}_COMPILER_ARG1 "${CMAKE_${lang}_COMPILER}")
+ list(POP_FRONT CMAKE_${lang}_COMPILER_ARG1 CMAKE_${lang}_COMPILER)
+ list(JOIN CMAKE_${lang}_COMPILER_ARG1 " " CMAKE_${lang}_COMPILER_ARG1)
+ endif()
+ unset(_CMAKE_${lang}_COMPILER_LENGTH)
# find the compiler in the PATH if necessary
# if compiler (and arguments) comes from cache then synchronize cache with updated CMAKE_<LANG>_COMPILER