1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-10-21 23:00:50 +08:00

Merge branch 'backport-3.16-objc-env-vars' into objc-env-vars

This commit is contained in:
Brad King
2020-05-14 07:27:24 -04:00
6 changed files with 61 additions and 18 deletions

14
Help/envvar/OBJC.rst Normal file
View File

@@ -0,0 +1,14 @@
OBJC
----
.. include:: ENV_VAR.txt
Preferred executable for compiling ``OBJC`` language files. Will only be used
by CMake on the first configuration to determine ``OBJC`` compiler, after
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.

14
Help/envvar/OBJCXX.rst Normal file
View File

@@ -0,0 +1,14 @@
OBJCXX
------
.. include:: ENV_VAR.txt
Preferred executable for compiling ``OBJCXX`` language files. Will only be used
by CMake on the first configuration to determine ``OBJCXX`` compiler, after
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.

View File

@@ -56,6 +56,8 @@ Environment Variables for Languages
/envvar/CXXFLAGS /envvar/CXXFLAGS
/envvar/FC /envvar/FC
/envvar/FFLAGS /envvar/FFLAGS
/envvar/OBJC
/envvar/OBJCXX
/envvar/RC /envvar/RC
/envvar/RCFLAGS /envvar/RCFLAGS
/envvar/SWIFTC /envvar/SWIFTC

View File

@@ -303,3 +303,10 @@ Changes made since CMake 3.16.0 include the following.
Additionally, the modules no longer expose their internal ``_Python*`` Additionally, the modules no longer expose their internal ``_Python*``
cache entries publicly. CMake 3.16.0 through 3.16.4 accidentally cache entries publicly. CMake 3.16.0 through 3.16.4 accidentally
made them visible as advanced cache entries. 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.

View File

@@ -34,16 +34,19 @@ else()
if(NOT CMAKE_OBJC_COMPILER) if(NOT CMAKE_OBJC_COMPILER)
set(CMAKE_OBJC_COMPILER_INIT NOTFOUND) set(CMAKE_OBJC_COMPILER_INIT NOTFOUND)
# prefer the environment variable OBJC # prefer the environment variable OBJC or CC
if($ENV{OBJC} MATCHES ".+") foreach(var OBJC CC)
get_filename_component(CMAKE_OBJC_COMPILER_INIT $ENV{OBJC} PROGRAM PROGRAM_ARGS CMAKE_OBJC_FLAGS_ENV_INIT) if($ENV{${var}} MATCHES ".+")
if(CMAKE_OBJC_FLAGS_ENV_INIT) get_filename_component(CMAKE_OBJC_COMPILER_INIT $ENV{${var}} PROGRAM PROGRAM_ARGS CMAKE_OBJC_FLAGS_ENV_INIT)
set(CMAKE_OBJC_COMPILER_ARG1 "${CMAKE_OBJC_FLAGS_ENV_INIT}" CACHE STRING "First argument to Objective-C compiler") 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() endif()
if(NOT EXISTS ${CMAKE_OBJC_COMPILER_INIT}) endforeach()
message(FATAL_ERROR "Could not find compiler set in environment variable OBJC:\n$ENV{OBJC}.")
endif()
endif()
# next try prefer the compiler specified by the generator # next try prefer the compiler specified by the generator
if(CMAKE_GENERATOR_OBJC) if(CMAKE_GENERATOR_OBJC)

View File

@@ -36,16 +36,19 @@ else()
if(NOT CMAKE_OBJCXX_COMPILER) if(NOT CMAKE_OBJCXX_COMPILER)
set(CMAKE_OBJCXX_COMPILER_INIT NOTFOUND) set(CMAKE_OBJCXX_COMPILER_INIT NOTFOUND)
# prefer the environment variable OBJCXX # prefer the environment variable OBJCXX or CXX
if($ENV{OBJCXX} MATCHES ".+") foreach(var OBJCXX CXX)
get_filename_component(CMAKE_OBJCXX_COMPILER_INIT $ENV{OBJCXX} PROGRAM PROGRAM_ARGS CMAKE_OBJCXX_FLAGS_ENV_INIT) if($ENV{${var}} MATCHES ".+")
if(CMAKE_OBJCXX_FLAGS_ENV_INIT) get_filename_component(CMAKE_OBJCXX_COMPILER_INIT $ENV{${var}} PROGRAM PROGRAM_ARGS CMAKE_OBJCXX_FLAGS_ENV_INIT)
set(CMAKE_OBJCXX_COMPILER_ARG1 "${CMAKE_OBJCXX_FLAGS_ENV_INIT}" CACHE STRING "First argument to Objective-C++ compiler") 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() endif()
if(NOT EXISTS ${CMAKE_OBJCXX_COMPILER_INIT}) endforeach()
message(FATAL_ERROR "Could not find compiler set in environment variable OBJCXX:\n$ENV{OBJCXX}.\n${CMAKE_OBJCXX_COMPILER_INIT}")
endif()
endif()
# next prefer the generator specified compiler # next prefer the generator specified compiler
if(CMAKE_GENERATOR_OBJCXX) if(CMAKE_GENERATOR_OBJCXX)