summaryrefslogtreecommitdiffstats
path: root/Modules/CMakeDetermineCompiler.cmake
diff options
context:
space:
mode:
authorFred Baksik <fdk17@ftml.net>2020-07-15 19:03:45 (GMT)
committerFred Baksik <fred.baksik@mrcy.com>2020-07-23 18:52:48 (GMT)
commit6f1af899db4e93c960145dae12ebaacb308ea1f0 (patch)
tree83ffcfdd61df3d600ca587c06b551b9903f2b130 /Modules/CMakeDetermineCompiler.cmake
parentec1d3bc0b64550307c23ceae7ef542124b68e2e5 (diff)
downloadCMake-6f1af899db4e93c960145dae12ebaacb308ea1f0.zip
CMake-6f1af899db4e93c960145dae12ebaacb308ea1f0.tar.gz
CMake-6f1af899db4e93c960145dae12ebaacb308ea1f0.tar.bz2
Toolchain: Capture all arguments from CMAKE_<LANG>_COMPILER
Capture CMAKE_<LANG>_COMPILER_ARG1 from CMAKE_<LANG>_COMPILER in the same fashion that it is from $ENV{<LANG>}. Since get_filename_component() returns a single string of all the arguments from $ENV{<LANG>}, a single string of arguments will be constructed from the items contained in CMAKE_<LANG>_COMPILER. Fixes #20089
Diffstat (limited to 'Modules/CMakeDetermineCompiler.cmake')
-rw-r--r--Modules/CMakeDetermineCompiler.cmake13
1 files changed, 5 insertions, 8 deletions
diff --git a/Modules/CMakeDetermineCompiler.cmake b/Modules/CMakeDetermineCompiler.cmake
index 7cd7c47..142e61e 100644
--- a/Modules/CMakeDetermineCompiler.cmake
+++ b/Modules/CMakeDetermineCompiler.cmake
@@ -107,14 +107,11 @@ macro(_cmake_find_compiler_path lang)
if(CMAKE_${lang}_COMPILER)
# we only get here if CMAKE_${lang}_COMPILER was specified using -D or a pre-made CMakeCache.txt
# (e.g. via ctest) or set in CMAKE_TOOLCHAIN_FILE
- # if CMAKE_${lang}_COMPILER is a list of length 2, use the first item as
- # CMAKE_${lang}_COMPILER and the 2nd one as CMAKE_${lang}_COMPILER_ARG1
- list(LENGTH CMAKE_${lang}_COMPILER _CMAKE_${lang}_COMPILER_LIST_LENGTH)
- if("${_CMAKE_${lang}_COMPILER_LIST_LENGTH}" EQUAL 2)
- list(GET CMAKE_${lang}_COMPILER 1 CMAKE_${lang}_COMPILER_ARG1)
- list(GET CMAKE_${lang}_COMPILER 0 CMAKE_${lang}_COMPILER)
- endif()
- unset(_CMAKE_${lang}_COMPILER_LIST_LENGTH)
+ # 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)
# find the compiler in the PATH if necessary
get_filename_component(_CMAKE_USER_${lang}_COMPILER_PATH "${CMAKE_${lang}_COMPILER}" PATH)