-
Notifications
You must be signed in to change notification settings - Fork 758
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Windows MSYS discovery of libzmq breaks due to library names #361
Comments
@ferdnyc Thanks a lot for bringing this up! I will be happy to include a fix to the CMakeLists.txt, but I fear I won't be able to bring up one myself, given that I am not at all familiar with MSYS. If you want it add an MSYS CI job (on Appveyor?) that checks that this works as expected, that would also be great to ensure that it doesn't break again in the future! |
The ONLY way I've found to make it work is by changing the The idea of being less explicit about the library type in the find module makes me a little nervous, and I think I'm going to install and try a couple more Windows compilers to confirm before I submit a PR to that effect, but so far it's absolutely the only thing that works, and no other changes need to be made on all platforms I've tried so far. (Though I will probably also move
That makes sense as well, I'll definitely take you up on that. AppVeyor have a ready-made MSYS2 setup pre-installed on their Windows images, so it's also quite painless. (Travis' Windows setup is a disaster for doing anything other than MSVC builds... and even for those, it's not great.) |
@sigiesec I ran into this issue today and was surprised this was still an issue, indeed replacing your FindZeroMQ.cmake with ferdnyc's fixes the issue. But beyond this, it isn't really a MSYS issue, and it isn't really a Mingw issue. Trying to use VCPKG or Conan to get ZMQ as a dependency, regardless if whether MSVC was used or not, was similarly painful with the default FindZeroMQ.cmake. |
Please provide a PR that fixes it. Having a test that covers it with or without MSYS would be nice, but that's optional. |
…penshot, previously cppzmq was not looking for the correct names, and rejected valid static library names when looking for zmq on windows, this fix aims to include those other names
@sigiesec We are using this change on both windows and linux and it appears to work (windows using vcpkg, linux using normal repository install of zmq), is it possible you could take a look at this? we currently depend on this change to use your library. |
Post-#267, I find that the
FindZeroMQ.cmake
from this repo is still failing on Windows, when invoked in a CMake project using the "MSYS Makefiles" generator, with ZeroMQ 4.3.1 installed from the MYS-officialmingw32/mingw-w64-i686-zeromq
(32-bit) andmingw64/mingw-w64-x86_64-zeromq
(64-bit) packages viapacman
.(This also appears to be a different issue from #270, where I believe libzmq was self-built by the reporter. I'm not building libzmq, just installing the standard MSYS packages that include a
libzmq.pc
file.)A little background. Also, apologies for the length of the forthcoming coredump:
zmq.hpp
is actually included in the MSYS packages, so technicallycppzmq
isn't needed on (our) Windows at all, andfind_package(cppzmq)
will end up being aNOTFOUND
.However, since ZeroMQ doesn't install CMake targets for itself, and since our project uses ZeroMQ in cross-platform builds on other systems where
cppzmq
is useful (various Linux distros like Fedora, wherecppzmq
is a separate package and not bundled withlibzmq
), I wanted to replace our home-grownFindZMQ.cmake
with theFindZeroMQ.cmake
fromcppzmq
. My goal was to have ZeroMQ itself always be detected the same way, instead of getting configured twice in different ways whencppzmq
is present. Plus,FindZeroMQ.cmake
createdIMPORTED
targets, where our old find module was still stuck in the results-variables dark ages.The switchover worked a treat, on Linux and MacOS. But on our Windows builders, it broke in really weird, subtle ways.
The issue, I believe, comes down to this note, from the "Imported Libraries" section of the CMake
add_library()
docs:That point is relevant to these sections of the
FindZeroMQ.cmake
code:cppzmq/libzmq-pkg-config/FindZeroMQ.cmake
Lines 6 to 9 in fdb2f13
cppzmq/libzmq-pkg-config/FindZeroMQ.cmake
Lines 24 to 26 in fdb2f13
...The problem is that
libzmq.dll.a
is NOT a static library. As the CMake documentation notes, despite the extension it's actually the import library forlibzmq.dll
. So, searching for and configuringlibzmq.dll.a
as a static library appears to break — and not in obvious ways, in really confusing ones.What I was finding was that
FindZeroMQ.cmake
would report success:The
libzmq
target would be created, but the build would fail before the linking step, with:Attempting to use the
libzmq-static
target would also fail, since the file isn't a static library, and causes a build dependency forlibzmq.dll
to be created which then goes unsatisfied.For the moment I've switched to removing the
libzmq-static
target entirely, and creatinglibzmq
as anUNKNOWN IMPORTED
library. I'm also detecting the library by name, instead of by filename:That seems to work on all platforms, at least for our purposes.
I'd like to restore the shared/static library split in a way that works for all platforms, and if I can figure out a way to do it I'll submit a PR. It might be as simple as moving
libzmq.dll.a
to theSHARED
detection, rather than theSTATIC
detection. But I have to do a lot more testing to confirm that.The text was updated successfully, but these errors were encountered: