Skip to content

Commit

Permalink
ORC-331. Initial support of MSVC
Browse files Browse the repository at this point in the history
Fixes #240

Signed-off-by: Owen O'Malley <omalley@apache.org>
  • Loading branch information
rip-nsk authored and omalley committed Apr 23, 2018
1 parent c0f3bcf commit 6c67bc8
Show file tree
Hide file tree
Showing 10 changed files with 83 additions and 42 deletions.
21 changes: 8 additions & 13 deletions CMakeLists.txt
Expand Up @@ -64,9 +64,11 @@ INCLUDE(ExternalProject)
#
# Compiler specific flags
#
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O3 -g -DNDEBUG")
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG")
if (NOT MSVC)
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O3 -g -DNDEBUG")
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG")
endif ()
message(STATUS "compiler ${CMAKE_CXX_COMPILER_ID} version ${CMAKE_CXX_COMPILER_VERSION}")
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
set (CXX11_FLAGS "-std=c++11")
Expand All @@ -87,16 +89,9 @@ elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
elseif (MSVC)
add_definitions (-D_SCL_SECURE_NO_WARNINGS)
add_definitions (-D_CRT_SECURE_NO_WARNINGS)
# TODO: We assume MSVC debug mode. In the future, set these flags
# appropriately for all build mode.
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /MTd")
set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /NODEFAULTLIB:libc.lib")
set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /NODEFAULTLIB:libcmt.lib")
set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /NODEFAULTLIB:msvcrt.lib")
set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /NODEFAULTLIB:libcd.lib")

set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /NODEFAULTLIB:msvcrtd.lib")
add_definitions (-D_CRT_NONSTDC_NO_DEPRECATE) # The POSIX name for this item is deprecated
set (WARN_FLAGS "${WARN_FLAGS} -wd4521") # multiple copy constructors specified
set (WARN_FLAGS "${WARN_FLAGS} -wd4146") # unary minus operator applied to unsigned type, result still unsigned
endif ()

enable_testing()
Expand Down
5 changes: 5 additions & 0 deletions c++/src/Adaptor.hh.in
Expand Up @@ -65,6 +65,9 @@
#elif defined(__GNUC__)
#define DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push")
#define DIAGNOSTIC_POP _Pragma("GCC diagnostic pop")
#elif defined(_MSC_VER)
#define DIAGNOSTIC_PUSH __pragma(warning(push))
#define DIAGNOSTIC_POP __pragma(warning(pop))
#else
#error("Unknown compiler")
#endif
Expand All @@ -79,6 +82,8 @@
#define DIAGNOSTIC_IGNORE(XXX) PRAGMA(clang diagnostic ignored XXX)
#elif defined(__GNUC__)
#define DIAGNOSTIC_IGNORE(XXX) PRAGMA(GCC diagnostic ignored XXX)
#elif defined(_MSC_VER)
#define DIAGNOSTIC_IGNORE(XXX) __pragma(warning(disable : XXX))
#else
#define DIAGNOSTIC_IGNORE(XXX)
#endif
Expand Down
4 changes: 4 additions & 0 deletions c++/src/CMakeLists.txt
Expand Up @@ -51,6 +51,10 @@ CHECK_CXX_SOURCE_COMPILES("
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored \"-Wdeprecated\"
#pragma GCC diagnostic pop
#elif defined(_MSC_VER)
#pragma warning( push )
#pragma warning( disable : 4996 )
#pragma warning( pop )
#else
unknownCompiler!
#endif
Expand Down
10 changes: 8 additions & 2 deletions c++/src/Compression.cc
Expand Up @@ -266,7 +266,10 @@ namespace orc {
}

DIAGNOSTIC_PUSH
DIAGNOSTIC_IGNORE("-Wold-style-cast")

#if defined(__GNUC__) || defined(__clang__)
DIAGNOSTIC_IGNORE("-Wold-style-cast")
#endif

void ZlibCompressionStream::init() {
strm.zalloc = nullptr;
Expand Down Expand Up @@ -370,7 +373,10 @@ DIAGNOSTIC_PUSH
};

DIAGNOSTIC_PUSH
DIAGNOSTIC_IGNORE("-Wold-style-cast")

#if defined(__GNUC__) || defined(__clang__)
DIAGNOSTIC_IGNORE("-Wold-style-cast")
#endif

ZlibDecompressionStream::ZlibDecompressionStream
(std::unique_ptr<SeekableInputStream> inStream,
Expand Down
4 changes: 3 additions & 1 deletion c++/src/wrap/coded-stream-wrapper.h
Expand Up @@ -24,7 +24,9 @@ DIAGNOSTIC_PUSH
DIAGNOSTIC_IGNORE("-Wreserved-id-macro")
#endif

DIAGNOSTIC_IGNORE("-Wconversion")
#if defined(__GNUC__) || defined(__clang__)
DIAGNOSTIC_IGNORE("-Wconversion")
#endif

#include <google/protobuf/io/coded_stream.h>

Expand Down
15 changes: 9 additions & 6 deletions c++/src/wrap/gmock.h
Expand Up @@ -21,12 +21,15 @@
#include "Adaptor.hh"

DIAGNOSTIC_PUSH
DIAGNOSTIC_IGNORE("-Wdeprecated")
DIAGNOSTIC_IGNORE("-Wmissing-noreturn")
DIAGNOSTIC_IGNORE("-Wpadded")
DIAGNOSTIC_IGNORE("-Wsign-compare")
DIAGNOSTIC_IGNORE("-Wsign-conversion")
DIAGNOSTIC_IGNORE("-Wundef")

#if defined(__GNUC__) || defined(__clang__)
DIAGNOSTIC_IGNORE("-Wdeprecated")
DIAGNOSTIC_IGNORE("-Wmissing-noreturn")
DIAGNOSTIC_IGNORE("-Wpadded")
DIAGNOSTIC_IGNORE("-Wsign-compare")
DIAGNOSTIC_IGNORE("-Wsign-conversion")
DIAGNOSTIC_IGNORE("-Wundef")
#endif

#ifdef __clang__
DIAGNOSTIC_IGNORE("-Wnull-dereference")
Expand Down
21 changes: 15 additions & 6 deletions c++/src/wrap/gtest-wrapper.h
Expand Up @@ -20,7 +20,9 @@
// we need to disable a whole set of warnings as we include gtest.h
// restore most of the warnings after the file is loaded.

DIAGNOSTIC_IGNORE("-Wsign-compare")
#if defined(__GNUC__) || defined(__clang__)
DIAGNOSTIC_IGNORE("-Wsign-compare")
#endif

#ifdef __clang__
DIAGNOSTIC_IGNORE("-Wconversion-null")
Expand All @@ -33,18 +35,25 @@ DIAGNOSTIC_IGNORE("-Wsign-compare")

DIAGNOSTIC_PUSH

DIAGNOSTIC_IGNORE("-Wdeprecated")
DIAGNOSTIC_IGNORE("-Wmissing-noreturn")
DIAGNOSTIC_IGNORE("-Wpadded")
DIAGNOSTIC_IGNORE("-Wsign-compare")
DIAGNOSTIC_IGNORE("-Wundef")
#if defined(__GNUC__) || defined(__clang__)
DIAGNOSTIC_IGNORE("-Wdeprecated")
DIAGNOSTIC_IGNORE("-Wmissing-noreturn")
DIAGNOSTIC_IGNORE("-Wpadded")
DIAGNOSTIC_IGNORE("-Wsign-compare")
DIAGNOSTIC_IGNORE("-Wundef")
#endif

#ifdef __clang__
DIAGNOSTIC_IGNORE("-Wshift-sign-overflow")
DIAGNOSTIC_IGNORE("-Wused-but-marked-unused")
DIAGNOSTIC_IGNORE("-Wweak-vtables")
#endif

#ifdef _MSC_VER
DIAGNOSTIC_IGNORE(4146) // unary minus operator applied to unsigned type, result still unsigned
DIAGNOSTIC_IGNORE(4805) // '==': unsafe mix of type 'const bool' and type 'const int64_t' in operation
#endif

#include "gtest/gtest.h"

DIAGNOSTIC_POP
Expand Down
21 changes: 14 additions & 7 deletions c++/src/wrap/orc-proto-wrapper.cc
Expand Up @@ -14,13 +14,15 @@

#include "Adaptor.hh"

DIAGNOSTIC_IGNORE("-Wconversion")
DIAGNOSTIC_IGNORE("-Wdeprecated")
DIAGNOSTIC_IGNORE("-Wignored-qualifiers")
DIAGNOSTIC_IGNORE("-Wpadded")
DIAGNOSTIC_IGNORE("-Wsign-compare")
DIAGNOSTIC_IGNORE("-Wsign-conversion")
DIAGNOSTIC_IGNORE("-Wunused-parameter")
#if defined(__GNUC__) || defined(__clang__)
DIAGNOSTIC_IGNORE("-Wconversion")
DIAGNOSTIC_IGNORE("-Wdeprecated")
DIAGNOSTIC_IGNORE("-Wignored-qualifiers")
DIAGNOSTIC_IGNORE("-Wpadded")
DIAGNOSTIC_IGNORE("-Wsign-compare")
DIAGNOSTIC_IGNORE("-Wsign-conversion")
DIAGNOSTIC_IGNORE("-Wunused-parameter")
#endif

#ifdef __clang__
DIAGNOSTIC_IGNORE("-Wdisabled-macro-expansion")
Expand All @@ -34,4 +36,9 @@ DIAGNOSTIC_IGNORE("-Wunused-parameter")
DIAGNOSTIC_IGNORE("-Wzero-as-null-pointer-constant")
#endif

#if defined(_MSC_VER)
DIAGNOSTIC_IGNORE(4146) // unary minus operator applied to unsigned type, result still unsigned
DIAGNOSTIC_IGNORE(4800) // forcing value to bool 'true' or 'false'
#endif

#include "orc_proto.pb.cc"
16 changes: 12 additions & 4 deletions c++/src/wrap/orc-proto-wrapper.hh
Expand Up @@ -18,10 +18,13 @@
#include "Adaptor.hh"

DIAGNOSTIC_PUSH
DIAGNOSTIC_IGNORE("-Wconversion")
DIAGNOSTIC_IGNORE("-Wdeprecated")
DIAGNOSTIC_IGNORE("-Wsign-conversion")
DIAGNOSTIC_IGNORE("-Wunused-parameter")

#if defined(__GNUC__) || defined(__clang__)
DIAGNOSTIC_IGNORE("-Wconversion")
DIAGNOSTIC_IGNORE("-Wdeprecated")
DIAGNOSTIC_IGNORE("-Wsign-conversion")
DIAGNOSTIC_IGNORE("-Wunused-parameter")
#endif

#ifdef __clang__
DIAGNOSTIC_IGNORE("-Wnested-anon-types")
Expand All @@ -32,6 +35,11 @@ DIAGNOSTIC_IGNORE("-Wunused-parameter")
DIAGNOSTIC_IGNORE("-Wzero-as-null-pointer-constant")
#endif

#if defined(_MSC_VER)
DIAGNOSTIC_IGNORE(4146) // unary minus operator applied to unsigned type, result still unsigned
DIAGNOSTIC_IGNORE(4800) // forcing value to bool 'true' or 'false'
#endif

#include "orc_proto.pb.h"

DIAGNOSTIC_POP
Expand Down
8 changes: 5 additions & 3 deletions c++/src/wrap/zero-copy-stream-wrapper.h
Expand Up @@ -19,9 +19,11 @@

DIAGNOSTIC_PUSH

DIAGNOSTIC_IGNORE("-Wdeprecated")
DIAGNOSTIC_IGNORE("-Wpadded")
DIAGNOSTIC_IGNORE("-Wunused-parameter")
#if defined(__GNUC__) || defined(__clang__)
DIAGNOSTIC_IGNORE("-Wdeprecated")
DIAGNOSTIC_IGNORE("-Wpadded")
DIAGNOSTIC_IGNORE("-Wunused-parameter")
#endif

#ifdef __clang__
DIAGNOSTIC_IGNORE("-Wreserved-id-macro")
Expand Down

0 comments on commit 6c67bc8

Please sign in to comment.