Skip to content
This repository has been archived by the owner on Mar 21, 2024. It is now read-only.

Commit

Permalink
Update deprecation mechanism (opt-out, cmake, c++14).
Browse files Browse the repository at this point in the history
Opt-out for our internal builds, since we'll still need to maintain and
test any deprecated APIs.
  • Loading branch information
alliepiper committed Jun 14, 2021
1 parent 7736317 commit 506c82b
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 1 deletion.
4 changes: 4 additions & 0 deletions cmake/ThrustBuildTargetList.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 4 additions & 0 deletions internal/build/common_build.mk
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ ifeq ($(OS),Linux)
LIBRARIES += m
endif

# Disable our THRUST_DEPRECATED and CUB_DEPRECATED macros for internal
# builds, since we need to build and test our deprecated APIs with -Werror.
CUDACC_FLAGS += -DTHRUST_IGNORE_DEPRECATED_API

include $(ROOTDIR)/thrust/internal/build/common_compiler.mk

# Add /bigobj to Windows build flag to workaround building Thrust with debug
Expand Down
6 changes: 6 additions & 0 deletions thrust/cmake/thrust-config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down
11 changes: 10 additions & 1 deletion thrust/detail/config/deprecated.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,17 @@
#pragma once

#include <thrust/detail/config/compiler.h>
#include <thrust/detail/config/cpp_dialect.h>

#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))
Expand Down

0 comments on commit 506c82b

Please sign in to comment.