zeromq/zmqpp

CMake build does not work with Microsoft Windows operating system, both for MinGW and MSVC

FlorianWolters opened this issue · 3 comments

The CMakeLists.txt generates compiler and linker errors when building with Microsoft Windows and/or the Microsoft Visual C++ (MSVC) compiler. The following changes must be applied to the CMakeLists.txt:

  1. Add Winsock to the libraries to link.

  2. Wrap the CMAKE_CXX_FLAGS modifications into an if-condition, so they get only applied when compiling with GCC/MinGW (https://github.com/zeromq/zmqpp/blob/develop/CMakeLists.txt#L18-26).

    if(${CMAKE_CXX_COMPILER_ID} STREQUAL GNU)
      # ...
    endif()
    

Off-Topic: Overall the build looks fragile. Would be nice if GCC/MinGW-w64/Clang/MSVC would all work equally. libzmq (and zmqpp) should use a CMake Package. I had to introduce a lot of custom builds steps (renaming of generated libraries, this issue, etc) in order to successfully build ZeroMQ with CMake for both MinGW-w64 and MSVC from sources.

bluca commented

Could you please a PR to fix those?

Also the following changes to libzmq: zeromq/libzmq#2295 were made to avoid the need of an external findpackage. But I don't use Windows so can't comment on more than that

Yes, I will create a PR tomorrow. Ah, I see: zeromq/libzmq#2295 seems to implement exactly what I mean: The modern CMake-Package approach as described in the link posted by myself.

Sorry, I totally forgot this one. The MinGW 6.3.0 build seems to work now in the develop head, but the VC 14.0 build fails with another error now. Sadly I do not have the time at the moment to fix the broken build, I've also spotted problems regarding optional build of static and shared libraries and so on. For example, a Find Module (or better: rely on the Package Configuration in the ZeroMQ library) should be used instead of the two variables ZEROMQ_LIB_DIR and ZEROMQ_INCLUDE_DIR. The person fixing the zmqpp build should read https://cgold.readthedocs.io/en/latest/tutorials/libraries/static-shared.html and https://cmake.org/cmake/help/latest/command/find_package.html.

tl;dr: It is not a good idea to build both shared and static libraries in one build configuration. Instead two separate build configurations (i.e. also out-of-source builds) should be used.