zeromq / libzmq

ZeroMQ core engine in C++, implements ZMTP/3.1
https://www.zeromq.org
Mozilla Public License 2.0
9.67k stars 2.35k forks source link

CMake install does not properly configure pkg-config for libzmq #4592

Open jwmelto opened 1 year ago

jwmelto commented 1 year ago

Issue description

When building with CMake, the generated pkg-config file does not include compiler defines.

Environment

Minimal test code / Steps to reproduce the issue

cd build
cmake -DENABLE_DRAFTS=on -S ..
make install

What's the actual result? (include assertion message & call stack if applicable)

pkg-config --cflags-only-other libzmq
(empty)

What's the expected result?

pkg-config --cflags-only-other libzmq
-DZMQ_BUILD_DRAFT_API=1

By inspection, the autotools config sets pkg_config_defines when draft API is enabled (here). The CMakeLists.txt file does not. When libzmq.pc.in is processed, the empty (undefined) pkg_config_defines is substituted, resulting in an improper configuration.

See cppzmq for an example of how to fix this.

ENHANCEMENT

The CMake exported target should include all properties (including COMPILE_DEFINITIONS). GNU Radio has an example of wrapping ZMQ in a modern CMake export; extending this model would be awesome

coleramos425 commented 1 year ago

Doesn't this commit address that? https://github.com/zeromq/libzmq/commit/c079ca5cc44f3a485a05e6af4cc60c40ec528838

I might be wrong, but I'm basing this off your example

See cppzmq for an example of how to fix this.

jwmelto commented 1 year ago

Looks like it. The CMake config files are still inadequate but that's probably a separate issue.

Any idea when a release including that fix will be available?

spchamp commented 6 months ago

This update may be available in release 4.3.5?

Albeit building with the latest sources and some non-default build options, this was built with the cmake tooling under a test build:

$ cat /usr/local/stow/libzmq-latest-24-04-05-00/lib64/pkgconfig/libzmq.pc 
prefix=/usr/local
exec_prefix=/usr/local
libdir=/usr/local/lib64
includedir=/usr/local/include

Name: libzmq
Description: 0MQ c++ library
Version: 4.3.6
Libs: -L${libdir} -lzmq
Libs.private: -lstdc++  -lrt
Requires.private:  gnutls libbsd libsodium openpgm-5.2
Cflags: -I${includedir} -DZMQ_BUILD_DRAFT_API=1