diff options
author | Brad King <brad.king@kitware.com> | 2020-05-15 13:14:54 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2020-05-15 13:15:46 (GMT) |
commit | a9559ccba5049b12d3b7bf372638ccf723fff679 (patch) | |
tree | af06c8100a76bc2fbfd02d1f504efbbcc31213c6 /Modules/CMakeDetermineOBJCXXCompiler.cmake | |
parent | 96b6bafd1769f76c558832f650994135dff28659 (diff) | |
parent | 13ea190725073dc725352daca3d5419c339acd1a (diff) | |
download | CMake-a9559ccba5049b12d3b7bf372638ccf723fff679.zip CMake-a9559ccba5049b12d3b7bf372638ccf723fff679.tar.gz CMake-a9559ccba5049b12d3b7bf372638ccf723fff679.tar.bz2 |
Merge topic 'objc-env-vars'
13ea190725 Help: Add 3.17.3 release note for Objective C/C++ compiler selection
16bf978e0c Merge branch 'backport-3.16-objc-env-vars' into objc-env-vars
67b9f55d46 Objective C/C++: Honor CC and CXX env vars to select compiler
ab9be6662f Help: Document OBJC and OBJCXX env vars for Objective C/C++ compilers
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4746
Diffstat (limited to 'Modules/CMakeDetermineOBJCXXCompiler.cmake')
-rw-r--r-- | Modules/CMakeDetermineOBJCXXCompiler.cmake | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/Modules/CMakeDetermineOBJCXXCompiler.cmake b/Modules/CMakeDetermineOBJCXXCompiler.cmake index 2cf5119..99ad6c3 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) |