From f962d0959a5e1ae23dfd51286723fad2334262be Mon Sep 17 00:00:00 2001 From: Ranjith Ramakrishnan Date: Fri, 10 Mar 2023 13:18:34 -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: I45f987b572a306036a72525d2b90d366459117ad --- CMakeLists.txt | 15 +++++++++++++++ src/header_template.hpp.in | 9 ++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index af8b85ce34..49cb64c6b6 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -431,6 +431,21 @@ configure_file( "${PROJECT_SOURCE_DIR}/RPM/rpm_postun" FILE_PERMISSIONS ${INST_SCR_PERM}) #backward compatibility for file reorganization 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(rdc-backward-compat) endif() if(DEFINED ENV{ROCM_LIBPATCH_VERSION}) diff --git a/src/header_template.hpp.in b/src/header_template.hpp.in index 9f1713f518..e8e0548267 100644 --- a/src/header_template.hpp.in +++ b/src/header_template.hpp.in @@ -22,11 +22,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 include as rdc/@header_name@" +#else /* ROCM_HEADER_WRAPPER_WERROR */ +#if defined(__GNUC__) +#warning "This file is deprecated. Use file from include path /opt/rocm-ver/include/ and include as rdc/@header_name@" #else #pragma message("This file is deprecated. Use file from include path /opt/rocm-ver/include/ and include as rdc/@header_name@") #endif +#endif /* ROCM_HEADER_WRAPPER_WERROR */ @include_statements@