0

I have tried for a day to try and resolve issues with the cmake when trying to build a project using the zeromq library. I appreciate that there have been several threads on this question in the past, but none seem to explain the fix in any detail. I've exhausted my knowledge regarding how to solve this one and would appreciate an explanation as to what I need to do.

Below is the following error message from the project cmake command issued inside CLion.

The cmake Error occurs at line 1 of vcpkg-cmake-wrapper.cmake proving that it was found.

  Could not find a package configuration file provided by "zeromq" with 
  any of the following names:

    zeromqConfig.cmake
    zeromq-config.cmake

  Add the installation prefix of "zeromq" to CMAKE_PREFIX_PATH or set
  "zeromq_DIR" to a directory containing one of the above files.  If "zeromq"
  provides a separate development package or SDK, be sure it has been
  installed.

Where does this package config file go and what is in it? What is meant by adding the installation prefix to CMAKE_PREFIX_PATH?

I installed zeromq using vcpkg. The output from vcpkg list is

cppzmq:x64-linux                                  4.8.1#1             Header-only C++ binding for ZeroMQ
zeromq:x64-linux                                  4.3.4#6             The ZeroMQ lightweight messaging kernel is a lib...

So to me this looks like the library downloaded, built and installed correctly.

My cmake toolchain options are:

-DCMAKE_TOOLCHAIN_FILE=~/vcpkg/scripts/buildsystems/vcpkg.cmake

/vcpkg/installed/x64-linux/share/zeromq/vcpkg-cmake-wrapper.cmake:1

CMakeLists.txt is:

cmake_minimum_required(VERSION 3.24.0)
project(Template VERSION 1.0.0)

add_executable(template src/main.cpp)

find_package(zeromq CONFIG REQUIRED)
find_package(cppzmq CONFIG REQUIRED)

target_compile_features(Template PRIVATE cxx_std_17)

target_link_libraries(main
        PRIVATE
        zeromq::zeromq
        cppzmq::cppzmq)

This is currently an empty project until I get cmake process to resolve the library

I have tried to understand by following the example on: https://vcpkg.readthedocs.io/en/latest/examples/manifest-mode-cmake/ From this I can successfully build and create an executable.

Tsyvarev
  • 60,011
  • 17
  • 110
  • 153
  • The name of CMake package with zeromq is `ZeroMQ`, not `zeromq`. See also [that answer](https://stackoverflow.com/a/41949456/3440745). – Tsyvarev Jan 20 '23 at 16:58

1 Answers1

0

Thanks Tsyvarev. I achieved an error free CMake by changing my CMakeLists.txt to:

cmake_minimum_required(VERSION 3.24.0)
project(Template VERSION 1.0.0)

#set(zeromq_DIR "~/usr/local/lib/cmake/ZeroMQ")

add_executable(Template src/main.cpp)

find_package(ZeroMQ CONFIG REQUIRED)

target_compile_features(Template PRIVATE cxx_std_17)

target_link_libraries(Template
        PRIVATE
        ZeroMQ)