summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2020-05-14 11:31:32 (GMT)
committerBrad King <brad.king@kitware.com>2020-05-14 11:31:32 (GMT)
commitb1a3131cc67b42cd5e8304206813e0a722257cd1 (patch)
treef7e579084e2eeb1697f064c21e7d0e4b315f9f8c /Modules
parent4b810405a4ad49e24f2d5531a6ad223101425f22 (diff)
parent67b9f55d46f934de0954ae83d39169c86039ecea (diff)
downloadCMake-b1a3131cc67b42cd5e8304206813e0a722257cd1.zip
CMake-b1a3131cc67b42cd5e8304206813e0a722257cd1.tar.gz
CMake-b1a3131cc67b42cd5e8304206813e0a722257cd1.tar.bz2
Merge branch 'backport-3.16-objc-env-vars' into release-3.16
Diffstat (limited to 'Modules')
-rw-r--r--Modules/CMakeDetermineOBJCCompiler.cmake21
-rw-r--r--Modules/CMakeDetermineOBJCXXCompiler.cmake21
2 files changed, 24 insertions, 18 deletions
diff --git a/Modules/CMakeDetermineOBJCCompiler.cmake b/Modules/CMakeDetermineOBJCCompiler.cmake
index ad13eab..11b47fd 100644
--- a/Modules/CMakeDetermineOBJCCompiler.cmake
+++ b/Modules/CMakeDetermineOBJCCompiler.cmake
@@ -34,16 +34,19 @@ else()
if(NOT CMAKE_OBJC_COMPILER)
set(CMAKE_OBJC_COMPILER_INIT NOTFOUND)
- # prefer the environment variable OBJC
- if($ENV{OBJC} MATCHES ".+")
- get_filename_component(CMAKE_OBJC_COMPILER_INIT $ENV{OBJC} 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")
+ # prefer the environment variable OBJC or CC
+ foreach(var OBJC CC)
+ 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")
+ endif()
+ if(NOT EXISTS ${CMAKE_OBJC_COMPILER_INIT})
+ message(FATAL_ERROR "Could not find compiler set in environment variable ${var}:\n $ENV{${var}}")
+ endif()
+ break()
endif()
- if(NOT EXISTS ${CMAKE_OBJC_COMPILER_INIT})
- message(FATAL_ERROR "Could not find compiler set in environment variable OBJC:\n$ENV{OBJC}.")
- endif()
- endif()
+ endforeach()
# next try prefer the compiler specified by the generator
if(CMAKE_GENERATOR_OBJC)
diff --git a/Modules/CMakeDetermineOBJCXXCompiler.cmake b/Modules/CMakeDetermineOBJCXXCompiler.cmake
index 60fcbb3..db874d1 100644
--- a/Modules/CMakeDetermineOBJCXXCompiler.cmake
+++ b/Modules/CMakeDetermineOBJCXXCompiler.cmake
@@ -36,16 +36,19 @@ else()
if(NOT CMAKE_OBJCXX_COMPILER)
set(CMAKE_OBJCXX_COMPILER_INIT NOTFOUND)
- # prefer the environment variable OBJCXX
- if($ENV{OBJCXX} MATCHES ".+")
- get_filename_component(CMAKE_OBJCXX_COMPILER_INIT $ENV{OBJCXX} 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")
+ # prefer the environment variable OBJCXX or CXX
+ foreach(var OBJCXX CXX)
+ 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")
+ endif()
+ if(NOT EXISTS ${CMAKE_OBJCXX_COMPILER_INIT})
+ message(FATAL_ERROR "Could not find compiler set in environment variable ${var}:\n $ENV{${var}}")
+ endif()
+ break()
endif()
- if(NOT EXISTS ${CMAKE_OBJCXX_COMPILER_INIT})
- message(FATAL_ERROR "Could not find compiler set in environment variable OBJCXX:\n$ENV{OBJCXX}.\n${CMAKE_OBJCXX_COMPILER_INIT}")
- endif()
- endif()
+ endforeach()
# next prefer the generator specified compiler
if(CMAKE_GENERATOR_OBJCXX)