Skip to content
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

CMake build on Linux does not export ZMQ_BUILD_DRAFT_API as a compile_definition with the target #4194

Closed
datax1969 opened this issue May 21, 2021 · 3 comments · Fixed by #4323

Comments

@datax1969
Copy link

libzmq version = 4.3.4

  • OS:
    Ubuntu 20.04 with cmake 3.16.3

Building with the following command after extracting the tarball and mkdir build; cd build.

cmake -D BUILD_SHARED=OFF -D ENABLE_CURVE=OFF -D ENABLE_DRAFTS=ON =WITH_LIBBSD=OFF -D WITH_LIBSODIUM=OFF ..
sudo make install

The FindPackage config module in /usr/local/lib/cmake/ZeroMQ has no mention of ZMQ_BUILD_DRAFT_API even though you now need it to use the cmake target libzmq-static.

I add the compile definition in my own CMakeLists.txt but the general idea of CMake is that I shouldn't need to. This is further exacerbated when using cppzmq which also requires the definition.

@bluca
Copy link
Member

bluca commented May 21, 2021

It's exported in pkgconfig, you can use that instead. If you want something cmake specific, please send a PR to implement it.

@datax1969
Copy link
Author

The difficulty arises through a combination of two slightly different issues:

  1. Building and installing using cmake has a different effect to building and installing using autconf/configure. With a CMake build on Linux you get a pkgconfig.pc file and a ZeroMQConfig.cmake file installed in the correct places. With autoconf/configure you only get the .pc file.
  2. The .pc file correctly exports ZMQ_BUILD_DRAFT_API. The .cmake file, if present, does not. This also means that all Windows builds (where cmake is forced) will not export that define.

CMake does not have a tight integration between when finding packages using its own mechanisms or that provided by pkg-config. cppzmq for instance tries first using find_package() and if that fails then falls back to the pkg-config method using pkg_check_modules().

So when I want to use libzmq in my project its much cleaner to know that either find_package() will work OR that I have to use the pkg-config method.

With Windows builds only supporting cmake and Windows not having pkg-config, I believe the proper multi-platform solution is to fix both these problems by ALWAYS installing ZeroMQConfig.cmake regardless of build method and fixing it to export the necessary #defines.

I can probably raise a PR to fix the ZeroMQConfig.cmake but autoconf is absolute black magic to me and I would not feel confident in doing this.

@bluca
Copy link
Member

bluca commented May 24, 2021

We can't support cmake stuff in autotools, that's not supported upstream and just too much work to do these kind of bol-ons. It's cmake-specific stuff, so to keep maintenance overhead down it's better to leave it with cmake alone. Please do send a PR to fix the variable exporting if you can.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants