Skip to content

Commit

Permalink
PROTON-2810: Make standalone C++ examples build work correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
astitcher committed Jul 8, 2024
1 parent 637c7c5 commit 0084354
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
11 changes: 10 additions & 1 deletion cpp/examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 0084354

Please sign in to comment.