From 7f97ff3c6550de154c5c55434a74e6b2ddb2d012 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Thu, 6 Nov 2025 16:14:02 -0700 Subject: [PATCH] Add an include-what-you-use option Name: AIS_USE_IWYU (default OFF) --- CMakeLists.txt | 5 +++++ cmake/AISIWYU.cmake | 16 ++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 cmake/AISIWYU.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 1306be49..1cbeecb7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -141,6 +141,11 @@ option(BUILD_CODE_COVERAGE "Build with code coverage flags (llvm C++ only)" OFF) #---------------------------------------------- include(AISClangSafeBuffers) +#---------------------------- +# include-what-you-use (IWYU) +#---------------------------- +include(AISIWYU) + #------------------- # Sanitizer options #------------------- diff --git a/cmake/AISIWYU.cmake b/cmake/AISIWYU.cmake new file mode 100644 index 00000000..2dafcb32 --- /dev/null +++ b/cmake/AISIWYU.cmake @@ -0,0 +1,16 @@ +# Copyright (c) Advanced Micro Devices, Inc. All rights reserved. +# +# SPDX-License-Identifier: MIT + +#----------------------------------------------------------------------------- +# Option to add the include-what-you-use tool +# +# When this option is enabled, compilation will emit IWYU suggestions. +#----------------------------------------------------------------------------- +option(AIS_USE_IWYU "Run include-what-you-use when compiling" OFF) + +if(AIS_USE_IWYU) + find_program(IWYU_EXE NAMES include-what-you-use REQUIRED) + set(CMAKE_C_INCLUDE_WHAT_YOU_USE ${IWYU_EXE}) + set(CMAKE_CXX_INCLUDE_WHAT_YOU_USE ${IWYU_EXE}) +endif()