From 86382934b9b8e690f9c1f6a19ac43ad1184cd398 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Sun, 9 Nov 2025 10:46:45 -0800 Subject: [PATCH 1/2] Add `include-what-you-use` support to CMake --- CMakeLists.txt | 11 +++++++++++ release_docs/CHANGELOG.md | 8 ++++++++ 2 files changed, 19 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index d608b39b534..8295b232c4a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -676,6 +676,17 @@ if (HDF5_ENABLE_COVERAGE) endif () endif () +#----------------------------------------------------------------------------- +# Option to use build with include-what-you-use +#----------------------------------------------------------------------------- +option(HDF5_USE_IWYU "Run include-what-you-use when compiling" OFF) + +if(HDF5_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() + #----------------------------------------------------------------------------- # Option to indicate using a memory checker #----------------------------------------------------------------------------- diff --git a/release_docs/CHANGELOG.md b/release_docs/CHANGELOG.md index 9125c2444c0..fcd5fa344d6 100644 --- a/release_docs/CHANGELOG.md +++ b/release_docs/CHANGELOG.md @@ -83,6 +83,14 @@ We would like to thank the many HDF5 community members who contributed to HDF5 2 ## Configuration +### Added CMake support for include-what-you-use + + Adds an `HDF5_USE_IWYU` option to CMake (default OFF). This will run the `include-what-you-use` tool while compiling. + + See https://include-what-you-use.org/ for more information. + + This requires `include-what-you-use` to be installed. + ### Improved the cross-compile support in the build system The CMake build system has been improved to better support cross-compiling. This includes the following changes: From 5b4b895c58ea43320e6e2f9048facd7a8fcf80f8 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Sun, 9 Nov 2025 10:52:05 -0800 Subject: [PATCH 2/2] Fix typo --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8295b232c4a..6f9d0cca9e5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -677,7 +677,7 @@ if (HDF5_ENABLE_COVERAGE) endif () #----------------------------------------------------------------------------- -# Option to use build with include-what-you-use +# Option to build with include-what-you-use #----------------------------------------------------------------------------- option(HDF5_USE_IWYU "Run include-what-you-use when compiling" OFF)