summaryrefslogtreecommitdiffstats
path: root/Modules/CMakeDetermineOBJCCompiler.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/CMakeDetermineOBJCCompiler.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/CMakeDetermineOBJCCompiler.cmake')
-rw-r--r--Modules/CMakeDetermineOBJCCompiler.cmake15
1 files changed, 6 insertions, 9 deletions
diff --git a/Modules/CMakeDetermineOBJCCompiler.cmake b/Modules/CMakeDetermineOBJCCompiler.cmake
index 11b47fd..709eb25 100644
--- a/Modules/CMakeDetermineOBJCCompiler.cmake
+++ b/Modules/CMakeDetermineOBJCCompiler.cmake
@@ -39,7 +39,7 @@ else()
if($ENV{${var}} MATCHES ".+")
get_filename_component(CMAKE_OBJC_COMPILER_INIT $ENV{${var}} PROGRAM PROGRAM_ARGS CMAKE_OBJC_FLAGS_ENV_INIT)
if(CMAKE_OBJC_FLAGS_ENV_INIT)
- set(CMAKE_OBJC_COMPILER_ARG1 "${CMAKE_OBJC_FLAGS_ENV_INIT}" CACHE STRING "First argument to Objective-C compiler")
+ set(CMAKE_OBJC_COMPILER_ARG1 "${CMAKE_OBJC_FLAGS_ENV_INIT}" CACHE STRING "Arguments to Objective-C compiler")
endif()
if(NOT EXISTS ${CMAKE_OBJC_COMPILER_INIT})
message(FATAL_ERROR "Could not find compiler set in environment variable ${var}:\n $ENV{${var}}")
@@ -65,14 +65,11 @@ else()
else()
# we only get here if CMAKE_OBJC_COMPILER was specified using -D or a pre-made CMakeCache.txt
# (e.g. via ctest) or set in CMAKE_TOOLCHAIN_FILE
- # if CMAKE_OBJC_COMPILER is a list of length 2, use the first item as
- # CMAKE_OBJC_COMPILER and the 2nd one as CMAKE_OBJC_COMPILER_ARG1
-
- list(LENGTH CMAKE_OBJC_COMPILER _CMAKE_OBJC_COMPILER_LIST_LENGTH)
- if("${_CMAKE_OBJC_COMPILER_LIST_LENGTH}" EQUAL 2)
- list(GET CMAKE_OBJC_COMPILER 1 CMAKE_OBJC_COMPILER_ARG1)
- list(GET CMAKE_OBJC_COMPILER 0 CMAKE_OBJC_COMPILER)
- endif()
+ # if CMAKE_OBJC_COMPILER is a list, use the first item as
+ # CMAKE_OBJC_COMPILER and the rest as CMAKE_OBJC_COMPILER_ARG1
+ set(CMAKE_OBJC_COMPILER_ARG1 "${CMAKE_OBJC_COMPILER}")
+ list(POP_FRONT CMAKE_OBJC_COMPILER_ARG1 CMAKE_OBJC_COMPILER)
+ list(JOIN CMAKE_OBJC_COMPILER_ARG1 " " CMAKE_OBJC_COMPILER_ARG1)
# if a compiler was specified by the user but without path,
# now try to find it with the full path