From ea061be2d19b081d1d67d195290a10462a6392d1 Mon Sep 17 00:00:00 2001 From: Ranjith Ramakrishnan Date: Fri, 10 Mar 2023 09:11:52 -0800 Subject: [PATCH] SWDEV-366831 - Compile time flag to switch between #warning and #error message Using backward compatibility paths will provide an #error message. Compile time option added to enable/disable the #error message. Disabling the same will provide a #warning message Change-Id: I6abc236e810ccc38d3636074e0e8f5a9657c2e9a --- header_template.hpp.in | 9 ++++++++- src/CMakeLists.txt | 14 ++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/header_template.hpp.in b/header_template.hpp.in index e676774..627fefd 100644 --- a/header_template.hpp.in +++ b/header_template.hpp.in @@ -23,11 +23,18 @@ #ifndef @include_guard@ #define @include_guard@ -#if defined(__GNUC__) +#ifndef ROCM_HEADER_WRAPPER_WERROR +#define ROCM_HEADER_WRAPPER_WERROR @deprecated_error@ +#endif +#if ROCM_HEADER_WRAPPER_WERROR /* ROCM_HEADER_WRAPPER_WERROR 1 */ #error "This file is deprecated. Use file from include path /opt/rocm-ver/include/ and prefix with roctracer" +#else /* ROCM_HEADER_WRAPPER_WERROR 0 */ +#if defined(__GNUC__) +#warning "This file is deprecated. Use file from include path /opt/rocm-ver/include/ and prefix with roctracer" #else #pragma message("This file is deprecated. Use file from include path /opt/rocm-ver/include/ and prefix with roctracer") #endif +#endif /* ROCM_HEADER_WRAPPER_WERROR */ @include_statements@ diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e1366e6..80598d2 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -247,5 +247,19 @@ if(NOT ENABLE_ASAN_PACKAGING) endif() if(FILE_REORG_BACKWARD_COMPATIBILITY) +## To enable/disable #error in wrapper header files + if(NOT DEFINED ROCM_HEADER_WRAPPER_WERROR) + if(DEFINED ENV{ROCM_HEADER_WRAPPER_WERROR}) + set(ROCM_HEADER_WRAPPER_WERROR "$ENV{ROCM_HEADER_WRAPPER_WERROR}" + CACHE STRING "Header wrapper warnings as errors.") + else() + set(ROCM_HEADER_WRAPPER_WERROR "ON" CACHE STRING "Header wrapper warnings as errors.") + endif() + endif() + if(ROCM_HEADER_WRAPPER_WERROR) + set(deprecated_error 1) + else() + set(deprecated_error 0) + endif() include(${PROJECT_SOURCE_DIR}/roctracer-backward-compat.cmake) endif()