Skip to content

Makefiles: Restore path consistency in the global dispatch makefile

Brad King requested to merge brad.king/cmake:makefile-path-consistency into master

Directory-level rules in CMakeFiles/Makefile2 were previously previously written by each directory's local generator using its own decision for using relative or absolute paths.

Since !7020 (merged), each local generator explicitly models the relationship between its source and build paths, and uses this to determine when it is safe to use relative paths. Because add_subdirectory supports arbitrary placement of the source and build directories, different local generators may have different relationships between their source and build paths. This can cause disagreement among rules written to CMakeFiles/Makefile2.

Restore consistency by always using the root local generator to write rules to CMakeFiles/Makefile2. Relative paths should always be expressed w.r.t. the top-level build directory since that is the working directory in which the make tool processing the file will run.

Fixes: #23814 (closed)
Backport: release

Merge request reports