nimbuscontrols / EIPScanner

Free implementation of EtherNet/IP in C++
https://eipscanner.readthedocs.io/en/latest/
MIT License
224 stars 90 forks source link

CMakeLists: Fix compilation with GCC < 10 on MinGW #77

Closed JohannesKauffmann closed 1 year ago

JohannesKauffmann commented 2 years ago

Some winsock2 functions needs at least _WIN32_WINNT=0x0600 defined. This was discovered when using MinGW-w64 to cross-compile:

[ 21%] Building CXX object src/CMakeFiles/EIPScannerS.dir/sockets/EndPoint.cpp.obj
/EIPScanner/src/sockets/EndPoint.cpp: In constructor ‘eipScanner::sockets::EndPoint::EndPoint(std::string, int)’:
/EIPScanner/src/sockets/EndPoint.cpp:38:9: error: ‘inet_pton’ was not declared in this scope; did you mean ‘inet_ntoa’?
   38 |     if (inet_pton(AF_INET, _host.c_str(), &_addr.sin_addr.s_addr) < 0) {
      |         ^~~~~~~~~
      |         inet_ntoa
gmake[2]: *** [src/CMakeFiles/EIPScannerS.dir/build.make:377: src/CMakeFiles/EIPScannerS.dir/sockets/EndPoint.cpp.obj] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:168: src/CMakeFiles/EIPScannerS.dir/all] Error 2
gmake: *** [Makefile:149: all] Error 2
JohannesKauffmann commented 2 years ago

Turns out this is not an issue with cross-compilation, but rather with older MinGW/GCC versions. Updated the commit (message), and also restructured the existing MSVC check.