diff --git a/projects/rocr-runtime/CMakeLists.txt b/projects/rocr-runtime/CMakeLists.txt index 7e78bfbe79..c447d6de98 100644 --- a/projects/rocr-runtime/CMakeLists.txt +++ b/projects/rocr-runtime/CMakeLists.txt @@ -210,6 +210,20 @@ install ( DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/ DESTINATION ${CMAKE_INS # Option to build header path migration helpers. option(INCLUDE_PATH_COMPATIBILITY "Generate backward compatible headers and include paths. Use of these headers will warn when included." ON) if(INCLUDE_PATH_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(hsakmt-backward-compat.cmake) endif() diff --git a/projects/rocr-runtime/hsakmt-backward-compat.cmake b/projects/rocr-runtime/hsakmt-backward-compat.cmake index 68b81a803a..3c5adabb42 100644 --- a/projects/rocr-runtime/hsakmt-backward-compat.cmake +++ b/projects/rocr-runtime/hsakmt-backward-compat.cmake @@ -46,12 +46,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 \"@file_name@ has moved to @CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_INCLUDEDIR@/hsakmt and package include paths have changed.\\nInclude as \\\"hsakmt/@file_name@\\\" when using cmake packages.\" +#else /* ROCM_HEADER_WRAPPER_WERROR 0 */ +#if defined(__GNUC__) +#warning \"@file_name@ has moved to @CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_INCLUDEDIR@/hsakmt and package include paths have changed.\\nInclude as \\\"hsakmt/@file_name@\\\" when using cmake packages.\" #else #pragma message(\"@file_name@ has moved to @CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_INCLUDEDIR@/hsakmt and package include paths have changed.\\nInclude as \\\"hsakmt/@file_name@\\\" when using cmake packages.\") #endif +#endif /* ROCM_HEADER_WRAPPER_WERROR */ @include_statements@