diff --git a/INSTALL.md b/INSTALL.md index 9208e63f..9bd6996f 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -37,6 +37,7 @@ Options |------|-------|-------| |AIS\_USE\_CLANG\_TIDY|OFF|Run the `clang-tidy` tool| |AIS\_USE\_IWYU|OFF|Run the `include-what-you-use` tool| +|AIS\_WARN\_UNSAFE\_BUFFER\_OPS|ON|Scan code for unsafe buffer operations (clang only, OFF for others)| |BUILD\_AIS\_DOCS|OFF|Build API documentation (requires Doxygen)| |BUILD\_AISCP|ON|Build `aiscp` example program (OFF if no hipFile)| |BUILD\_CODE\_COVERAGE|OFF|Generate code coverage information when tests are run| diff --git a/cmake/AISClangSafeBuffers.cmake b/cmake/AISClangSafeBuffers.cmake index a8281e34..3994f289 100644 --- a/cmake/AISClangSafeBuffers.cmake +++ b/cmake/AISClangSafeBuffers.cmake @@ -9,7 +9,13 @@ # # Fixing this cleanly requires C++20, so it's an option for now #----------------------------------------------------------------------------- -option(AIS_WARN_UNSAFE_BUFFER_OPS "Warn about unsafe buffer operations (llvm C++ only)" OFF) +if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") + set(USE_UBO ON) +else() + set(USE_UBO OFF) +endif() +option(AIS_WARN_UNSAFE_BUFFER_OPS "Warn about unsafe buffer operations (llvm C++ only)" ${USE_UBO}) + if(AIS_WARN_UNSAFE_BUFFER_OPS) if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") set(AIS_CLANG_WARNING_FLAGS @@ -17,5 +23,7 @@ if(AIS_WARN_UNSAFE_BUFFER_OPS) -fsafe-buffer-usage-suggestions ${AIS_CLANG_WARNING_FLAGS} ) + else() + message(FATAL_ERROR "Unsafe buffer warnings are only useful for clang/llvm") endif() endif()