diff --git a/runtime/hsa-runtime/CMakeLists.txt b/runtime/hsa-runtime/CMakeLists.txt index f0e14c3b6e..bd7eb45a77 100644 --- a/runtime/hsa-runtime/CMakeLists.txt +++ b/runtime/hsa-runtime/CMakeLists.txt @@ -312,6 +312,21 @@ install ( DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/inc/ DESTINATION ${CMAKE_INSTALL # 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(hsa-backward-compat.cmake) target_include_directories( ${CORE_RUNTIME_TARGET} PUBLIC diff --git a/runtime/hsa-runtime/hsa-backward-compat.cmake b/runtime/hsa-runtime/hsa-backward-compat.cmake index 10fc5d3b95..a2b42965d0 100644 --- a/runtime/hsa-runtime/hsa-backward-compat.cmake +++ b/runtime/hsa-runtime/hsa-backward-compat.cmake @@ -48,7 +48,18 @@ function(create_header_template) #ifndef @include_guard@ #define @include_guard@ +#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@/hsa and package include paths have changed.\\nInclude as \\\"hsa/@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@/hsa and package include paths have changed.\\nInclude as \\\"hsa/@file_name@\\\" when using cmake packages.\" +#else +#pragma message(\"@file_name@ has moved to @CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_INCLUDEDIR@/hsa and package include paths have changed.\\nInclude as \\\"hsa/@file_name@\\\" when using cmake packages.\") +#endif +#endif /* ROCM_HEADER_WRAPPER_WERROR */ @include_statements@ #endif")