Skip to content

Commit

Permalink
Add basic scoped suppression of ROCMChecks
Browse files Browse the repository at this point in the history
  • Loading branch information
lawruble13 committed Nov 9, 2023
1 parent 3eb1a3b commit cbbc80c
Showing 1 changed file with 45 additions and 10 deletions.
55 changes: 45 additions & 10 deletions share/rocmcmakebuildtools/cmake/ROCMChecks.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,20 @@ if(DEFINED ENV{ROCMCHECKS_ERROR_TOOLCHAIN_VAR})
set(ROCM_ERROR_TOOLCHAIN_VAR $ENV{ROCMCHECKS_ERROR_TOOLCHAIN_VAR})
endif()

define_property(GLOBAL PROPERTY ROCMChecksSuppressed INHERITED
BRIEF_DOCS "Property to indicate suppression of ROCMChecks."
FULL_DOCS "Property to indicate suppression of ROCMChecks."
)
define_property(GLOBAL PROPERTY ROCMChecksWatched
BRIEF_DOCS "Property recording variables watched by ROCMChecks."
FULL_DOCS "Property recording variables watched by ROCMChecks."
)

function(rocm_check_toolchain_var var access value list_file)
get_property(suppressed GLOBAL PROPERTY ROCMChecksSuppressed)
if ((NOT "${suppressed}" STREQUAL "") AND suppressed)
return()
endif()
set(message_type STATUS)
if(ROCM_ERROR_TOOLCHAIN_VAR)
set(message_type SEND_ERROR)
Expand Down Expand Up @@ -50,17 +63,39 @@ function(rocm_check_toolchain_var var access value list_file)
endif()
endif()
endfunction()

function(rocm_variable_watch VAR)
set_property(GLOBAL APPEND PROPERTY ROCMChecksWatched "${VAR}")
variable_watch("${VAR}" rocm_check_toolchain_var)
endfunction

function(add_subdirectory_unchecked source_directory)
get_property(watched_vars GLOBAL PROPERTY ROCMChecksWatched)
set_property(GLOBAL PROPERTY ROCMChecksSuppressed "ON")
foreach(var IN_LISTS watched_vars)
set(_rocmchecks_restore_${var} "${var}" CACHE INTERNAL)
endforeach()
add_subdirectory(${ARGV})
foreach(var IN_LISTS watched_vars)
if (DEFINED CACHE{${var}})
set(${var} "$CACHE{_rocmchecks_restore_${var}}")
endif()
unset(_rocmchecks_restore_${var} CACHE)
endforeach()
set_property(GLOBAL PROPERTY ROCMChecksSuppressed "OFF")
endfunction()

if(UNIX AND (ROCM_WARN_TOOLCHAIN_VAR OR ROCM_ERROR_TOOLCHAIN_VAR))
foreach(LANG C CXX Fortran)
variable_watch(CMAKE_${LANG}_COMPILER rocm_check_toolchain_var)
variable_watch(CMAKE_${LANG}_FLAGS rocm_check_toolchain_var)
variable_watch(CMAKE_${LANG}_LINK_EXECUTABLE rocm_check_toolchain_var)
variable_watch(CMAKE_${LANG}_SIZEOF_DATA_PTR rocm_check_toolchain_var)
variable_watch(CMAKE_${LANG}_STANDARD_INCLUDE_DIRECTORIES rocm_check_toolchain_var)
variable_watch(CMAKE_${LANG}_STANDARD_LIBRARIES rocm_check_toolchain_var)
rocm_variable_watch(CMAKE_${LANG}_COMPILER)
rocm_variable_watch(CMAKE_${LANG}_FLAGS)
rocm_variable_watch(CMAKE_${LANG}_LINK_EXECUTABLE)
rocm_variable_watch(CMAKE_${LANG}_SIZEOF_DATA_PTR)
rocm_variable_watch(CMAKE_${LANG}_STANDARD_INCLUDE_DIRECTORIES)
rocm_variable_watch(CMAKE_${LANG}_STANDARD_LIBRARIES)
endforeach()
variable_watch(CMAKE_EXE_LINKER_FLAGS rocm_check_toolchain_var)
variable_watch(CMAKE_MODULE_LINKER_FLAGS rocm_check_toolchain_var)
variable_watch(CMAKE_SHARED_LINKER_FLAGS rocm_check_toolchain_var)
variable_watch(CMAKE_STATIC_LINKER_FLAGS rocm_check_toolchain_var)
rocm_variable_watch(CMAKE_EXE_LINKER_FLAGS)
rocm_variable_watch(CMAKE_MODULE_LINKER_FLAGS)
rocm_variable_watch(CMAKE_SHARED_LINKER_FLAGS)
rocm_variable_watch(CMAKE_STATIC_LINKER_FLAGS)
endif()

0 comments on commit cbbc80c

Please sign in to comment.