Commit 4819ff96 authored by Zsolt Parragi's avatar Zsolt Parragi

Tests: fix failures with gnu mode clang on windows

    Root causes were:
    * Using incorrect conditions (assuming MSVC-like command line mode)
    * Trying to compile the MSVC STL in C++11 mode, when parts of it require
      C++14 or enabling MS extensions in clang.
    * Missing flush in a testcase using stdout in a dll and a main part
    with static crt
parent 26af0b25
......@@ -7,7 +7,7 @@ set(CMAKE_CXX_STANDARD 98)
# Clang/C2 in C++98 mode cannot properly handle some of MSVC headers
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND
CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC")
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD 14)
endif()
add_library(foo SHARED empty.cpp)
......
......@@ -7,7 +7,7 @@ add_library(testc1 STATIC libc1.c)
add_library(testc2 SHARED libc2.c)
add_executable (COnly conly.c foo.c foo.h)
target_link_libraries(COnly testc1 testc2)
if(MSVC_VERSION)
if(MSVC_VERSION AND NOT CMAKE_C_COMPILER_ID STREQUAL Clang OR "x${CMAKE_C_COMPILER_FRONTEND_VARIANT}" STREQUAL "xMSVC")
set_target_properties(COnly PROPERTIES
LINK_FLAGS " /NODEFAULTLIB:\"libcdg.lib\" /NODEFAULTLIB:\"libcmtg.lib\" /NODEFAULTLIB:\"foomsvcrt.lib\" /NODEFAULTLIB:\"libbar.lib\" /NODEFAULTLIB:\"libfooba.lib\"")
endif()
......
......@@ -446,6 +446,11 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND
set(CMAKE_CXX_STANDARD 11)
endif()
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND
CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "GNU")
set(CMAKE_CXX_STANDARD 14)
endif()
#
# Create the libs and the main exe
#
......
......@@ -403,6 +403,11 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND
set(CMAKE_CXX_STANDARD 11)
endif()
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND
CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "GNU")
set(CMAKE_CXX_STANDARD 14)
endif()
#
# Create the libs and the main exe
#
......
......@@ -18,7 +18,12 @@ if(NOT CTEST_CONFIGURATION_TYPE)
endif()
endforeach()
if(NOT CTEST_CONFIGURATION_TYPE)
set(CTEST_CONFIGURATION_TYPE NoConfig)
if("@CMAKE_C_COMPILER_ID@;@CMAKE_C_SIMULATE_ID@;@CMAKE_C_COMPILER_FRONTEND_VARIANT@" STREQUAL "Clang;MSVC;GNU")
# A valid configuration is required for this compiler in tests that do not set CMP0091 to NEW.
set(CTEST_CONFIGURATION_TYPE Debug)
else()
set(CTEST_CONFIGURATION_TYPE NoConfig)
endif()
endif()
message("Guessing configuration ${CTEST_CONFIGURATION_TYPE}")
endif()
......
......@@ -133,7 +133,9 @@ endif()
# for msvc the compiler version determines which c++11 features are available.
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC"
OR (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC"))
OR (CMAKE_CXX_COMPILER_ID STREQUAL "Clang"
AND "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC"
AND "x${CMAKE_CXX_COMPILER_FRONTEND_VARIANT}" 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,6 +5,17 @@ project(Plugin)
# We need proper C++98 support from the compiler
set(CMAKE_CXX_STANDARD 98)
# Clang/C2 in C++98 mode cannot properly handle some of MSVC headers
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND
CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC")
set(CMAKE_CXX_STANDARD 11)
endif()
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND
CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "GNU")
set(CMAKE_CXX_STANDARD 14)
endif()
# Test per-target output directory properties.
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${Plugin_BINARY_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${Plugin_BINARY_DIR}/lib/plugin)
......@@ -29,12 +40,6 @@ include_directories(
${Plugin_SOURCE_DIR}/include
)
# Clang/C2 in C++98 mode cannot properly handle some of MSVC headers
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND
CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC")
set(CMAKE_CXX_STANDARD 11)
endif()
# Create an executable that exports an API for use by plugins.
add_executable(example_exe src/example_exe.cxx)
set_target_properties(example_exe PROPERTIES
......
......@@ -51,6 +51,11 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND
set(CMAKE_CXX_STANDARD 11)
endif()
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND
CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "GNU")
set(CMAKE_CXX_STANDARD 14)
endif()
add_subdirectory(lib_shared_and_static)
if(CMAKE_SYSTEM_NAME MATCHES "AIX" AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU"
......
......@@ -6,4 +6,5 @@ __declspec(dllexport)
void greeting(void)
{
printf("Hello world!\n");
fflush(stdout);
}
......@@ -3,4 +3,5 @@
void greeting2(void)
{
printf("Hello world 2!\n");
fflush(stdout);
}
......@@ -5,7 +5,9 @@ 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" OR "x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC")
if (RunCMake_C_COMPILER_ID STREQUAL "MSVC"
OR ("x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC" AND
NOT CMAKE_C_COMPILER_ID STREQUAL "Clang" OR "x${CMAKE_C_COMPILER_FRONTEND_VARIANT}" STREQUAL "xMSVC"))
if (CMAKE_SIZEOF_VOID_P EQUAL 4)
set (undef_flag /INCLUDE:_func)
else()
......
......@@ -5,7 +5,9 @@ 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" OR "x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC")
if (RunCMake_C_COMPILER_ID STREQUAL "MSVC"
OR ("x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC" AND
NOT CMAKE_C_COMPILER_ID STREQUAL "Clang" OR "x${CMAKE_C_COMPILER_FRONTEND_VARIANT}" 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