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 | |
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')
-rw-r--r-- | Modules/CMakeCCompiler.cmake.in | 1 | ||||
-rw-r--r-- | Modules/CMakeCXXCompiler.cmake.in | 1 | ||||
-rw-r--r-- | Modules/CMakeDetermineCCompiler.cmake | 1 | ||||
-rw-r--r-- | Modules/CMakeDetermineCXXCompiler.cmake | 1 | ||||
-rw-r--r-- | Modules/CMakeDetermineCompilerId.cmake | 64 | ||||
-rw-r--r-- | Modules/CMakeFindBinUtils.cmake | 21 | ||||
-rw-r--r-- | Modules/Compiler/Clang-CXX.cmake | 13 | ||||
-rw-r--r-- | Modules/Platform/Windows-Clang.cmake | 117 |
8 files changed, 169 insertions, 50 deletions
diff --git a/Modules/CMakeCCompiler.cmake.in b/Modules/CMakeCCompiler.cmake.in index f473b0d..9b8d423 100644 --- a/Modules/CMakeCCompiler.cmake.in +++ b/Modules/CMakeCCompiler.cmake.in @@ -12,6 +12,7 @@ set(CMAKE_C11_COMPILE_FEATURES "@CMAKE_C11_COMPILE_FEATURES@") set(CMAKE_C_PLATFORM_ID "@CMAKE_C_PLATFORM_ID@") set(CMAKE_C_SIMULATE_ID "@CMAKE_C_SIMULATE_ID@") +set(CMAKE_C_COMPILER_FRONTEND_VARIANT "@CMAKE_C_COMPILER_FRONTEND_VARIANT@") set(CMAKE_C_SIMULATE_VERSION "@CMAKE_C_SIMULATE_VERSION@") @_SET_CMAKE_C_COMPILER_ARCHITECTURE_ID@ @SET_MSVC_C_ARCHITECTURE_ID@ diff --git a/Modules/CMakeCXXCompiler.cmake.in b/Modules/CMakeCXXCompiler.cmake.in index a1be02b..e7f0e70 100644 --- a/Modules/CMakeCXXCompiler.cmake.in +++ b/Modules/CMakeCXXCompiler.cmake.in @@ -14,6 +14,7 @@ set(CMAKE_CXX20_COMPILE_FEATURES "@CMAKE_CXX20_COMPILE_FEATURES@") set(CMAKE_CXX_PLATFORM_ID "@CMAKE_CXX_PLATFORM_ID@") set(CMAKE_CXX_SIMULATE_ID "@CMAKE_CXX_SIMULATE_ID@") +set(CMAKE_CXX_COMPILER_FRONTEND_VARIANT "@CMAKE_CXX_COMPILER_FRONTEND_VARIANT@") set(CMAKE_CXX_SIMULATE_VERSION "@CMAKE_CXX_SIMULATE_VERSION@") @_SET_CMAKE_CXX_COMPILER_ARCHITECTURE_ID@ @SET_MSVC_CXX_ARCHITECTURE_ID@ diff --git a/Modules/CMakeDetermineCCompiler.cmake b/Modules/CMakeDetermineCCompiler.cmake index 495d7e8..8be781a 100644 --- a/Modules/CMakeDetermineCCompiler.cmake +++ b/Modules/CMakeDetermineCCompiler.cmake @@ -114,7 +114,6 @@ 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 afcd956..00ef5b9 100644 --- a/Modules/CMakeDetermineCXXCompiler.cmake +++ b/Modules/CMakeDetermineCXXCompiler.cmake @@ -109,7 +109,6 @@ 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 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() diff --git a/Modules/CMakeFindBinUtils.cmake b/Modules/CMakeFindBinUtils.cmake index 35f75c9..0e84116 100644 --- a/Modules/CMakeFindBinUtils.cmake +++ b/Modules/CMakeFindBinUtils.cmake @@ -60,7 +60,9 @@ __resolve_tool_path(CMAKE_MT "${_CMAKE_TOOLCHAIN_LOCATION}" "Default Manifes set(_CMAKE_TOOL_VARS "") # if it's the MS C/CXX compiler, search for link -if("x${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_SIMULATE_ID}" STREQUAL "xMSVC" +if(("x${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_SIMULATE_ID}" STREQUAL "xMSVC" AND + ("x${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_FRONTEND_VARIANT}" STREQUAL "xMSVC" + OR NOT "x${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ID}" STREQUAL "xClang")) OR "x${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ID}" STREQUAL "xMSVC" OR (CMAKE_HOST_WIN32 AND "x${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ID}" STREQUAL "xPGI") OR (CMAKE_HOST_WIN32 AND "x${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ID}" STREQUAL "xNVIDIA") @@ -80,17 +82,26 @@ else() if(CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN) set(_CMAKE_TOOLCHAIN_LOCATION ${_CMAKE_TOOLCHAIN_LOCATION} ${CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN}/bin) endif() - find_program(CMAKE_AR NAMES ${_CMAKE_TOOLCHAIN_PREFIX}ar${_CMAKE_TOOLCHAIN_SUFFIX} HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) - find_program(CMAKE_RANLIB NAMES ${_CMAKE_TOOLCHAIN_PREFIX}ranlib HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) + if("${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ID}" STREQUAL Clang) + set(LLVM_OBJDUMP "llvm-objdump") + set(LLVM_LLD "ld.lld") + set(LLVM_RANLIB "llvm-ranlib") + set(LLVM_AR "llvm-ar") + endif() + + find_program(CMAKE_AR NAMES ${_CMAKE_TOOLCHAIN_PREFIX}ar${_CMAKE_TOOLCHAIN_SUFFIX} ${LLVM_AR} HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) + + find_program(CMAKE_RANLIB NAMES ${_CMAKE_TOOLCHAIN_PREFIX}ranlib ${LLVM_RANLIB} HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) if(NOT CMAKE_RANLIB) set(CMAKE_RANLIB : CACHE INTERNAL "noop for ranlib") endif() + find_program(CMAKE_STRIP NAMES ${_CMAKE_TOOLCHAIN_PREFIX}strip${_CMAKE_TOOLCHAIN_SUFFIX} HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) - find_program(CMAKE_LINKER NAMES ${_CMAKE_TOOLCHAIN_PREFIX}ld HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) + find_program(CMAKE_LINKER NAMES ${_CMAKE_TOOLCHAIN_PREFIX}ld ${LLVM_LLD} HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) find_program(CMAKE_NM NAMES ${_CMAKE_TOOLCHAIN_PREFIX}nm HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) - find_program(CMAKE_OBJDUMP NAMES ${_CMAKE_TOOLCHAIN_PREFIX}objdump HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) + find_program(CMAKE_OBJDUMP NAMES ${_CMAKE_TOOLCHAIN_PREFIX}objdump ${LLVM_OBJDUMP} HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) find_program(CMAKE_OBJCOPY NAMES ${_CMAKE_TOOLCHAIN_PREFIX}objcopy HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) list(APPEND _CMAKE_TOOL_VARS CMAKE_AR CMAKE_RANLIB CMAKE_STRIP CMAKE_LINKER CMAKE_NM CMAKE_OBJDUMP CMAKE_OBJCOPY) diff --git a/Modules/Compiler/Clang-CXX.cmake b/Modules/Compiler/Clang-CXX.cmake index c116078..17f3917 100644 --- a/Modules/Compiler/Clang-CXX.cmake +++ b/Modules/Compiler/Clang-CXX.cmake @@ -1,7 +1,7 @@ include(Compiler/Clang) __compiler_clang(CXX) -if(NOT "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC") +if("x${CMAKE_CXX_COMPILER_FRONTEND_VARIANT}" STREQUAL "xGNU") set(CMAKE_CXX_COMPILE_OPTIONS_VISIBILITY_INLINES_HIDDEN "-fvisibility-inlines-hidden") endif() @@ -10,7 +10,8 @@ if(APPLE AND NOT appleClangPolicy STREQUAL NEW) return() endif() -if(NOT "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC") + +if("x${CMAKE_CXX_COMPILER_FRONTEND_VARIANT}" STREQUAL "xGNU") if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 2.1) set(CMAKE_CXX98_STANDARD_COMPILE_OPTION "-std=c++98") set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION "-std=gnu++98") @@ -56,6 +57,14 @@ if(NOT "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC") unset(_clang_version_std17) + if("x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC") + # This clang++ is missing some features because of MSVC compatibility. + unset(CMAKE_CXX11_STANDARD__HAS_FULL_SUPPORT) + unset(CMAKE_CXX14_STANDARD__HAS_FULL_SUPPORT) + unset(CMAKE_CXX17_STANDARD__HAS_FULL_SUPPORT) + unset(CMAKE_CXX20_STANDARD__HAS_FULL_SUPPORT) + endif() + __compiler_check_default_language_standard(CXX 2.1 98) elseif(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 3.9 AND CMAKE_CXX_SIMULATE_VERSION VERSION_GREATER_EQUAL 19.0) diff --git a/Modules/Platform/Windows-Clang.cmake b/Modules/Platform/Windows-Clang.cmake index 007ae53..b317da6 100644 --- a/Modules/Platform/Windows-Clang.cmake +++ b/Modules/Platform/Windows-Clang.cmake @@ -8,13 +8,120 @@ if(__WINDOWS_CLANG) endif() set(__WINDOWS_CLANG 1) +macro(__windows_compiler_clang_gnu lang) + set(CMAKE_LIBRARY_PATH_FLAG "-L") + set(CMAKE_LINK_LIBRARY_FLAG "-l") + + set(CMAKE_IMPORT_LIBRARY_PREFIX "") + set(CMAKE_SHARED_LIBRARY_PREFIX "") + set(CMAKE_SHARED_MODULE_PREFIX "") + set(CMAKE_STATIC_LIBRARY_PREFIX "") + set(CMAKE_EXECUTABLE_SUFFIX ".exe") + set(CMAKE_IMPORT_LIBRARY_SUFFIX ".lib") + set(CMAKE_SHARED_LIBRARY_SUFFIX ".dll") + set(CMAKE_SHARED_MODULE_SUFFIX ".dll") + set(CMAKE_STATIC_LIBRARY_SUFFIX ".lib") + set(CMAKE_DEPFILE_FLAGS_${lang} "-MD -MT <OBJECT> -MF <DEPFILE>") + + set(CMAKE_FIND_LIBRARY_PREFIXES "lib" "") + set(CMAKE_FIND_LIBRARY_SUFFIXES ".dll" ".dll.a" ".a" ".lib") + set(CMAKE_SUPPORT_WINDOWS_EXPORT_ALL_SYMBOLS 1) + set (CMAKE_LINK_DEF_FILE_FLAG "-Xlinker /DEF:") + + if("${CMAKE_${lang}_SIMULATE_VERSION}" MATCHES "^([0-9]+)\\.([0-9]+)") + math(EXPR MSVC_VERSION "${CMAKE_MATCH_1}*100 + ${CMAKE_MATCH_2}") + endif() + + # No -fPIC on Windows + set(CMAKE_${lang}_COMPILE_OPTIONS_PIC "") + set(CMAKE_${lang}_COMPILE_OPTIONS_PIE "") + set(_CMAKE_${lang}_PIE_MAY_BE_SUPPORTED_BY_LINKER NO) + set(CMAKE_${lang}_LINK_OPTIONS_PIE "") + set(CMAKE_${lang}_LINK_OPTIONS_NO_PIE "") + set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS "") + + set(CMAKE_${lang}_USE_RESPONSE_FILE_FOR_OBJECTS 1) + set(CMAKE_${lang}_USE_RESPONSE_FILE_FOR_LIBRARIES 1) + set(CMAKE_${lang}_USE_RESPONSE_FILE_FOR_INCLUDES 1) + + # Create archiving rules to support large object file lists for static libraries. + set(CMAKE_${lang}_ARCHIVE_CREATE "<CMAKE_AR> qc <TARGET> <LINK_FLAGS> <OBJECTS>") + set(CMAKE_${lang}_ARCHIVE_APPEND "<CMAKE_AR> q <TARGET> <LINK_FLAGS> <OBJECTS>") + set(CMAKE_${lang}_ARCHIVE_FINISH "<CMAKE_RANLIB> <TARGET>") + set(CMAKE_${lang}_CREATE_SHARED_LIBRARY + "<CMAKE_${lang}_COMPILER> -nostartfiles -nostdlib <CMAKE_SHARED_LIBRARY_${lang}_FLAGS> <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS> -o <TARGET> ${CMAKE_GNULD_IMAGE_VERSION} -Xlinker /implib:<TARGET_IMPLIB> -Xlinker /pdb:<TARGET_PDB> -Xlinker /version:<TARGET_VERSION_MAJOR>.<TARGET_VERSION_MINOR> <OBJECTS> <LINK_LIBRARIES>") + set(CMAKE_${lang}_CREATE_SHARED_MODULE ${CMAKE_${lang}_CREATE_SHARED_LIBRARY}) + set(CMAKE_${lang}_LINK_EXECUTABLE + "<CMAKE_${lang}_COMPILER> -nostartfiles -nostdlib <FLAGS> <CMAKE_${lang}_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> -Xlinker /implib:<TARGET_IMPLIB> -Xlinker /pdb:<TARGET_PDB> -Xlinker /version:<TARGET_VERSION_MAJOR>.<TARGET_VERSION_MINOR> ${CMAKE_GNULD_IMAGE_VERSION} <LINK_LIBRARIES>") + + set(CMAKE_${lang}_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreaded -Xclang -flto-visibility-public-std -D_MT -Xclang --dependent-lib=libcmt) + set(CMAKE_${lang}_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDLL -D_DLL -D_MT -Xclang --dependent-lib=msvcrt) + set(CMAKE_${lang}_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDebug -D_DEBUG -Xclang -flto-visibility-public-std -D_MT -Xclang --dependent-lib=libcmtd) + set(CMAKE_${lang}_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDebugDLL -D_DEBUG -D_DLL -D_MT -Xclang --dependent-lib=msvcrtd) + + if(CMAKE_MSVC_RUNTIME_LIBRARY_DEFAULT) + set(__ADDED_FLAGS "") + set(__ADDED_FLAGS_DEBUG "") + else() + set(__ADDED_FLAGS_DEBUG "-D_DEBUG -D_DLL -D_MT -Xclang --dependent-lib=msvcrtd") + set(__ADDED_FLAGS "-D_DLL -D_MT -Xclang --dependent-lib=msvcrt") + endif() + + string(APPEND CMAKE_${lang}_FLAGS_DEBUG_INIT " -g -Xclang -gcodeview -O0 ${__ADDED_FLAGS_DEBUG}") + string(APPEND CMAKE_${lang}_FLAGS_MINSIZEREL_INIT " -Os -DNDEBUG ${__ADDED_FLAGS}") + string(APPEND CMAKE_${lang}_FLAGS_RELEASE_INIT " -O3 -DNDEBUG ${__ADDED_FLAGS}") + string(APPEND CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT " -O2 -g -DNDEBUG -Xclang -gcodeview ${__ADDED_FLAGS}") + set(CMAKE_INCLUDE_SYSTEM_FLAG_${lang} "-isystem ") + + unset(__ADDED_FLAGS) + unset(__ADDED_FLAGS_DEBUG) + string(TOLOWER "${CMAKE_BUILD_TYPE}" BUILD_TYPE_LOWER) + set(CMAKE_${lang}_STANDARD_LIBRARIES_INIT "-lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 -loldnames") + + enable_language(RC) +endmacro() + if("x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC" OR "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC") - include(Platform/Windows-MSVC) - macro(__windows_compiler_clang lang) - set(_COMPILE_${lang} "${_COMPILE_${lang}_MSVC}") - __windows_compiler_msvc(${lang}) - endmacro() + + if ( DEFINED CMAKE_C_COMPILER_ID AND DEFINED CMAKE_CXX_COMPILER_ID + AND NOT "x${CMAKE_C_COMPILER_ID}" STREQUAL "x${CMAKE_CXX_COMPILER_ID}") + message(FATAL_ERROR "The current configuration mixes Clang and MSVC or " + "some other CL compatible compiler tool. This is not supported. " + "Use either clang or MSVC as both C and C++ compilers.") + endif() + + if ( DEFINED CMAKE_C_COMPILER_FRONTEND_VARIANT AND DEFINED CMAKE_CXX_COMPILER_FRONTEND_VARIANT + AND NOT "x${CMAKE_C_COMPILER_FRONTEND_VARIANT}" STREQUAL "x${CMAKE_CXX_COMPILER_FRONTEND_VARIANT}") + message(FATAL_ERROR "The current configuration uses the Clang compiler " + "tool with mixed frontend variants, both the GNU and in MSVC CL " + "like variants. This is not supported. Use either clang/clang++ " + "or clang-cl as both C and C++ compilers.") + endif() + + if ( "x${CMAKE_CXX_COMPILER_FRONTEND_VARIANT}" STREQUAL "xMSVC" OR "x${CMAKE_C_COMPILER_FRONTEND_VARIANT}" STREQUAL "xMSVC" ) + include(Platform/Windows-MSVC) + + macro(__windows_compiler_clang lang) + set(_COMPILE_${lang} "${_COMPILE_${lang}_MSVC}") + __windows_compiler_msvc(${lang}) + endmacro() + else() + cmake_policy(GET CMP0091 __WINDOWS_CLANG_CMP0091) + if(__WINDOWS_CLANG_CMP0091 STREQUAL "NEW") + set(CMAKE_MSVC_RUNTIME_LIBRARY_DEFAULT "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL") + else() + set(CMAKE_MSVC_RUNTIME_LIBRARY_DEFAULT "") + endif() + unset(__WINDOWS_CLANG_CMP0091) + + set(CMAKE_BUILD_TYPE_INIT Debug) + + macro(__windows_compiler_clang lang) + __windows_compiler_clang_gnu(${lang}) + endmacro() + endif() + else() include(Platform/Windows-GNU) macro(__windows_compiler_clang lang) |