mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-07 14:20:06 -06:00
`include-what-you-use` diagnostics, in practice, are specific to the environment's compiler and standard library. Update includes to satisfy IWYU for our CI job under Debian 13. Some patterns: * Types named in virtual `override` signatures no longer require includes since the overridden signature already names them. * A function argument's type needs to be included even if its constructor is called only by implicit conversion. For example, constructing a `std::function` from a lambda now requires `<functional>`. * Some prior mysterious `<type_traits>` inclusions are no longer required.
48 lines
1.4 KiB
C++
48 lines
1.4 KiB
C++
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
|
file LICENSE.rst or https://cmake.org/licensing for details. */
|
|
#include "cmGccDepfileReader.h"
|
|
|
|
#include <utility>
|
|
#include <vector>
|
|
|
|
#include <cm/optional>
|
|
|
|
#include "cmGccDepfileLexerHelper.h"
|
|
#include "cmStringAlgorithms.h"
|
|
#include "cmSystemTools.h"
|
|
|
|
cm::optional<cmGccDepfileContent> cmReadGccDepfile(
|
|
char const* filePath, std::string const& prefix,
|
|
GccDepfilePrependPaths prependPaths)
|
|
{
|
|
cmGccDepfileLexerHelper helper;
|
|
if (!helper.readFile(filePath)) {
|
|
return cm::nullopt;
|
|
}
|
|
auto deps = cm::make_optional(std::move(helper).extractContent());
|
|
|
|
for (auto& dep : *deps) {
|
|
for (auto& rule : dep.rules) {
|
|
if (prependPaths == GccDepfilePrependPaths::All && !prefix.empty() &&
|
|
!cmSystemTools::FileIsFullPath(rule)) {
|
|
rule = cmStrCat(prefix, '/', rule);
|
|
}
|
|
if (cmSystemTools::FileIsFullPath(rule)) {
|
|
rule = cmSystemTools::CollapseFullPath(rule);
|
|
}
|
|
cmSystemTools::ConvertToLongPath(rule);
|
|
}
|
|
for (auto& path : dep.paths) {
|
|
if (!prefix.empty() && !cmSystemTools::FileIsFullPath(path)) {
|
|
path = cmStrCat(prefix, '/', path);
|
|
}
|
|
if (cmSystemTools::FileIsFullPath(path)) {
|
|
path = cmSystemTools::CollapseFullPath(path);
|
|
}
|
|
cmSystemTools::ConvertToLongPath(path);
|
|
}
|
|
}
|
|
|
|
return deps;
|
|
}
|