Skip to content
This repository has been archived by the owner on Jul 8, 2022. It is now read-only.

Commit

Permalink
CMake: Add compile check to test for correct ZeroMQ C++ headers
Browse files Browse the repository at this point in the history
We are relying on the presence of convertability from zmq::socket_t to void *.

Add a cmake check so that we know that we have the correct version.
  • Loading branch information
t-b committed Feb 6, 2019
1 parent 060b990 commit 9f3ca3a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
10 changes: 10 additions & 0 deletions configure/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,16 @@ Please install cppzmq (https://github.com/zeromq/cppzmq) on your system and/or u
<OMNI_BASE>/include and system include directories).")
endif()

TRY_COMPILE(HAS_COMPATIBLE_ZMQ_HPP_VERSION
${CMAKE_BINARY_DIR}/configure
SOURCES ${CMAKE_SOURCE_DIR}/configure/test_zmq_hpp.cpp
CMAKE_FLAGS "-I ${CPPZMQ_BASE}/include -I ${ZMQ_PKG_INCLUDE_DIRS}/include"
LINK_LIBRARIES ${ZMQ_PKG_LIBRARIES})

IF(NOT HAS_COMPATIBLE_ZMQ_HPP_VERSION)
message(FATAL_ERROR "Please use a compatible version of cppzmq")
ENDIF()

message("Verifying ${OMNIIDL_PATH}omniidl")
if(WIN32)
execute_process(COMMAND ${OMNIIDL_PATH}omniidl.exe -V RESULT_VARIABLE FAILED)
Expand Down
10 changes: 10 additions & 0 deletions configure/test_zmq_hpp.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#include <zmq.hpp>

int main(int argc, char** argv)
{
zmq::context_t c;
zmq::socket_t s(c, ZMQ_REQ);

// we require `operator void*()`
void *ptr = s;
}

0 comments on commit 9f3ca3a

Please sign in to comment.