diff options
author | Fred Baksik <fdk17@ftml.net> | 2020-07-15 19:03:45 (GMT) |
---|---|---|
committer | Fred Baksik <fred.baksik@mrcy.com> | 2020-07-23 18:52:48 (GMT) |
commit | 6f1af899db4e93c960145dae12ebaacb308ea1f0 (patch) | |
tree | 83ffcfdd61df3d600ca587c06b551b9903f2b130 | |
parent | ec1d3bc0b64550307c23ceae7ef542124b68e2e5 (diff) | |
download | CMake-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
-rw-r--r-- | Modules/CMakeDetermineASMCompiler.cmake | 2 | ||||
-rw-r--r-- | Modules/CMakeDetermineCCompiler.cmake | 2 | ||||
-rw-r--r-- | Modules/CMakeDetermineCUDACompiler.cmake | 2 | ||||
-rw-r--r-- | Modules/CMakeDetermineCXXCompiler.cmake | 2 | ||||
-rw-r--r-- | Modules/CMakeDetermineCompiler.cmake | 13 | ||||
-rw-r--r-- | Modules/CMakeDetermineFortranCompiler.cmake | 2 | ||||
-rw-r--r-- | Modules/CMakeDetermineJavaCompiler.cmake | 2 | ||||
-rw-r--r-- | Modules/CMakeDetermineOBJCCompiler.cmake | 15 | ||||
-rw-r--r-- | Modules/CMakeDetermineOBJCXXCompiler.cmake | 15 | ||||
-rw-r--r-- | Modules/CMakeDetermineRCCompiler.cmake | 2 | ||||
-rw-r--r-- | Modules/CMakeDetermineSwiftCompiler.cmake | 2 |
11 files changed, 25 insertions, 34 deletions
diff --git a/Modules/CMakeDetermineASMCompiler.cmake b/Modules/CMakeDetermineASMCompiler.cmake index bc8b86b..a3e5a12 100644 --- a/Modules/CMakeDetermineASMCompiler.cmake +++ b/Modules/CMakeDetermineASMCompiler.cmake @@ -11,7 +11,7 @@ if(NOT CMAKE_ASM${ASM_DIALECT}_COMPILER) if(NOT $ENV{ASM${ASM_DIALECT}} STREQUAL "") get_filename_component(CMAKE_ASM${ASM_DIALECT}_COMPILER_INIT $ENV{ASM${ASM_DIALECT}} PROGRAM PROGRAM_ARGS CMAKE_ASM${ASM_DIALECT}_FLAGS_ENV_INIT) if(CMAKE_ASM${ASM_DIALECT}_FLAGS_ENV_INIT) - set(CMAKE_ASM${ASM_DIALECT}_COMPILER_ARG1 "${CMAKE_ASM${ASM_DIALECT}_FLAGS_ENV_INIT}" CACHE STRING "First argument to ASM${ASM_DIALECT} compiler") + set(CMAKE_ASM${ASM_DIALECT}_COMPILER_ARG1 "${CMAKE_ASM${ASM_DIALECT}_FLAGS_ENV_INIT}" CACHE STRING "Arguments to ASM${ASM_DIALECT} compiler") endif() if(NOT EXISTS ${CMAKE_ASM${ASM_DIALECT}_COMPILER_INIT}) message(FATAL_ERROR "Could not find compiler set in environment variable ASM${ASM_DIALECT}:\n$ENV{ASM${ASM_DIALECT}}.") diff --git a/Modules/CMakeDetermineCCompiler.cmake b/Modules/CMakeDetermineCCompiler.cmake index 86683d1..5aa7dd8 100644 --- a/Modules/CMakeDetermineCCompiler.cmake +++ b/Modules/CMakeDetermineCCompiler.cmake @@ -43,7 +43,7 @@ else() if(NOT $ENV{CC} STREQUAL "") get_filename_component(CMAKE_C_COMPILER_INIT $ENV{CC} PROGRAM PROGRAM_ARGS CMAKE_C_FLAGS_ENV_INIT) if(CMAKE_C_FLAGS_ENV_INIT) - set(CMAKE_C_COMPILER_ARG1 "${CMAKE_C_FLAGS_ENV_INIT}" CACHE STRING "First argument to C compiler") + set(CMAKE_C_COMPILER_ARG1 "${CMAKE_C_FLAGS_ENV_INIT}" CACHE STRING "Arguments to C compiler") endif() if(NOT EXISTS ${CMAKE_C_COMPILER_INIT}) message(FATAL_ERROR "Could not find compiler set in environment variable CC:\n$ENV{CC}.") diff --git a/Modules/CMakeDetermineCUDACompiler.cmake b/Modules/CMakeDetermineCUDACompiler.cmake index 0c586f5..daca382 100644 --- a/Modules/CMakeDetermineCUDACompiler.cmake +++ b/Modules/CMakeDetermineCUDACompiler.cmake @@ -19,7 +19,7 @@ else() if(NOT $ENV{CUDACXX} STREQUAL "") get_filename_component(CMAKE_CUDA_COMPILER_INIT $ENV{CUDACXX} PROGRAM PROGRAM_ARGS CMAKE_CUDA_FLAGS_ENV_INIT) if(CMAKE_CUDA_FLAGS_ENV_INIT) - set(CMAKE_CUDA_COMPILER_ARG1 "${CMAKE_CUDA_FLAGS_ENV_INIT}" CACHE STRING "First argument to CXX compiler") + set(CMAKE_CUDA_COMPILER_ARG1 "${CMAKE_CUDA_FLAGS_ENV_INIT}" CACHE STRING "Arguments to CXX compiler") endif() if(NOT EXISTS ${CMAKE_CUDA_COMPILER_INIT}) message(FATAL_ERROR "Could not find compiler set in environment variable CUDACXX:\n$ENV{CUDACXX}.\n${CMAKE_CUDA_COMPILER_INIT}") diff --git a/Modules/CMakeDetermineCXXCompiler.cmake b/Modules/CMakeDetermineCXXCompiler.cmake index 662b831..e7e294f 100644 --- a/Modules/CMakeDetermineCXXCompiler.cmake +++ b/Modules/CMakeDetermineCXXCompiler.cmake @@ -42,7 +42,7 @@ else() if(NOT $ENV{CXX} STREQUAL "") get_filename_component(CMAKE_CXX_COMPILER_INIT $ENV{CXX} PROGRAM PROGRAM_ARGS CMAKE_CXX_FLAGS_ENV_INIT) if(CMAKE_CXX_FLAGS_ENV_INIT) - set(CMAKE_CXX_COMPILER_ARG1 "${CMAKE_CXX_FLAGS_ENV_INIT}" CACHE STRING "First argument to CXX compiler") + set(CMAKE_CXX_COMPILER_ARG1 "${CMAKE_CXX_FLAGS_ENV_INIT}" CACHE STRING "Arguments to CXX compiler") endif() if(NOT EXISTS ${CMAKE_CXX_COMPILER_INIT}) message(FATAL_ERROR "Could not find compiler set in environment variable CXX:\n$ENV{CXX}.\n${CMAKE_CXX_COMPILER_INIT}") 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) diff --git a/Modules/CMakeDetermineFortranCompiler.cmake b/Modules/CMakeDetermineFortranCompiler.cmake index 5f5a70a..8a57408 100644 --- a/Modules/CMakeDetermineFortranCompiler.cmake +++ b/Modules/CMakeDetermineFortranCompiler.cmake @@ -26,7 +26,7 @@ else() if(NOT $ENV{FC} STREQUAL "") get_filename_component(CMAKE_Fortran_COMPILER_INIT $ENV{FC} PROGRAM PROGRAM_ARGS CMAKE_Fortran_FLAGS_ENV_INIT) if(CMAKE_Fortran_FLAGS_ENV_INIT) - set(CMAKE_Fortran_COMPILER_ARG1 "${CMAKE_Fortran_FLAGS_ENV_INIT}" CACHE STRING "First argument to Fortran compiler") + set(CMAKE_Fortran_COMPILER_ARG1 "${CMAKE_Fortran_FLAGS_ENV_INIT}" CACHE STRING "Arguments to Fortran compiler") endif() if(EXISTS ${CMAKE_Fortran_COMPILER_INIT}) else() diff --git a/Modules/CMakeDetermineJavaCompiler.cmake b/Modules/CMakeDetermineJavaCompiler.cmake index 3092bb5..db456c0 100644 --- a/Modules/CMakeDetermineJavaCompiler.cmake +++ b/Modules/CMakeDetermineJavaCompiler.cmake @@ -11,7 +11,7 @@ if(NOT CMAKE_Java_COMPILER) if(NOT $ENV{JAVA_COMPILER} STREQUAL "") get_filename_component(CMAKE_Java_COMPILER_INIT $ENV{JAVA_COMPILER} PROGRAM PROGRAM_ARGS CMAKE_Java_FLAGS_ENV_INIT) if(CMAKE_Java_FLAGS_ENV_INIT) - set(CMAKE_Java_COMPILER_ARG1 "${CMAKE_Java_FLAGS_ENV_INIT}" CACHE STRING "First argument to Java compiler") + set(CMAKE_Java_COMPILER_ARG1 "${CMAKE_Java_FLAGS_ENV_INIT}" CACHE STRING "Arguments to Java compiler") endif() if(NOT EXISTS ${CMAKE_Java_COMPILER_INIT}) message(SEND_ERROR "Could not find compiler set in environment variable JAVA_COMPILER:\n$ENV{JAVA_COMPILER}.") 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 diff --git a/Modules/CMakeDetermineOBJCXXCompiler.cmake b/Modules/CMakeDetermineOBJCXXCompiler.cmake index 99ad6c3..ffd0091 100644 --- a/Modules/CMakeDetermineOBJCXXCompiler.cmake +++ b/Modules/CMakeDetermineOBJCXXCompiler.cmake @@ -41,7 +41,7 @@ else() if($ENV{${var}} MATCHES ".+") get_filename_component(CMAKE_OBJCXX_COMPILER_INIT $ENV{${var}} PROGRAM PROGRAM_ARGS CMAKE_OBJCXX_FLAGS_ENV_INIT) if(CMAKE_OBJCXX_FLAGS_ENV_INIT) - set(CMAKE_OBJCXX_COMPILER_ARG1 "${CMAKE_OBJCXX_FLAGS_ENV_INIT}" CACHE STRING "First argument to Objective-C++ compiler") + set(CMAKE_OBJCXX_COMPILER_ARG1 "${CMAKE_OBJCXX_FLAGS_ENV_INIT}" CACHE STRING "Arguments to Objective-C++ compiler") endif() if(NOT EXISTS ${CMAKE_OBJCXX_COMPILER_INIT}) message(FATAL_ERROR "Could not find compiler set in environment variable ${var}:\n $ENV{${var}}") @@ -67,14 +67,11 @@ else() else() # we only get here if CMAKE_OBJCXX_COMPILER was specified using -D or a pre-made CMakeCache.txt # (e.g. via ctest) or set in CMAKE_TOOLCHAIN_FILE - # if CMAKE_OBJCXX_COMPILER is a list of length 2, use the first item as - # CMAKE_OBJCXX_COMPILER and the 2nd one as CMAKE_OBJCXX_COMPILER_ARG1 - - list(LENGTH CMAKE_OBJCXX_COMPILER _CMAKE_OBJCXX_COMPILER_LIST_LENGTH) - if("${_CMAKE_OBJCXX_COMPILER_LIST_LENGTH}" EQUAL 2) - list(GET CMAKE_OBJCXX_COMPILER 1 CMAKE_OBJCXX_COMPILER_ARG1) - list(GET CMAKE_OBJCXX_COMPILER 0 CMAKE_OBJCXX_COMPILER) - endif() + # if CMAKE_OBJCXX_COMPILER is a list, use the first item as + # CMAKE_OBJCXX_COMPILER and the rest as CMAKE_OBJCXX_COMPILER_ARG1 + set(CMAKE_OBJCXX_COMPILER_ARG1 "${CMAKE_OBJCXX_COMPILER}") + list(POP_FRONT CMAKE_OBJCXX_COMPILER_ARG1 CMAKE_OBJCXX_COMPILER) + list(JOIN CMAKE_OBJCXX_COMPILER_ARG1 " " CMAKE_OBJCXX_COMPILER_ARG1) # if a compiler was specified by the user but without path, # now try to find it with the full path diff --git a/Modules/CMakeDetermineRCCompiler.cmake b/Modules/CMakeDetermineRCCompiler.cmake index 8801e16..f8d55a5 100644 --- a/Modules/CMakeDetermineRCCompiler.cmake +++ b/Modules/CMakeDetermineRCCompiler.cmake @@ -13,7 +13,7 @@ if(NOT CMAKE_RC_COMPILER) if(NOT $ENV{RC} STREQUAL "") get_filename_component(CMAKE_RC_COMPILER_INIT $ENV{RC} PROGRAM PROGRAM_ARGS CMAKE_RC_FLAGS_ENV_INIT) if(CMAKE_RC_FLAGS_ENV_INIT) - set(CMAKE_RC_COMPILER_ARG1 "${CMAKE_RC_FLAGS_ENV_INIT}" CACHE STRING "First argument to RC compiler") + set(CMAKE_RC_COMPILER_ARG1 "${CMAKE_RC_FLAGS_ENV_INIT}" CACHE STRING "Arguments to RC compiler") endif() if(EXISTS ${CMAKE_RC_COMPILER_INIT}) else() diff --git a/Modules/CMakeDetermineSwiftCompiler.cmake b/Modules/CMakeDetermineSwiftCompiler.cmake index 688133f..aaad560 100644 --- a/Modules/CMakeDetermineSwiftCompiler.cmake +++ b/Modules/CMakeDetermineSwiftCompiler.cmake @@ -27,7 +27,7 @@ elseif("${CMAKE_GENERATOR}" MATCHES "^Ninja") PROGRAM_ARGS CMAKE_Swift_FLAGS_ENV_INIT) if(CMAKE_Swift_FLAGS_ENV_INIT) set(CMAKE_Swift_COMPILER_ARG1 "${CMAKE_Swift_FLAGS_ENV_INIT}" CACHE - STRING "First argument to the Swift compiler") + STRING "Arguments to the Swift compiler") endif() if(NOT EXISTS ${CMAKE_Swift_COMPILER_INIT}) message(FATAL_ERROR "Could not find compiler set in environment variable SWIFTC\n$ENV{SWIFTC}.\n${CMAKE_Swift_COMPILER_INIT}") |