From ea950b8778cca2b7e7dc0ddc1815d802b67ad9d5 Mon Sep 17 00:00:00 2001 From: Ranjith Ramakrishnan Date: Fri, 10 Mar 2023 08:55:39 -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: Ib49633501aa6eb6d97158b1ecfc47de6f18fba85 [ROCm/amdsmi commit: 14b86107a7f233ccd89b6f6c8d3dbb41184c503c] --- projects/amdsmi/CMakeLists.txt | 15 +++++++++++++++ projects/amdsmi/rocm_smi-backward-compat.cmake | 9 ++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/projects/amdsmi/CMakeLists.txt b/projects/amdsmi/CMakeLists.txt index 1c3446fd4e..5635238099 100755 --- a/projects/amdsmi/CMakeLists.txt +++ b/projects/amdsmi/CMakeLists.txt @@ -148,6 +148,21 @@ add_subdirectory("oam") option(FILE_REORG_BACKWARD_COMPATIBILITY "Enable File Reorg with backward compatibility" ON) 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(rocm_smi-backward-compat.cmake) endif() diff --git a/projects/amdsmi/rocm_smi-backward-compat.cmake b/projects/amdsmi/rocm_smi-backward-compat.cmake index 5f89f2e7f5..fe447f1863 100644 --- a/projects/amdsmi/rocm_smi-backward-compat.cmake +++ b/projects/amdsmi/rocm_smi-backward-compat.cmake @@ -62,11 +62,18 @@ function(create_header_template) #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 @prefix_name@\" +#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 @prefix_name@\" #else #pragma message(\"This file is deprecated. Use file from include path /opt/rocm-ver/include/ and prefix with @prefix_name@\") #endif +#endif /* ROCM_HEADER_WRAPPER_WERROR */ @include_statements@