VERIFY_INTERFACE_HEADER_SETS: Add IWYU pragma: associated to verification file

This commit is contained in:
Daniel Hannon
2022-10-07 19:00:28 +01:00
parent 269652a814
commit 6942234bf5
2 changed files with 6 additions and 2 deletions

View File

@@ -8760,7 +8760,11 @@ std::string cmGeneratorTarget::GenerateHeaderSetVerificationFile(
cmGeneratedFileStream fout(filename);
fout.SetCopyIfDifferent(true);
fout << "#include <" << headerFilename << ">\n";
// IWYU pragma: associated allows include what you use to
// consider the headerFile as part of the entire language
// unit within include-what-you-use and as a result allows
// one to get IWYU advice for headers :)
fout << "#include <" << headerFilename << "> // IWYU pragma: associated\n";
fout.close();
return filename;

View File

@@ -9,7 +9,7 @@ function(check_file target filename)
if(filename MATCHES "^(.*)(\\.[a-z]+)$")
set(header_filename "${CMAKE_MATCH_1}")
endif()
set(expected_contents "#include <${header_filename}>\n")
set(expected_contents "#include <${header_filename}> // IWYU pragma: associated\n")
file(READ "${full_filename}" actual_contents)
if(NOT actual_contents STREQUAL expected_contents)