Skip to content

Commit

Permalink
PROTON-2810: Change C++ language version to C++17
Browse files Browse the repository at this point in the history
Change documented requirements; Stop linking C++ code with threads
library as this is now in C++ 17 standard library (everywhere except
FrewBSD with clang)
  • Loading branch information
astitcher committed Jul 1, 2024
1 parent 9e329f6 commit 5498087
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 28 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ if (CMAKE_CXX_COMPILER)

enable_language(CXX)

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_EXTENSIONS OFF)
endif()

Expand Down
17 changes: 7 additions & 10 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,22 @@ Dependencies
Cross-platform dependencies

- CMake 3.16+
- Python 3.8+ (required to build core C library)
- Swig 1.3+ (for the bindings)
- Python 3.9+ (required to build core C library)
- Swig 1.3+ (for the Ruby binding)
- Ruby 1.9+ (for the Ruby binding)
- Go 1.11+ (for the Go binding)

Linux dependencies

- GNU Make 3.81+
- GCC 4.8.4+
- GCC 9+
- Cyrus SASL 2.1+ (for SASL support)
- OpenSSL 1.0+ (for SSL support)
- JsonCpp 1.8+ for C++ connection configuration file support

Windows dependencies

- Visual Studio 2015 or newer (regular or C++ Express)
- Visual Studio 2019 or newer (Community or Enterprise Editions)

CMake (Linux)
-------------
Expand Down Expand Up @@ -60,7 +60,7 @@ The following prerequisites are required to do a full build on
Debian-based systems (Ubuntu). If you do not wish to build a given
language binding you can omit the dev package for that language.

# Required dependencies
# Required dependencies
$ apt-get install gcc g++ cmake cmake-curses-gui uuid-dev

# Dependencies needed for SSL support
Expand Down Expand Up @@ -107,8 +107,8 @@ Studio and used to build the Proton library.

The following packages must be installed:

- Visual Studio 2017 or newer (Community or Enterprise Editions)
- Python (www.python.org)
- Visual Studio 2019 or newer (Community or Enterprise Editions)
- Python 3.9 or newer (www.python.org)
- CMake (www.cmake.org)

Additional packages are required for language bindings:
Expand All @@ -131,9 +131,6 @@ this `INSTALL.md` file:

If CMake doesn't guess things correctly, useful additional arguments are:

-G "Visual Studio 15 2017"
or

-G "Visual Studio 16 2019"
or

Expand Down
11 changes: 7 additions & 4 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,13 @@ endif()
include(CMakeDependentOption)
enable_language(CXX)

set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
find_package(Threads)
# This is only needed for FreeBSD with clang (its system compiler)
# Everything else will get threads support by default with C++ libs
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
find_package(Threads)
link_libraries(Threads::Threads)
endif()

include(versions.cmake)

Expand Down Expand Up @@ -54,8 +59,6 @@ else()
set(TRACING_SRC src/tracing_stub.cpp src/init_tracer_stub.cpp)
endif()

list(APPEND PLATFORM_LIBS Threads::Threads)

set(CXX_EXAMPLE_FLAGS "${CXX_WARNING_FLAGS} ${CXX_STANDARD}")
set(CXX_EXAMPLE_LINK_FLAGS "${SANITIZE_FLAGS}")

Expand Down
2 changes: 1 addition & 1 deletion cpp/benchmarks/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# under the License.
#

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

Expand Down
16 changes: 4 additions & 12 deletions cpp/examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,8 @@ cmake_minimum_required (VERSION 3.16)
project(ProtonCppExamples C CXX)

find_package(ProtonCpp REQUIRED)
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
find_package(Threads REQUIRED)

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_EXTENSIONS OFF)

# Single-threaded examples
Expand All @@ -51,7 +49,9 @@ foreach(example
ssl_client_cert
encode_decode
scheduled_send
service_bus)
service_bus
multithreaded_client
multithreaded_client_flow_control)
add_executable(${example} ${example}.cpp)
target_link_libraries(${example} Proton::cpp)
endforeach()
Expand All @@ -63,11 +63,3 @@ if (ENABLE_OPENTELEMETRYCPP)
target_link_libraries(${example} Proton::cpp opentelemetry-cpp::trace opentelemetry-cpp::otlp_http_exporter)
endforeach()
endif()

# Examples that use threads directly
foreach(example
multithreaded_client
multithreaded_client_flow_control)
add_executable(${example} ${example}.cpp)
target_link_libraries(${example} Proton::cpp Threads::Threads)
endforeach()

0 comments on commit 5498087

Please sign in to comment.