From c1cd11743f93c31274cd99575f27c6f6ac447c1a Mon Sep 17 00:00:00 2001 From: oandreeva-nv Date: Mon, 18 Dec 2023 18:30:25 -0800 Subject: [PATCH 1/4] Setting CXX_STANDARD version for project --- CMakeLists.txt | 22 ++++++++++++++++++++++ src/CMakeLists.txt | 11 +++++------ src/grpc/CMakeLists.txt | 2 +- 3 files changed, 28 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 54daf4951a..90e6b86147 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,6 +30,24 @@ project(tritonserver LANGUAGES C CXX) include(CMakeDependentOption) +# Use C++17 standard as Triton's default. +set(TRITON_MIN_CXX_STANDARD 17 CACHE STRING "The minimum C++ standard whose features are requested to build this target.") + +# Unset CMAKE_CXX_STANDARD if it's too low and in the CMakeCache.txt +if($CACHE{CMAKE_CXX_STANDARD} AND $CACHE{CMAKE_CXX_STANDARD} LESS ${TRITON_MIN_CXX_STANDARD}) + message(WARNING "Resetting cache value for CMAKE_CXX_STANDARD to ${TRITON_MIN_CXX_STANDARD}") + unset(CMAKE_CXX_STANDARD CACHE) +endif() + +# Allow manually specified CMAKE_CXX_STANDARD if it's greater than the minimum +# required C++ version +if(DEFINED CMAKE_CXX_STANDARD AND CMAKE_CXX_STANDARD LESS ${TRITON_MIN_CXX_STANDARD}) + message(FATAL_ERROR "Requested CMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD} which is less than the minimum C++ standard ${TRITON_MIN_CXX_STANDARD}") +endif() + +set(CMAKE_CXX_STANDARD ${TRITON_MIN_CXX_STANDARD} CACHE STRING "C++ standard to conform to") +set(CMAKE_CXX_STANDARD_REQUIRED ON) + set(TRITON_VERSION "0.0.0" CACHE STRING "The version of the Triton shared library" ) option(TRITON_ENABLE_LOGGING "Include logging support in server" ON) @@ -106,6 +124,7 @@ endif() # # Dependencies # + include(FetchContent) FetchContent_Declare( @@ -260,6 +279,9 @@ ExternalProject_Add(triton-server -DTRITON_ENABLE_S3:BOOL=${TRITON_ENABLE_S3} -DTRITON_ENABLE_TENSORRT:BOOL=${TRITON_ENABLE_TENSORRT} -DTRITON_ENABLE_ENSEMBLE:BOOL=${TRITON_ENABLE_ENSEMBLE} + -DTRITON_MIN_CXX_STANDARD:STRING=${TRITON_MIN_CXX_STANDARD} + -DCMAKE_CXX_STANDARD:STRING=${CMAKE_CXX_STANDARD} + -DCMAKE_CXX_STANDARD_REQUIRED:BOOL=${CMAKE_CXX_STANDARD_REQUIRED} -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} -DCMAKE_INSTALL_PREFIX:PATH=${TRITON_INSTALL_PREFIX} -DTRITON_VERSION:STRING=${TRITON_VERSION} diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index fe9be17cbb..93d0d856b5 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -61,6 +61,11 @@ endif() # TRITON_ENABLE_GRPC FetchContent_MakeAvailable(repo-common repo-core repo-backend) +# C++ standard +if(DEFINED CMAKE_CXX_STANDARD AND CMAKE_CXX_STANDARD) + message(STATUS "C++ standard: ${CMAKE_CXX_STANDARD}") +endif() + # CUDA # if(${TRITON_ENABLE_GPU}) @@ -117,7 +122,6 @@ if (NOT WIN32) set_property(TARGET main PROPERTY OUTPUT_NAME tritonserver) endif() -target_compile_features(main PRIVATE cxx_std_11) if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") message("Using MSVC as compiler, default target on Windows 10. " "If the target system is not Windows 10, please update _WIN32_WINNT " @@ -353,7 +357,6 @@ if(${TRITON_ENABLE_HTTP} ${HTTP_ENDPOINT_SRCS} ${HTTP_ENDPOINT_HDRS} ) - target_compile_features(http-endpoint-library PRIVATE cxx_std_11) if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") target_compile_options( http-endpoint-library @@ -508,7 +511,6 @@ if(${TRITON_ENABLE_TRACING}) ) if (NOT WIN32) - target_compile_features(tracing-library PRIVATE cxx_std_17) target_include_directories( tracing-library @@ -592,7 +594,6 @@ if (NOT WIN32) simple.cc ) - target_compile_features(simple PRIVATE cxx_std_11) if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") message("Using MSVC as compiler, default target on Windows 10. " "If the target system is not Windows 10, please update _WIN32_WINNT " @@ -656,7 +657,6 @@ if (NOT WIN32) multi_server.cc ) - target_compile_features(multi_server PRIVATE cxx_std_11) if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") message("Using MSVC as compiler, default target on Windows 10. " "If the target system is not Windows 10, please update _WIN32_WINNT " @@ -721,7 +721,6 @@ if (NOT WIN32) memory_alloc.cc ) - target_compile_features(memory_alloc PRIVATE cxx_std_11) if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") message("Using MSVC as compiler, default target on Windows 10. " "If the target system is not Windows 10, please update _WIN32_WINNT " diff --git a/src/grpc/CMakeLists.txt b/src/grpc/CMakeLists.txt index 1308b6e1b2..c3750c1857 100644 --- a/src/grpc/CMakeLists.txt +++ b/src/grpc/CMakeLists.txt @@ -37,7 +37,7 @@ add_library( stream_infer_handler.cc ) -target_compile_features(grpc-endpoint-library PRIVATE cxx_std_11) +target_compile_features(grpc-endpoint-library PRIVATE cxx_std_17) if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") target_compile_options( grpc-endpoint-library From 739b5f51dfe160026ac63721d3c92650063629d1 Mon Sep 17 00:00:00 2001 From: oandreeva-nv Date: Tue, 19 Dec 2023 12:00:10 -0800 Subject: [PATCH 2/4] Remove target_compile_features from grpc CMake --- src/grpc/CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/src/grpc/CMakeLists.txt b/src/grpc/CMakeLists.txt index c3750c1857..8d378d4249 100644 --- a/src/grpc/CMakeLists.txt +++ b/src/grpc/CMakeLists.txt @@ -37,7 +37,6 @@ add_library( stream_infer_handler.cc ) -target_compile_features(grpc-endpoint-library PRIVATE cxx_std_17) if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") target_compile_options( grpc-endpoint-library From 2f18a2455bc2059e99522c75c08d8d0759dbd7ad Mon Sep 17 00:00:00 2001 From: oandreeva-nv Date: Wed, 20 Dec 2023 10:37:46 -0800 Subject: [PATCH 3/4] Removing explicit set of CMAKE_CXX_STANDARD --- CMakeLists.txt | 20 +------------------- src/CMakeLists.txt | 11 ++++++----- src/grpc/CMakeLists.txt | 1 + 3 files changed, 8 insertions(+), 24 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 90e6b86147..c6b05a7404 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -31,22 +31,7 @@ project(tritonserver LANGUAGES C CXX) include(CMakeDependentOption) # Use C++17 standard as Triton's default. -set(TRITON_MIN_CXX_STANDARD 17 CACHE STRING "The minimum C++ standard whose features are requested to build this target.") - -# Unset CMAKE_CXX_STANDARD if it's too low and in the CMakeCache.txt -if($CACHE{CMAKE_CXX_STANDARD} AND $CACHE{CMAKE_CXX_STANDARD} LESS ${TRITON_MIN_CXX_STANDARD}) - message(WARNING "Resetting cache value for CMAKE_CXX_STANDARD to ${TRITON_MIN_CXX_STANDARD}") - unset(CMAKE_CXX_STANDARD CACHE) -endif() - -# Allow manually specified CMAKE_CXX_STANDARD if it's greater than the minimum -# required C++ version -if(DEFINED CMAKE_CXX_STANDARD AND CMAKE_CXX_STANDARD LESS ${TRITON_MIN_CXX_STANDARD}) - message(FATAL_ERROR "Requested CMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD} which is less than the minimum C++ standard ${TRITON_MIN_CXX_STANDARD}") -endif() - -set(CMAKE_CXX_STANDARD ${TRITON_MIN_CXX_STANDARD} CACHE STRING "C++ standard to conform to") -set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(TRITON_MIN_CXX_STANDARD 17 CACHE STRING "The minimum C++ standard which features are requested to build this target.") set(TRITON_VERSION "0.0.0" CACHE STRING "The version of the Triton shared library" ) @@ -124,7 +109,6 @@ endif() # # Dependencies # - include(FetchContent) FetchContent_Declare( @@ -280,8 +264,6 @@ ExternalProject_Add(triton-server -DTRITON_ENABLE_TENSORRT:BOOL=${TRITON_ENABLE_TENSORRT} -DTRITON_ENABLE_ENSEMBLE:BOOL=${TRITON_ENABLE_ENSEMBLE} -DTRITON_MIN_CXX_STANDARD:STRING=${TRITON_MIN_CXX_STANDARD} - -DCMAKE_CXX_STANDARD:STRING=${CMAKE_CXX_STANDARD} - -DCMAKE_CXX_STANDARD_REQUIRED:BOOL=${CMAKE_CXX_STANDARD_REQUIRED} -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} -DCMAKE_INSTALL_PREFIX:PATH=${TRITON_INSTALL_PREFIX} -DTRITON_VERSION:STRING=${TRITON_VERSION} diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 93d0d856b5..85cd1434fc 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -61,11 +61,6 @@ endif() # TRITON_ENABLE_GRPC FetchContent_MakeAvailable(repo-common repo-core repo-backend) -# C++ standard -if(DEFINED CMAKE_CXX_STANDARD AND CMAKE_CXX_STANDARD) - message(STATUS "C++ standard: ${CMAKE_CXX_STANDARD}") -endif() - # CUDA # if(${TRITON_ENABLE_GPU}) @@ -122,6 +117,7 @@ if (NOT WIN32) set_property(TARGET main PROPERTY OUTPUT_NAME tritonserver) endif() +target_compile_features(main PRIVATE cxx_std_${TRITON_MIN_CXX_STANDARD}) if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") message("Using MSVC as compiler, default target on Windows 10. " "If the target system is not Windows 10, please update _WIN32_WINNT " @@ -357,6 +353,7 @@ if(${TRITON_ENABLE_HTTP} ${HTTP_ENDPOINT_SRCS} ${HTTP_ENDPOINT_HDRS} ) + target_compile_features(http-endpoint-library PRIVATE cxx_std_${TRITON_MIN_CXX_STANDARD}) if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") target_compile_options( http-endpoint-library @@ -511,6 +508,7 @@ if(${TRITON_ENABLE_TRACING}) ) if (NOT WIN32) + target_compile_features(tracing-library PRIVATE cxx_std_${TRITON_MIN_CXX_STANDARD}) target_include_directories( tracing-library @@ -594,6 +592,7 @@ if (NOT WIN32) simple.cc ) + target_compile_features(simple PRIVATE cxx_std_${TRITON_MIN_CXX_STANDARD}) if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") message("Using MSVC as compiler, default target on Windows 10. " "If the target system is not Windows 10, please update _WIN32_WINNT " @@ -657,6 +656,7 @@ if (NOT WIN32) multi_server.cc ) + target_compile_features(multi_server PRIVATE cxx_std_${TRITON_MIN_CXX_STANDARD}) if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") message("Using MSVC as compiler, default target on Windows 10. " "If the target system is not Windows 10, please update _WIN32_WINNT " @@ -721,6 +721,7 @@ if (NOT WIN32) memory_alloc.cc ) + target_compile_features(memory_alloc PRIVATE cxx_std_${TRITON_MIN_CXX_STANDARD}) if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") message("Using MSVC as compiler, default target on Windows 10. " "If the target system is not Windows 10, please update _WIN32_WINNT " diff --git a/src/grpc/CMakeLists.txt b/src/grpc/CMakeLists.txt index 8d378d4249..8b200a591e 100644 --- a/src/grpc/CMakeLists.txt +++ b/src/grpc/CMakeLists.txt @@ -37,6 +37,7 @@ add_library( stream_infer_handler.cc ) +target_compile_features(grpc-endpoint-library PRIVATE cxx_std_${TRITON_MIN_CXX_STANDARD}) if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") target_compile_options( grpc-endpoint-library From c377b31d10fcbc5d88206977eab6f2770b1637ca Mon Sep 17 00:00:00 2001 From: oandreeva-nv Date: Wed, 20 Dec 2023 12:04:25 -0800 Subject: [PATCH 4/4] Comment clarification --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c6b05a7404..f4e04dc84b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,7 +30,7 @@ project(tritonserver LANGUAGES C CXX) include(CMakeDependentOption) -# Use C++17 standard as Triton's default. +# Use C++17 standard as Triton's minimum required. set(TRITON_MIN_CXX_STANDARD 17 CACHE STRING "The minimum C++ standard which features are requested to build this target.") set(TRITON_VERSION "0.0.0" CACHE STRING "The version of the Triton shared library" )