Browse Source

Set CMAKE_<LANG>_COMPILER_FRONTEND_VARIANT on single-variant compilers

The `GNU` and `MSVC` compilers obviously use their own front-end
command-line style.  Also set this for `AppleClang`.

Fixes: #24232
Russell Greene 2 years ago
parent
commit
e4fcdfa301

+ 6 - 0
Help/release/dev/frontend-variant-always.rst

@@ -0,0 +1,6 @@
+frontend-variant-always
+-----------------------
+
+* The :variable:`CMAKE_<LANG>_COMPILER_FRONTEND_VARIANT` variable is now
+  set for ``GNU``, ``MSVC``, and ``AppleClang`` compilers that have only
+  one frontend variant.

+ 4 - 0
Help/variable/CMAKE_LANG_COMPILER_FRONTEND_VARIANT.rst

@@ -16,3 +16,7 @@ the compiler whose frontend it resembles.
 .. note::
   In other words, this variable describes what command line options
   and language extensions the compiler frontend expects.
+
+.. versionchanged:: 3.26
+  This variable is set for ``GNU``, ``MSVC``, and ``AppleClang``
+  compilers that have only one frontend variant.

+ 5 - 1
Modules/CMakeDetermineCompilerId.cmake

@@ -243,8 +243,12 @@ function(CMAKE_DETERMINE_COMPILER_ID lang flagvar src)
     else()
       set(CMAKE_${lang}_COMPILER_FRONTEND_VARIANT "GNU")
     endif()
-  elseif("x${CMAKE_${lang}_COMPILER_ID}" STREQUAL "xFujitsuClang")
+  elseif("x${CMAKE_${lang}_COMPILER_ID}" STREQUAL "xGNU"
+    OR "x${CMAKE_${lang}_COMPILER_ID}" STREQUAL "xAppleClang"
+    OR "x${CMAKE_${lang}_COMPILER_ID}" STREQUAL "xFujitsuClang")
     set(CMAKE_${lang}_COMPILER_FRONTEND_VARIANT "GNU")
+  elseif("x${CMAKE_${lang}_COMPILER_ID}" STREQUAL "xMSVC")
+    set(CMAKE_${lang}_COMPILER_FRONTEND_VARIANT "MSVC")
   else()
     set(CMAKE_${lang}_COMPILER_FRONTEND_VARIANT "")
   endif()