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()