mirror of
https://github.com/reactos/CMake.git
synced 2025-02-17 01:58:25 +00:00
Objective C/C++: Honor CC and CXX env vars to select compiler
If the `OBJC` or `OBJCXX` environment variable is not set to specify an Objective C or C++ compiler, check `CC` or `CXX` too. Fixes: #20703
This commit is contained in:
parent
ab9be6662f
commit
67b9f55d46
@ -9,3 +9,6 @@ which the value for ``OBJC`` is stored in the cache as
|
||||
:variable:`CMAKE_OBJC_COMPILER <CMAKE_<LANG>_COMPILER>`. For any configuration
|
||||
run (including the first), the environment variable will be ignored if the
|
||||
:variable:`CMAKE_OBJC_COMPILER <CMAKE_<LANG>_COMPILER>` variable is defined.
|
||||
|
||||
If ``OBJC`` is not defined, the :envvar:`CC` environment variable will
|
||||
be checked instead.
|
||||
|
@ -9,3 +9,6 @@ which the value for ``OBJCXX`` is stored in the cache as
|
||||
:variable:`CMAKE_OBJCXX_COMPILER <CMAKE_<LANG>_COMPILER>`. For any configuration
|
||||
run (including the first), the environment variable will be ignored if the
|
||||
:variable:`CMAKE_OBJCXX_COMPILER <CMAKE_<LANG>_COMPILER>` variable is defined.
|
||||
|
||||
If ``OBJCXX`` is not defined, the :envvar:`CXX` environment variable will
|
||||
be checked instead.
|
||||
|
@ -303,3 +303,10 @@ Changes made since CMake 3.16.0 include the following.
|
||||
Additionally, the modules no longer expose their internal ``_Python*``
|
||||
cache entries publicly. CMake 3.16.0 through 3.16.4 accidentally
|
||||
made them visible as advanced cache entries.
|
||||
|
||||
3.16.7
|
||||
------
|
||||
|
||||
* Selection of the Objective C or C++ compiler now considers the
|
||||
:envvar:`CC` or :envvar:`CXX` environment variable if the
|
||||
:envvar:`OBJC` or :envvar:`OBJCXX` environment variable is not set.
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user