VERIFY_INTERFACE_HEADER_SETS: Add IWYU pragma: associated to verification file

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

No files matched your search

+5 -1
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;
@@ -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)