zeromq / cppzmq

Header-only C++ binding for libzmq
http://www.zeromq.org
MIT License
1.94k stars 757 forks source link

Build instructions for libzmq and cppzmq with draft apis #455

Open wynn4 opened 3 years ago

wynn4 commented 3 years ago

Following the basic install instructions here: https://github.com/zeromq/cppzmq#build-instructions

Results in builds where the draft apis are not enabled. Looking into the CMakeLists.txt files, I thought that if I cloned the repositories (as opposed to downloading a .tar.gz from the release page) that the draft functions would be enabled.

From CMakeLists.txt:

if (EXISTS "${CMAKE_SOURCE_DIR}/.git") OPTION (ENABLE_DRAFTS "Build and install draft classes and methods" ON) else () OPTION (ENABLE_DRAFTS "Build and install draft classes and methods" OFF) endif () if (ENABLE_DRAFTS) ADD_DEFINITIONS (-DZMQ_BUILD_DRAFT_API) set (pkg_config_defines "-DZMQ_BUILD_DRAFT_API=1") else (ENABLE_DRAFTS) set (pkg_config_defines "") endif (ENABLE_DRAFTS)

Is there a simple change to these instructions that would change this? Specifically I'm hoping to use the cppzmq's poller functionality.

gummif commented 3 years ago

How are you consuming the libary, with CMake add_subdirectory or just including the headers or a package manager? But the simplest way is to just define ZMQ_BUILD_DRAFT_API in you project (assuming libzmq has it enabled also).

wynn4 commented 3 years ago

Thanks @gummif. I'm installing both libraries following the instructions from the README linked above, then in my project's CMakeLists.txt I'm doing the following (as also suggested in the README):

#find cppzmq wrapper, installed by make of cppzmq    
find_package(cppzmq)  
target_link_libraries(*Your Project Name* cppzmq)
gummif commented 3 years ago

I think in this case you need to just define the macro yourself. But that could maybe be better documented as you said.

jaewooklee93 commented 3 years ago

I also have had hard time to build my program with zmq draft feature on Windows 10 / Visual Studio

It would be nice if #build-instructions mentions about ZMQ_BUILD_DRAFT_API