Tests: fix Module.GenerateExportHeader building on Clang/C2

This commit is contained in:
Mariusz Pluciński 2016-02-19 22:17:00 +01:00 committed by Brad King
parent 123b7e1335
commit ada3736c78
3 changed files with 93 additions and 1 deletions

View File

@ -1,4 +1,5 @@
cmake_minimum_required(VERSION 2.8.5 FATAL_ERROR) cmake_minimum_required(VERSION 2.8.5 FATAL_ERROR)
cmake_policy(SET CMP0054 NEW)
project(GenerateExportHeader) project(GenerateExportHeader)
@ -66,6 +67,12 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL HP AND
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -AA") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -AA")
endif () endif ()
# 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()
add_subdirectory(lib_shared_and_static) add_subdirectory(lib_shared_and_static)
add_compiler_export_flags() add_compiler_export_flags()
@ -107,7 +114,10 @@ add_executable(GenerateExportHeader exportheader_test.cpp)
target_link_libraries(GenerateExportHeader ${link_libraries}) target_link_libraries(GenerateExportHeader ${link_libraries})
if (WIN32 OR CYGWIN) if (WIN32 OR CYGWIN)
if(MSVC AND COMPILER_HAS_DEPRECATED) if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND
CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC")
set(_platform Win32-Clang)
elseif(MSVC AND COMPILER_HAS_DEPRECATED)
set(_platform Win32) set(_platform Win32)
elseif((MINGW OR CYGWIN) AND COMPILER_HAS_DEPRECATED) elseif((MINGW OR CYGWIN) AND COMPILER_HAS_DEPRECATED)
set(_platform MinGW) set(_platform MinGW)

View File

@ -0,0 +1,41 @@
#ifndef LIBSHARED_EXPORT_H
#define LIBSHARED_EXPORT_H
#ifdef LIBSHARED_STATIC_DEFINE
# define LIBSHARED_EXPORT
# define LIBSHARED_NO_EXPORT
#else
# ifndef LIBSHARED_EXPORT
# ifdef libshared_EXPORTS
/* We are building this library */
# define LIBSHARED_EXPORT __declspec(dllexport)
# else
/* We are using this library */
# define LIBSHARED_EXPORT __declspec(dllimport)
# endif
# endif
# ifndef LIBSHARED_NO_EXPORT
# define LIBSHARED_NO_EXPORT
# endif
#endif
#ifndef LIBSHARED_DEPRECATED
# define LIBSHARED_DEPRECATED __attribute__ ((__deprecated__))
#endif
#ifndef LIBSHARED_DEPRECATED_EXPORT
# define LIBSHARED_DEPRECATED_EXPORT LIBSHARED_EXPORT LIBSHARED_DEPRECATED
#endif
#ifndef LIBSHARED_DEPRECATED_NO_EXPORT
# define LIBSHARED_DEPRECATED_NO_EXPORT LIBSHARED_NO_EXPORT LIBSHARED_DEPRECATED
#endif
#define DEFINE_NO_DEPRECATED 0
#if DEFINE_NO_DEPRECATED
# define LIBSHARED_NO_DEPRECATED
#endif
#endif

View File

@ -0,0 +1,41 @@
#ifndef LIBSTATIC_EXPORT_H
#define LIBSTATIC_EXPORT_H
#ifdef LIBSTATIC_STATIC_DEFINE
# define LIBSTATIC_EXPORT
# define LIBSTATIC_NO_EXPORT
#else
# ifndef LIBSTATIC_EXPORT
# ifdef libstatic_EXPORTS
/* We are building this library */
# define LIBSTATIC_EXPORT
# else
/* We are using this library */
# define LIBSTATIC_EXPORT
# endif
# endif
# ifndef LIBSTATIC_NO_EXPORT
# define LIBSTATIC_NO_EXPORT
# endif
#endif
#ifndef LIBSTATIC_DEPRECATED
# define LIBSTATIC_DEPRECATED __attribute__ ((__deprecated__))
#endif
#ifndef LIBSTATIC_DEPRECATED_EXPORT
# define LIBSTATIC_DEPRECATED_EXPORT LIBSTATIC_EXPORT LIBSTATIC_DEPRECATED
#endif
#ifndef LIBSTATIC_DEPRECATED_NO_EXPORT
# define LIBSTATIC_DEPRECATED_NO_EXPORT LIBSTATIC_NO_EXPORT LIBSTATIC_DEPRECATED
#endif
#define DEFINE_NO_DEPRECATED 0
#if DEFINE_NO_DEPRECATED
# define LIBSTATIC_NO_DEPRECATED
#endif
#endif