This is an automated email from the ASF dual-hosted git repository.
astitcher pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/qpid-proton.git
The following commit(s) were added to refs/heads/main by this push:
new 0084354ba PROTON-2810: Make standalone C++ examples build work
correctly
0084354ba is described below
commit 0084354ba917f712ce293e06df5d300f9094d86e
Author: Andrew Stitcher <[email protected]>
AuthorDate: Mon Jul 8 12:36:49 2024 -0400
PROTON-2810: Make standalone C++ examples build work correctly
---
cpp/CMakeLists.txt | 2 +-
cpp/examples/CMakeLists.txt | 11 ++++++++++-
2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt
index 93b42424e..c65cc8723 100644
--- a/cpp/CMakeLists.txt
+++ b/cpp/CMakeLists.txt
@@ -33,7 +33,7 @@ enable_language(CXX)
# So leave this here for a few more years!
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
find_package(Threads)
-link_libraries(Threads::Threads)
+list(APPEND PLATFORM_LIBS Threads::Threads)
include(versions.cmake)
diff --git a/cpp/examples/CMakeLists.txt b/cpp/examples/CMakeLists.txt
index cbaefbe3c..587edfc52 100644
--- a/cpp/examples/CMakeLists.txt
+++ b/cpp/examples/CMakeLists.txt
@@ -25,6 +25,15 @@ find_package(ProtonCpp REQUIRED)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_EXTENSIONS OFF)
+# This is not needed for modern versions of Linux using glibc 2.34 or later
+# However RHEL before RHEL 9; Ubuntu before 22.04; Debian before 12 and FreeBSD
+# with clang (its system compiler) all still need to link the threads library
+# explicitly even though thread support is now included in C++17.
+#
+# So leave this here for a few more years!
+set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
+find_package(Threads)
+
# Single-threaded examples
foreach(example
broker
@@ -53,7 +62,7 @@ foreach(example
multithreaded_client
multithreaded_client_flow_control)
add_executable(${example} ${example}.cpp)
- target_link_libraries(${example} Proton::cpp)
+ target_link_libraries(${example} Proton::cpp Threads::Threads)
endforeach()
# Tracing examples
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]