diff options
author | Brad King <brad.king@kitware.com> | 2021-05-19 18:27:04 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2021-05-25 14:48:26 (GMT) |
commit | c564a3e3fff52ef811291c5ba8fb07a5a1b47f97 (patch) | |
tree | aaeb51363d6158ad9768c31384e17c6dbfd44d32 /Source/cmLocalNinjaGenerator.cxx | |
parent | eb98d4511146db844029c809fde81982d3928e54 (diff) | |
download | CMake-c564a3e3fff52ef811291c5ba8fb07a5a1b47f97.zip CMake-c564a3e3fff52ef811291c5ba8fb07a5a1b47f97.tar.gz CMake-c564a3e3fff52ef811291c5ba8fb07a5a1b47f97.tar.bz2 |
Ninja: Always compile sources using absolute paths
The Ninja generator traditionally referenced source files and include
directories using paths relative to the build directory if they could be
expressed without a `../` sequence that leaves the build and source
directories. For example, when using a `build/` directory inside the
source tree, sources would be compiled as `-c ../src.c` and include
directories would be referenced as `-I ../include`. This approach
matches the traditional Ninja convention of using relative paths
whenever possible, but has undesirable side effects such as:
* Compiler diagnostic messages may not use absolute paths, making it
harder for IDEs/editors to find the referenced sources or headers.
* Debug symbols may not use absolute paths, making it harder for
debuggers to find the referenced sources or headers.
* Different results depending on the path to the build tree relative
to the source tree.
* Inconsistent with the Makefile generators, which use absolute paths.
Switch to always using absolute paths to reference source files and
include directories on compiler command lines. While alternative
solutions for diagnostic messages and debug symbols may exist with
specific tooling, this is the simplest and most consistent approach.
Note that a previous attempt to do this in commit 955c2a630a (Ninja: Use
full path for all source files, 2016-08-05, v3.7.0-rc1~275^2) was
reverted by commit 666ad1df2d (Revert "Ninja: Use full path for all
source files", 2017-02-24, v3.8.0-rc2~9^2) due to problems hooking up
depfile dependencies on generated files. This time, the changes in
commit 2725ecff38 (Ninja: Handle depfiles with absolute paths to
generated files, 2021-05-19) should avoid those problems.
Fixes: #13894, #17450
Diffstat (limited to 'Source/cmLocalNinjaGenerator.cxx')
-rw-r--r-- | Source/cmLocalNinjaGenerator.cxx | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index 22a1a1a..8142599 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -208,11 +208,9 @@ std::string cmLocalNinjaGenerator::ConvertToIncludeReference( std::string const& path, IncludePathStyle pathStyle, cmOutputConverter::OutputFormat format) { - if (pathStyle == IncludePathStyle::Absolute) { - return this->ConvertToOutputFormat(path, format); - } - return this->ConvertToOutputFormat(this->MaybeRelativeToTopBinDir(path), - format); + // FIXME: Remove IncludePathStyle infrastructure. It is no longer used. + static_cast<void>(pathStyle); + return this->ConvertToOutputFormat(path, format); } // Private methods. |