[C++] Fix building shared library in mingw toolchain
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]
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.
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
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...
Have we reached a consensus on the way they should be?
I don't know CMake. Someone else must review this patch.