@@ -103,6 +103,31 @@ function(CMAKE_DETERMINE_COMPILER_ID lang flagvar src)
103
103
set (CMAKE_${lang}_CL_SHOWINCLUDES_PREFIX "" )
104
104
endif ()
105
105
106
+ set (_variant "" )
107
+ if ("x${CMAKE_${lang} _COMPILER_ID}" STREQUAL "xClang" )
108
+ if (CMAKE_HOST_WIN32 AND "x${CMAKE_${lang} _SIMULATE_ID}" STREQUAL "xMSVC" )
109
+ if (CMAKE_GENERATOR MATCHES "Visual Studio" )
110
+ set (CMAKE_${lang}_COMPILER_FRONTEND_VARIANT "MSVC" )
111
+ else ()
112
+ # Test whether an MSVC-like command-line option works.
113
+ execute_process (COMMAND "${CMAKE_${lang} _COMPILER}" -?
114
+ RESULT_VARIABLE _clang_result
115
+ OUTPUT_VARIABLE _clang_stdout
116
+ ERROR_VARIABLE _clang_stderr )
117
+ if (_clang_result EQUAL 0 )
118
+ set (CMAKE_${lang}_COMPILER_FRONTEND_VARIANT "MSVC" )
119
+ else ()
120
+ set (CMAKE_${lang}_COMPILER_FRONTEND_VARIANT "GNU" )
121
+ endif ()
122
+ endif ()
123
+ set (_variant " with ${CMAKE_${lang} _COMPILER_FRONTEND_VARIANT}-like command-line" )
124
+ else ()
125
+ set (CMAKE_${lang}_COMPILER_FRONTEND_VARIANT "GNU" )
126
+ endif ()
127
+ else ()
128
+ set (CMAKE_${lang}_COMPILER_FRONTEND_VARIANT "" )
129
+ endif ()
130
+
106
131
# Display the final identification result.
107
132
if (CMAKE_${lang}_COMPILER_ID )
108
133
if (CMAKE_${lang}_COMPILER_VERSION )
@@ -116,9 +141,10 @@ function(CMAKE_DETERMINE_COMPILER_ID lang flagvar src)
116
141
set (_archid "" )
117
142
endif ()
118
143
message (STATUS "The ${lang} compiler identification is "
119
- "${CMAKE_${lang} _COMPILER_ID}${_archid}${_version} " )
144
+ "${CMAKE_${lang} _COMPILER_ID}${_archid}${_version}${_variant} " )
120
145
unset (_archid )
121
146
unset (_version )
147
+ unset (_variant )
122
148
else ()
123
149
message (STATUS "The ${lang} compiler identification is unknown" )
124
150
endif ()
@@ -137,6 +163,7 @@ function(CMAKE_DETERMINE_COMPILER_ID lang flagvar src)
137
163
PARENT_SCOPE )
138
164
set (CMAKE_${lang}_XCODE_ARCHS "${CMAKE_${lang} _XCODE_ARCHS}" PARENT_SCOPE )
139
165
set (CMAKE_${lang}_CL_SHOWINCLUDES_PREFIX "${CMAKE_${lang} _CL_SHOWINCLUDES_PREFIX}" PARENT_SCOPE )
166
+ set (CMAKE_${lang}_COMPILER_FRONTEND_VARIANT "${CMAKE_${lang} _COMPILER_FRONTEND_VARIANT}" PARENT_SCOPE )
140
167
set (CMAKE_${lang}_COMPILER_VERSION "${CMAKE_${lang} _COMPILER_VERSION}" PARENT_SCOPE )
141
168
set (CMAKE_${lang}_COMPILER_VERSION_INTERNAL "${CMAKE_${lang} _COMPILER_VERSION_INTERNAL}" PARENT_SCOPE )
142
169
set (CMAKE_${lang}_COMPILER_WRAPPER "${CMAKE_${lang} _COMPILER_WRAPPER}" PARENT_SCOPE )
@@ -838,38 +865,3 @@ function(CMAKE_DETERMINE_MSVC_SHOWINCLUDES_PREFIX lang userflags)
838
865
set (CMAKE_${lang}_CL_SHOWINCLUDES_PREFIX "" PARENT_SCOPE )
839
866
endif ()
840
867
endfunction ()
841
-
842
- function (CMAKE_DIAGNOSE_UNSUPPORTED_CLANG lang envvar )
843
- if (NOT CMAKE_HOST_WIN32 OR CMAKE_GENERATOR MATCHES "Visual Studio" OR
844
- NOT "${CMAKE_${lang} _COMPILER_ID};${CMAKE_${lang} _SIMULATE_ID}" STREQUAL "Clang;MSVC" )
845
- return ()
846
- endif ()
847
-
848
- # Test whether an MSVC-like command-line option works.
849
- execute_process (COMMAND "${CMAKE_${lang} _COMPILER}" -?
850
- RESULT_VARIABLE _clang_result
851
- OUTPUT_VARIABLE _clang_stdout
852
- ERROR_VARIABLE _clang_stderr )
853
- if (_clang_result EQUAL 0 )
854
- return ()
855
- endif ()
856
-
857
- # Help the user configure the environment to use the MSVC-like Clang.
858
- string (CONCAT _msg
859
- "The Clang compiler tool\n "
860
- " \" ${CMAKE_${lang} _COMPILER}\"\n "
861
- "targets the MSVC ABI but has a GNU-like command-line interface. "
862
- "This is not supported. "
863
- "Use 'clang-cl' instead, e.g. by setting '${envvar} =clang-cl' in the environment."
864
- )
865
- execute_process (COMMAND rc -help
866
- RESULT_VARIABLE _rc_result
867
- OUTPUT_VARIABLE _rc_stdout
868
- ERROR_VARIABLE _rc_stderr )
869
- if (NOT _rc_result EQUAL 0 )
870
- string (APPEND _msg " "
871
- "Furthermore, use the MSVC command-line environment."
872
- )
873
- endif ()
874
- message (FATAL_ERROR "${_msg} " )
875
- endfunction ()
0 commit comments