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: Ib48e361b72176e2845c8f74f980f0234e7eb4a7d
This commit is contained in:
Ranjith Ramakrishnan
2023-03-10 08:38:09 -08:00
parent 7e403f08a6
commit 629ddde072
2 ha cambiato i file con 26 aggiunte e 0 eliminazioni
+15
Vedi File
@@ -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
@@ -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")