summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2017-10-11 13:28:09 (GMT)
committerBrad King <brad.king@kitware.com>2017-10-11 13:28:09 (GMT)
commit609a6fe96d9dc39ee80a5504be34570c09f62cca (patch)
tree99df1ff279580d5f283ff29ea3012bd244d75f68
parent155c1505a587b4f4861c9badf7ac8b3b5ddcffdc (diff)
parentb6d3a1c09a796ec0c29074c387953fb88ebfe874 (diff)
downloadCMake-609a6fe96d9dc39ee80a5504be34570c09f62cca.zip
CMake-609a6fe96d9dc39ee80a5504be34570c09f62cca.tar.gz
CMake-609a6fe96d9dc39ee80a5504be34570c09f62cca.tar.bz2
Merge branch 'clang-msvc-help' into release-3.10
Merge-request: !1373
-rw-r--r--Modules/CMakeDetermineCCompiler.cmake1
-rw-r--r--Modules/CMakeDetermineCXXCompiler.cmake1
-rw-r--r--Modules/CMakeDetermineCompilerId.cmake35
3 files changed, 37 insertions, 0 deletions
diff --git a/Modules/CMakeDetermineCCompiler.cmake b/Modules/CMakeDetermineCCompiler.cmake
index fcbda20..4e56ce1 100644
--- a/Modules/CMakeDetermineCCompiler.cmake
+++ b/Modules/CMakeDetermineCCompiler.cmake
@@ -110,6 +110,7 @@ if(NOT CMAKE_C_COMPILER_ID_RUN)
include(${CMAKE_ROOT}/Modules/CMakeDetermineCompilerId.cmake)
CMAKE_DETERMINE_COMPILER_ID(C CFLAGS CMakeCCompilerId.c)
+ CMAKE_DIAGNOSE_UNSUPPORTED_CLANG(C CC)
# Set old compiler and platform id variables.
if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
diff --git a/Modules/CMakeDetermineCXXCompiler.cmake b/Modules/CMakeDetermineCXXCompiler.cmake
index 8c33eb6..4541844 100644
--- a/Modules/CMakeDetermineCXXCompiler.cmake
+++ b/Modules/CMakeDetermineCXXCompiler.cmake
@@ -105,6 +105,7 @@ if(NOT CMAKE_CXX_COMPILER_ID_RUN)
include(${CMAKE_ROOT}/Modules/CMakeDetermineCompilerId.cmake)
CMAKE_DETERMINE_COMPILER_ID(CXX CXXFLAGS CMakeCXXCompilerId.cpp)
+ CMAKE_DIAGNOSE_UNSUPPORTED_CLANG(CXX CXX)
# Set old compiler and platform id variables.
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake
index 7efe739..347106e 100644
--- a/Modules/CMakeDetermineCompilerId.cmake
+++ b/Modules/CMakeDetermineCompilerId.cmake
@@ -735,3 +735,38 @@ 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 a GNU-like command-line option works.
+ execute_process(COMMAND "${CMAKE_${lang}_COMPILER}" --version
+ RESULT_VARIABLE _clang_result
+ OUTPUT_VARIABLE _clang_stdout
+ ERROR_VARIABLE _clang_stderr)
+ if(NOT _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()