mirror of
https://github.com/zeromq/cppzmq.git
synced 2025-10-14 15:05:38 +02:00
Problem: Examples are not compiled
Solution: Compile the examples when tests are compiled and using C++11 or greater.
This commit is contained in:
23
examples/CMakeLists.txt
Normal file
23
examples/CMakeLists.txt
Normal file
@@ -0,0 +1,23 @@
|
||||
cmake_minimum_required(VERSION 3.0 FATAL_ERROR)
|
||||
|
||||
project(cppzmq-examples CXX)
|
||||
|
||||
# place binaries and libraries according to GNU standards
|
||||
|
||||
include(GNUInstallDirs)
|
||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR})
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR})
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_BINDIR})
|
||||
|
||||
find_package(Threads)
|
||||
|
||||
add_executable(
|
||||
pubsub_multithread_inproc
|
||||
pubsub_multithread_inproc.cpp
|
||||
)
|
||||
|
||||
target_link_libraries(
|
||||
pubsub_multithread_inproc
|
||||
PRIVATE cppzmq
|
||||
PRIVATE ${CMAKE_THREAD_LIBS_INIT}
|
||||
)
|
@@ -40,9 +40,10 @@ void SubscriberThread1(zmq::context_t *ctx) {
|
||||
zmq::recv_result_t result =
|
||||
zmq::recv_multipart(subscriber, std::back_inserter(recv_msgs));
|
||||
assert(result && "recv failed");
|
||||
assert(*result == 2);
|
||||
|
||||
std::cout << "Thread2: [" << recv_msgs[0].to_string_view() << "] "
|
||||
<< recv_msgs[1].to_string_view() << std::endl;
|
||||
std::cout << "Thread2: [" << recv_msgs[0].to_string() << "] "
|
||||
<< recv_msgs[1].to_string() << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,9 +61,10 @@ void SubscriberThread2(zmq::context_t *ctx) {
|
||||
zmq::recv_result_t result =
|
||||
zmq::recv_multipart(subscriber, std::back_inserter(recv_msgs));
|
||||
assert(result && "recv failed");
|
||||
assert(*result == 2);
|
||||
|
||||
std::cout << "Thread3: [" << recv_msgs[0].to_string_view() << "] "
|
||||
<< recv_msgs[1].to_string_view() << std::endl;
|
||||
std::cout << "Thread3: [" << recv_msgs[0].to_string() << "] "
|
||||
<< recv_msgs[1].to_string() << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user