diff options
author | Brad King <brad.king@kitware.com> | 2019-05-29 13:21:53 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2019-05-29 13:22:12 (GMT) |
commit | 067a4f484b1e2f650918d90051653b5c434c77a2 (patch) | |
tree | e0d9e8dd16e4518988067865f3f922f13a512b71 /Modules/CMakeDetermineCompilerId.cmake | |
parent | 8b42d560028b8da0a3cf7e1a14962f2245d21227 (diff) | |
parent | 74829f01b13de0031e659bf8dac3e6672fbfa77b (diff) | |
download | CMake-067a4f484b1e2f650918d90051653b5c434c77a2.zip CMake-067a4f484b1e2f650918d90051653b5c434c77a2.tar.gz CMake-067a4f484b1e2f650918d90051653b5c434c77a2.tar.bz2 |
Merge topic 'clang-gnulike-support'
74829f01b1 Help: Add notes for topic 'clang-gnulike-support'
19669abe1d Tests: handle string escaping differences with NMake+clang
a2a90f41e3 Tests: require C++14 for the Tutorial
4819ff9647 Tests: fix failures with gnu mode clang on windows
26af0b25e7 cmake: use correct stack size with gnu mode clang on windows
d44c0db0b2 clang: setup correct configuration in gnu mode
b7d5ef23e9 cmGlobalNinjaGenerator: use gnu compatible paths with clang in gnu mode
3d0210d8dc binutils: add the llvm-* variants to the tool lists.
...
Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: Francesco Bertolaccini <francesco@bertolaccini.dev>
Acked-by: Stanislav Ershov <digital.stream.of.mind@gmail.com>
Acked-by: Saleem Abdulrasool <compnerd@compnerd.org>
Merge-request: !2992
Diffstat (limited to 'Modules/CMakeDetermineCompilerId.cmake')
-rw-r--r-- | Modules/CMakeDetermineCompilerId.cmake | 64 |
1 files changed, 28 insertions, 36 deletions
diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake index c7e5685..6083358 100644 --- a/Modules/CMakeDetermineCompilerId.cmake +++ b/Modules/CMakeDetermineCompilerId.cmake @@ -136,6 +136,31 @@ function(CMAKE_DETERMINE_COMPILER_ID lang flagvar src) set(CMAKE_${lang}_CL_SHOWINCLUDES_PREFIX "") endif() + set(_variant "") + if("x${CMAKE_${lang}_COMPILER_ID}" STREQUAL "xClang") + if(CMAKE_HOST_WIN32 AND "x${CMAKE_${lang}_SIMULATE_ID}" STREQUAL "xMSVC") + if(CMAKE_GENERATOR MATCHES "Visual Studio") + set(CMAKE_${lang}_COMPILER_FRONTEND_VARIANT "MSVC") + else() + # Test whether an MSVC-like command-line option works. + execute_process(COMMAND "${CMAKE_${lang}_COMPILER}" -? + RESULT_VARIABLE _clang_result + OUTPUT_VARIABLE _clang_stdout + ERROR_VARIABLE _clang_stderr) + if(_clang_result EQUAL 0) + set(CMAKE_${lang}_COMPILER_FRONTEND_VARIANT "MSVC") + else() + set(CMAKE_${lang}_COMPILER_FRONTEND_VARIANT "GNU") + endif() + endif() + set(_variant " with ${CMAKE_${lang}_COMPILER_FRONTEND_VARIANT}-like command-line") + else() + set(CMAKE_${lang}_COMPILER_FRONTEND_VARIANT "GNU") + endif() + else() + set(CMAKE_${lang}_COMPILER_FRONTEND_VARIANT "") + endif() + # Display the final identification result. if(CMAKE_${lang}_COMPILER_ID) if(CMAKE_${lang}_COMPILER_VERSION) @@ -149,9 +174,10 @@ function(CMAKE_DETERMINE_COMPILER_ID lang flagvar src) set(_archid "") endif() message(STATUS "The ${lang} compiler identification is " - "${CMAKE_${lang}_COMPILER_ID}${_archid}${_version}") + "${CMAKE_${lang}_COMPILER_ID}${_archid}${_version}${_variant}") unset(_archid) unset(_version) + unset(_variant) else() message(STATUS "The ${lang} compiler identification is unknown") endif() @@ -163,6 +189,7 @@ function(CMAKE_DETERMINE_COMPILER_ID lang flagvar src) PARENT_SCOPE) set(CMAKE_${lang}_XCODE_ARCHS "${CMAKE_${lang}_XCODE_ARCHS}" PARENT_SCOPE) set(CMAKE_${lang}_CL_SHOWINCLUDES_PREFIX "${CMAKE_${lang}_CL_SHOWINCLUDES_PREFIX}" PARENT_SCOPE) + set(CMAKE_${lang}_COMPILER_FRONTEND_VARIANT "${CMAKE_${lang}_COMPILER_FRONTEND_VARIANT}" PARENT_SCOPE) set(CMAKE_${lang}_COMPILER_VERSION "${CMAKE_${lang}_COMPILER_VERSION}" PARENT_SCOPE) set(CMAKE_${lang}_COMPILER_VERSION_INTERNAL "${CMAKE_${lang}_COMPILER_VERSION_INTERNAL}" PARENT_SCOPE) set(CMAKE_${lang}_COMPILER_WRAPPER "${CMAKE_${lang}_COMPILER_WRAPPER}" PARENT_SCOPE) @@ -864,38 +891,3 @@ function(CMAKE_DETERMINE_MSVC_SHOWINCLUDES_PREFIX lang userflags) set(CMAKE_${lang}_CL_SHOWINCLUDES_PREFIX "" PARENT_SCOPE) endif() endfunction() - -function(CMAKE_DIAGNOSE_UNSUPPORTED_CLANG lang envvar) - if(NOT CMAKE_HOST_WIN32 OR CMAKE_GENERATOR MATCHES "Visual Studio" OR - NOT "${CMAKE_${lang}_COMPILER_ID};${CMAKE_${lang}_SIMULATE_ID}" STREQUAL "Clang;MSVC") - return() - endif() - - # Test whether an MSVC-like command-line option works. - execute_process(COMMAND "${CMAKE_${lang}_COMPILER}" -? - RESULT_VARIABLE _clang_result - OUTPUT_VARIABLE _clang_stdout - ERROR_VARIABLE _clang_stderr) - if(_clang_result EQUAL 0) - return() - endif() - - # Help the user configure the environment to use the MSVC-like Clang. - string(CONCAT _msg - "The Clang compiler tool\n" - " \"${CMAKE_${lang}_COMPILER}\"\n" - "targets the MSVC ABI but has a GNU-like command-line interface. " - "This is not supported. " - "Use 'clang-cl' instead, e.g. by setting '${envvar}=clang-cl' in the environment." - ) - execute_process(COMMAND rc -help - RESULT_VARIABLE _rc_result - OUTPUT_VARIABLE _rc_stdout - ERROR_VARIABLE _rc_stderr) - if(NOT _rc_result EQUAL 0) - string(APPEND _msg " " - "Furthermore, use the MSVC command-line environment." - ) - endif() - message(FATAL_ERROR "${_msg}") -endfunction() |