antlr4 icon indicating copy to clipboard operation
antlr4 copied to clipboard

[C++] Fix building shared library in mingw toolchain

Open Biswa96 opened this issue 3 years ago • 5 comments

This fixes building shared library by defining proper symbols. Previously, the symbols ANTLR4CPP_EXPORTS and ANTLR4CPP_STATIC were defined for MSVC toolchain only. So, mingw toolchain was excluded in that condition. Hence, the issue is solved by moving the compile definitions in a general if(WIN32) check which is independent of compiler toolchain.

Signed-off-by: Biswapriyo Nath [email protected]

Biswa96 avatar Jun 21 '22 16:06 Biswa96

In master branch, this was solved different way. If required I can create another PR to make things similar in master branch. Setting COMPILE_FLAGS with set_target_properties was deprecated. So, using target_compile_definitions is better choice, IMO.

Biswa96 avatar Jun 21 '22 16:06 Biswa96

The name "WIN32" does not mean 32 bit only. "WIN32" is true for any Microsoft Windows OS, irrespective of CPU architecture. See more https://cmake.org/cmake/help/latest/variable/WIN32.html

Biswa96 avatar Jun 26 '22 12:06 Biswa96

WIN32 means "Windows 32 bit". It doesn't matter if that is still available on all Windows versions (which is purely for compatibility reasons). But anyway...

mike-lischke avatar Jun 26 '22 15:06 mike-lischke

Have we reached a consensus on the way they should be?

parrt avatar Aug 26 '22 21:08 parrt

I don't know CMake. Someone else must review this patch.

mike-lischke avatar Aug 27 '22 08:08 mike-lischke