Skip to content

Modernize FindZeroMQ.cmake and fix some ZeroMQ related compile bugs#5091

Open
SunBlack wants to merge 1 commit into
ornladios:masterfrom
SunBlack:zeromq
Open

Modernize FindZeroMQ.cmake and fix some ZeroMQ related compile bugs#5091
SunBlack wants to merge 1 commit into
ornladios:masterfrom
SunBlack:zeromq

Conversation

@SunBlack

@SunBlack SunBlack commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Supersedes #5089 and fixes #5088.

Since the discussion in #5089 showed that pkg conf is necessary, and therefore a separate find script is still required, I tested this locally with vcpkg and ran into several other issues with ZeroMQ, so it’s probably worth creating a separate PR after all.

Changes:

  • Modernized CMake script to use always imported targets (and therefore get also retrieve maybe necessary compiler flags and other indirect dependencies)
  • Didn't raised minimum required version to 4.2.2 - didn't checked whether 4.1 exports pkg files
  • To prevent recursive calls, added MODULE and CONFIG to the find_package calls
  • Removed alternative operator representations, as they caused compile issues with MSVC 2026 (and are deprecated anyway)

Notes:

  • Didn't verified the pkg path
  • Is it okay to add pkgconf to scripts/ci/images/Dockerfile.ci-spack-ubuntu22.04-base or is there really a another legacy path necessary?

@SunBlack SunBlack requested a review from a team as a code owner June 17, 2026 11:41
@SunBlack SunBlack force-pushed the zeromq branch 7 times, most recently from 339ee81 to 9ff93dc Compare June 17, 2026 14:36
Comment thread cmake/FindZeroMQ.cmake Outdated
endif()

# pkg-config fallback
find_package(PkgConfig ${_zmq_quiet} ${_zmq_required})

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

find_dependency will avoid having to explicitly forward these flags.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, always forgetting this command :-/

Comment thread cmake/FindZeroMQ.cmake Outdated
if(TARGET libzmq)
add_library(ZeroMQ::ZMQ ALIAS libzmq)
return()
endif()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's move the CONFIG find this to the detect options, in that manner it remains consistent with the other deps. There if it fails you can invoke this MODULE find.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the changes, what I meant is to move the CONFIG find to the DetectOptions.cmake

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure whether this is a good idea, as there are always more duplication in the DetectOptions.cmake due to the AUTO/ON paths:

if(ADIOS2_USE_ZeroMQ STREQUAL AUTO)
    find_package(ZeroMQ 4.1 CONFIG)
    if (NOT ZeroMQ_FOUND)
      find_package(ZeroMQ 4.1 MODULE)
	endif()
elseif(ADIOS2_USE_ZeroMQ)
    find_package(ZeroMQ 4.1 CONFIG REQUIRED)
    if (NOT ZeroMQ_FOUND)
      find_package(ZeroMQ 4.1 MODULE REQUIRED)
	endif()
endif()

Another downside: The (3) examples could not use the Config code or need also the duplicated paths there

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason to have this in detectoptions.cmake is keep that file consistent, the dance of find_package is common there.

Another downside: The (3) examples could not use the Config code or need also the duplicated paths there

Can you develop this point?

Thanks!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do think it's poor design to move it to DetectOptions, since that means anyone looking for ZeroMQ has to implement both variants instead of having a central location, but if that's what you want...

The examples don't actually need ZeroMQ, since the target is only linked privately.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The examples don't actually need ZeroMQ, since the target is only linked privately.

This is true since we find_dependency(zeroMq) in the adios2-config.cmake.

Comment thread cmake/FindZeroMQ.cmake Outdated

# If native package was found, stop here
if(TARGET libzmq)
add_library(ZeroMQ::ZMQ ALIAS libzmq)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets just use libzmq thru adios2? Looking at libzmq source code it seems that they do not namespace their targets in the config cmake file.

@SunBlack SunBlack force-pushed the zeromq branch 3 times, most recently from 1583f7a to b42b725 Compare June 22, 2026 13:03
Comment thread cmake/DetectOptions.cmake Outdated
find_package(ZeroMQ 4.1 REQUIRED)
find_package(ZeroMQ 4.1)
if(NOT ZeroMQ_FOUND)
find_package(ZeroMQPkg 4.1 REQUIRED)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for the rename, you can use find_package(... MODULE)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know. I put that there on purpose to make it clear that it's only intended for the pkg variant. If the module is ever exported and someone runs find_package(ZeroMQ), they might not realize that it's only meant for that one variant.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This add extra complexity, please keep it simple using the module is more succinct.

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 this pull request may close these issues.

Use config mode to find ZeroMQ

2 participants