Commit 9d2ab63a authored by Brad King's avatar Brad King Committed by Kitware Robot

Merge topic 'clangcl-fixes'

091afa73 Tests: Teach tests when to treat clang-cl as MSVC
00676890 Work around clang-cl breakage on make_unique/std::forward
d625dfcd Avoid compiling CMake itself as C++17 with Clang's MSVC ABI
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Merge-request: !2573
parents 20afd497 091afa73
Pipeline #129822 passed with stage
in 0 seconds
......@@ -2,8 +2,21 @@
#include <memory>
#include <unordered_map>
#ifdef _MSC_VER
# include <comdef.h>
#endif
int main()
{
std::unique_ptr<int> u(new int(0));
#ifdef _MSC_VER
// clang-cl has problems instantiating this constructor in C++17 mode
// error: indirection requires pointer operand ('const _GUID' invalid)
// return *_IID;
IUnknownPtr ptr{};
IDispatchPtr disp(ptr);
#endif
return *u;
}
......@@ -70,8 +70,9 @@ bool cmExportFileGenerator::GenerateImportFile()
std::unique_ptr<cmsys::ofstream> foutPtr;
if (this->AppendMode) {
// Open for append.
auto openmodeApp = std::ios::app;
foutPtr = cm::make_unique<cmsys::ofstream>(this->MainImportFile.c_str(),
std::ios::app);
openmodeApp);
} else {
// Generate atomically and with copy-if-different.
std::unique_ptr<cmGeneratedFileStream> ap(
......
......@@ -50,8 +50,9 @@ void cmExportLibraryDependenciesCommand::ConstFinalPass() const
// Use copy-if-different if not appending.
std::unique_ptr<cmsys::ofstream> foutPtr;
if (this->Append) {
const auto openmodeApp = std::ios::app;
foutPtr =
cm::make_unique<cmsys::ofstream>(this->Filename.c_str(), std::ios::app);
cm::make_unique<cmsys::ofstream>(this->Filename.c_str(), openmodeApp);
} else {
std::unique_ptr<cmGeneratedFileStream> ap(
new cmGeneratedFileStream(this->Filename, true));
......
......@@ -459,7 +459,7 @@ if(BUILD_TESTING)
set(runCxxDialectTest 1)
endif()
if(CMAKE_CXX_COMPILER_ID STREQUAL Clang
AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.4)
AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.4 AND NOT "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC")
if(NOT APPLE OR POLICY CMP0025)
set(runCxxDialectTest 1)
endif()
......
......@@ -57,7 +57,7 @@ else()
message("Unhandled Platform")
endif()
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang" AND NOT "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC")
check_cxx_compiler_flag("-x c++" HAVE_X_CXX)
if(NOT HAVE_X_CXX)
message(FATAL_ERROR "${CMAKE_CXX_COMPILER_ID} compiler flag '-x c++' check failed")
......
......@@ -407,7 +407,7 @@ endforeach()
unset(_configs)
if (((CMAKE_C_COMPILER_ID STREQUAL GNU AND CMAKE_C_COMPILER_VERSION VERSION_GREATER 4.4)
OR CMAKE_C_COMPILER_ID STREQUAL Clang)
OR (CMAKE_C_COMPILER_ID STREQUAL Clang AND NOT "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC"))
AND (CMAKE_GENERATOR STREQUAL "Unix Makefiles" OR CMAKE_GENERATOR STREQUAL "Ninja"))
include(CheckCXXCompilerFlag)
check_cxx_compiler_flag(-Wunused-variable run_sys_includes_test)
......
......@@ -2,7 +2,7 @@ cmake_minimum_required (VERSION 2.6)
project(IncludeDirectories)
if (((CMAKE_C_COMPILER_ID STREQUAL GNU AND CMAKE_C_COMPILER_VERSION VERSION_GREATER 4.4)
OR CMAKE_C_COMPILER_ID STREQUAL Clang OR CMAKE_C_COMPILER_ID STREQUAL AppleClang)
OR (CMAKE_C_COMPILER_ID STREQUAL Clang AND NOT "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC") OR CMAKE_C_COMPILER_ID STREQUAL AppleClang)
AND (CMAKE_GENERATOR STREQUAL "Unix Makefiles"
OR CMAKE_GENERATOR STREQUAL "Ninja"
OR (CMAKE_GENERATOR STREQUAL "Xcode" AND NOT XCODE_VERSION VERSION_LESS 6.0)))
......
......@@ -61,7 +61,7 @@ if (C_expected_features)
string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" COMPILER_VERSION_PATCH "${CMAKE_C_COMPILER_VERSION}")
if (CMAKE_C_COMPILER_ID STREQUAL "GNU"
OR CMAKE_C_COMPILER_ID STREQUAL "Clang"
OR (CMAKE_C_COMPILER_ID STREQUAL "Clang" AND NOT "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC")
OR CMAKE_C_COMPILER_ID STREQUAL "AppleClang"
OR CMAKE_C_COMPILER_ID STREQUAL "Intel")
add_executable(WriteCompilerDetectionHeader_C11 main.c)
......@@ -118,7 +118,7 @@ string(REGEX REPLACE "^[0-9]+\\.([0-9]+)\\.[0-9]+.*" "\\1" COMPILER_VERSION_MINO
string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" COMPILER_VERSION_PATCH "${CMAKE_CXX_COMPILER_VERSION}")
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU"
OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang"
OR (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND NOT "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC")
OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang"
OR CMAKE_CXX_COMPILER_ID STREQUAL "SunPro"
OR CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
......@@ -128,7 +128,7 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU"
endif()
# for msvc the compiler version determines which c++11 features are available.
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" OR "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC")
if(";${CMAKE_CXX_COMPILE_FEATURES};" MATCHES ";cxx_delegating_constructors;")
list(APPEND true_defs EXPECTED_COMPILER_CXX_DELEGATING_CONSTRUCTORS)
list(APPEND true_defs EXPECTED_COMPILER_CXX_VARIADIC_TEMPLATES)
......
......@@ -5,7 +5,7 @@ cmake_policy(SET CMP0054 NEW)
set (lib_name "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}lib${CMAKE_STATIC_LIBRARY_SUFFIX}")
if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
if (RunCMake_C_COMPILER_ID STREQUAL "MSVC")
if (RunCMake_C_COMPILER_ID STREQUAL "MSVC" OR "x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC")
if (CMAKE_SIZEOF_VOID_P EQUAL 4)
set (undef_flag /INCLUDE:_func)
else()
......
......@@ -5,7 +5,7 @@ cmake_policy(SET CMP0054 NEW)
set (lib_name "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}lib${CMAKE_STATIC_LIBRARY_SUFFIX}")
if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
if (RunCMake_C_COMPILER_ID STREQUAL "MSVC")
if (RunCMake_C_COMPILER_ID STREQUAL "MSVC" OR "x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC")
if (CMAKE_SIZEOF_VOID_P EQUAL 4)
set (undef_flag /INCLUDE:_func)
else()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment