summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2020-05-15 13:14:54 (GMT)
committerKitware Robot <kwrobot@kitware.com>2020-05-15 13:15:46 (GMT)
commita9559ccba5049b12d3b7bf372638ccf723fff679 (patch)
treeaf06c8100a76bc2fbfd02d1f504efbbcc31213c6
parent96b6bafd1769f76c558832f650994135dff28659 (diff)
parent13ea190725073dc725352daca3d5419c339acd1a (diff)
downloadCMake-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
-rw-r--r--Help/envvar/OBJC.rst14
-rw-r--r--Help/envvar/OBJCXX.rst14
-rw-r--r--Help/manual/cmake-env-variables.7.rst2
-rw-r--r--Help/release/3.16.rst7
-rw-r--r--Help/release/3.17.rst4
-rw-r--r--Modules/CMakeDetermineOBJCCompiler.cmake21
-rw-r--r--Modules/CMakeDetermineOBJCXXCompiler.cmake21
7 files changed, 65 insertions, 18 deletions
diff --git a/Help/envvar/OBJC.rst b/Help/envvar/OBJC.rst
new file mode 100644
index 0000000..30c0d13
--- /dev/null
+++ b/Help/envvar/OBJC.rst
@@ -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.
diff --git a/Help/envvar/OBJCXX.rst b/Help/envvar/OBJCXX.rst
new file mode 100644
index 0000000..a72f7e7
--- /dev/null
+++ b/Help/envvar/OBJCXX.rst
@@ -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.
diff --git a/Help/manual/cmake-env-variables.7.rst b/Help/manual/cmake-env-variables.7.rst
index ee83799..ce1e360 100644
--- a/Help/manual/cmake-env-variables.7.rst
+++ b/Help/manual/cmake-env-variables.7.rst
@@ -63,6 +63,8 @@ Environment Variables for Languages
/envvar/CXXFLAGS
/envvar/FC
/envvar/FFLAGS
+ /envvar/OBJC
+ /envvar/OBJCXX
/envvar/RC
/envvar/RCFLAGS
/envvar/SWIFTC
diff --git a/Help/release/3.16.rst b/Help/release/3.16.rst
index e2d6788..bd6d041 100644
--- a/Help/release/3.16.rst
+++ b/Help/release/3.16.rst
@@ -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.
diff --git a/Help/release/3.17.rst b/Help/release/3.17.rst
index 91e2463..b7c66d8 100644
--- a/Help/release/3.17.rst
+++ b/Help/release/3.17.rst
@@ -337,6 +337,10 @@ Changes made since CMake 3.17.0 include the following.
3.17.3
------
+* 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.
+
* The :module:`FindPkgConfig` module now extracts include directories
prefixed with ``-isystem`` into the ``*_INCLUDE_DIRS`` variables and
:prop_tgt:`INTERFACE_INCLUDE_DIRECTORIES` target properties.
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 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)