Skip to content

Commit

Permalink
Merge pull request #1548 from adrpo/FixMsys2MinGWBuild
Browse files Browse the repository at this point in the history
adapt code to compile with msys2 mingw compiler
  • Loading branch information
parrt authored Dec 25, 2016
2 parents 0774117 + 8ab5f02 commit 1c987e7
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 11 deletions.
1 change: 1 addition & 0 deletions contributors.txt
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,4 @@ YYYY/MM/DD, github id, Full name, email
2016/12/03, redxdev, Samuel Bloomberg, sam@redxdev.com
2016/12/11, Gaulouis, Gaulouis, gaulouis.com@gmail.com
2016/12/22, akosthekiss, Akos Kiss, akiss@inf.u-szeged.hu
2016/12/24, adrpo, Adrian Pop, adrian.pop@liu.se
14 changes: 11 additions & 3 deletions runtime/Cpp/runtime/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

include_directories(
${PROJECT_SOURCE_DIR}/runtime/src
${PROJECT_SOURCE_DIR}/runtime/src/atn
Expand Down Expand Up @@ -50,7 +51,13 @@ elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")
set(disabled_compile_warnings "${disabled_compile_warnings} -Wno-multichar")
endif()


set(extra_share_compile_flags "")
set(extra_static_compile_flags "")
if (WIN32)
set(extra_share_compile_flags "-DANTLR4CPP_EXPORTS")
set(extra_static_compile_flags "-DANTLR4CPP_STATIC")
endif(WIN32)

set_target_properties(antlr4_shared
PROPERTIES VERSION ${ANTLR_VERSION}
SOVERSION ${ANTLR_VERSION}
Expand All @@ -59,14 +66,15 @@ set_target_properties(antlr4_shared
# TODO: test in windows. DLL is treated as runtime.
# see https://cmake.org/cmake/help/v3.0/prop_tgt/LIBRARY_OUTPUT_DIRECTORY.html
RUNTIME_OUTPUT_DIRECTORY ${LIB_OUTPUT_DIR}
COMPILE_FLAGS "${disabled_compile_warnings}")
ARCHIVE_OUTPUT_DIRECTORY ${LIB_OUTPUT_DIR}
COMPILE_FLAGS "${disabled_compile_warnings} ${extra_share_compile_flags}")

set_target_properties(antlr4_static
PROPERTIES VERSION ${ANTLR_VERSION}
SOVERSION ${ANTLR_VERSION}
OUTPUT_NAME antlr4-runtime
ARCHIVE_OUTPUT_DIRECTORY ${LIB_OUTPUT_DIR}
COMPILE_FLAGS "${disabled_compile_warnings}")
COMPILE_FLAGS "${disabled_compile_warnings} ${extra_static_compile_flags}")

install(TARGETS antlr4_shared
DESTINATION lib)
Expand Down
2 changes: 1 addition & 1 deletion runtime/Cpp/runtime/src/ANTLRFileStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ void ANTLRFileStream::loadFromFile(const std::string &fileName) {
return;
}

#ifdef _WIN32
#ifdef _MSC_VER
std::ifstream stream(antlrcpp::s2ws(fileName), std::ios::binary);
#else
std::ifstream stream(fileName, std::ios::binary);
Expand Down
14 changes: 9 additions & 5 deletions runtime/Cpp/runtime/src/antlr4-common.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,14 @@

// Defines for the Guid class and other platform dependent stuff.
#ifdef _WIN32
#pragma warning (disable: 4250) // Class inherits by dominance.
#pragma warning (disable: 4512) // assignment operator could not be generated
#ifdef _MSC_VER
#pragma warning (disable: 4250) // Class inherits by dominance.
#pragma warning (disable: 4512) // assignment operator could not be generated

#if _MSC_VER < 1900
// Before VS 2015 code like "while (true)" will create a (useless) warning in level 4.
#pragma warning (disable: 4127) // conditional expression is constant
#if _MSC_VER < 1900
// Before VS 2015 code like "while (true)" will create a (useless) warning in level 4.
#pragma warning (disable: 4127) // conditional expression is constant
#endif
#endif

#define GUID_WINDOWS
Expand Down Expand Up @@ -69,7 +71,9 @@
#endif
#endif

#ifdef _MSC_VER
class ANTLR4CPP_PUBLIC std::exception; // Needed for VS 2015.
#endif

#elif __APPLE__
#define GUID_CFUUID
Expand Down
4 changes: 2 additions & 2 deletions runtime/Cpp/runtime/src/support/Any.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

#include "antlr4-common.h"

#ifdef _WIN32
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable: 4521) // 'antlrcpp::Any': multiple copy constructors specified
#endif
Expand Down Expand Up @@ -139,6 +139,6 @@ struct Any

} // namespace antlrcpp

#ifdef _WIN32
#ifdef _MSC_VER
#pragma warning(pop)
#endif

0 comments on commit 1c987e7

Please sign in to comment.