From 27518aebe4c3a396a2ea0b5d44919182873931f2 Mon Sep 17 00:00:00 2001 From: Allison Vacanti Date: Wed, 9 Jun 2021 17:41:44 -0400 Subject: [PATCH] Update deprecation mechanism (opt-out, cmake, c++14). Opt-out for our internal builds, since we'll still need to maintain and test any deprecated APIs. --- cmake/ThrustBuildTargetList.cmake | 4 ++++ dependencies/cub | 2 +- thrust/cmake/thrust-config.cmake | 6 ++++++ thrust/detail/config/deprecated.h | 11 ++++++++++- 4 files changed, 21 insertions(+), 2 deletions(-) diff --git a/cmake/ThrustBuildTargetList.cmake b/cmake/ThrustBuildTargetList.cmake index 1a859443c7..a5dbd5c4b5 100644 --- a/cmake/ThrustBuildTargetList.cmake +++ b/cmake/ThrustBuildTargetList.cmake @@ -314,6 +314,10 @@ function(thrust_build_target_list) add_flag_option(IGNORE_DEPRECATED_COMPILER "Don't warn about deprecated compilers." OFF) add_flag_option(IGNORE_CUB_VERSION_CHECK "Don't warn about mismatched CUB versions." OFF) + # By default, suppress deprecation warnings when building our test suite, + ## since we'll need to test deprecated APIs with `-Werror`. + add_flag_option(IGNORE_DEPRECATED_API "Don't warn about deprecated Thrust or CUB APIs." ON) + # Top level meta-target. Makes it easier to just build thrust targets when # building both CUB and Thrust. Add all project files here so IDEs will be # aware of them. This will not generate build rules. diff --git a/dependencies/cub b/dependencies/cub index a693b016f9..f919860740 160000 --- a/dependencies/cub +++ b/dependencies/cub @@ -1 +1 @@ -Subproject commit a693b016f932c56514ba3ee7900efc14ce963892 +Subproject commit f919860740bff96ec3d0af20026622bd7c37f20f diff --git a/thrust/cmake/thrust-config.cmake b/thrust/cmake/thrust-config.cmake index c08fcb042b..b9e9fb0650 100644 --- a/thrust/cmake/thrust-config.cmake +++ b/thrust/cmake/thrust-config.cmake @@ -50,6 +50,7 @@ # # # Create target with HOST=CPP DEVICE=CUDA and some advanced flags set # thrust_create_target(TargetName +# IGNORE_DEPRECATED_API # Silence build warnings about deprecated APIs # IGNORE_DEPRECATED_CPP_DIALECT # Silence build warnings about deprecated compilers and C++ standards # IGNORE_DEPRECATED_CPP_11 # Only silence deprecation warnings for C++11 # IGNORE_DEPRECATED_COMPILER # Only silence deprecation warnings for old compilers @@ -104,6 +105,7 @@ function(thrust_create_target target_name) ADVANCED FROM_OPTIONS IGNORE_CUB_VERSION_CHECK + IGNORE_DEPRECATED_API IGNORE_DEPRECATED_COMPILER IGNORE_DEPRECATED_CPP_11 IGNORE_DEPRECATED_CPP_DIALECT @@ -196,6 +198,10 @@ function(thrust_create_target target_name) target_compile_definitions(${target_name} INTERFACE "THRUST_IGNORE_DEPRECATED_CPP_DIALECT") endif() + if (TCT_IGNORE_DEPRECATED_API) + target_compile_definitions(${target_name} INTERFACE "THRUST_IGNORE_DEPRECATED_API") + endif() + if (TCT_IGNORE_DEPRECATED_CPP_11) target_compile_definitions(${target_name} INTERFACE "THRUST_IGNORE_DEPRECATED_CPP_11") endif() diff --git a/thrust/detail/config/deprecated.h b/thrust/detail/config/deprecated.h index cd18f3ac92..05851c6768 100644 --- a/thrust/detail/config/deprecated.h +++ b/thrust/detail/config/deprecated.h @@ -21,8 +21,17 @@ #pragma once #include +#include -#if THRUST_HOST_COMPILER == THRUST_HOST_COMPILER_MSVC +#if defined(CUB_IGNORE_DEPRECATED_API) && !defined(THRUST_IGNORE_DEPRECATED_API) +# define THRUST_IGNORE_DEPRECATED_API +#endif + +#ifdef THRUST_IGNORE_DEPRECATED_API +# define THRUST_DEPRECATED +#elif THRUST_CPP_DIALECT >= 2014 +# define THRUST_DEPRECATED [[deprecated]] +#elif THRUST_HOST_COMPILER == THRUST_HOST_COMPILER_MSVC # define THRUST_DEPRECATED __declspec(deprecated) #elif THRUST_HOST_COMPILER == THRUST_HOST_COMPILER_CLANG # define THRUST_DEPRECATED __attribute__((deprecated))