Skip to content

Fix computing relative paths with empty components

Ghost User requested to merge (removed):issue-16892 into master

When generating files with full path containing more than one "/" (slash) in a row in the path, it causes re-configuration of the project upon each build phase, despite the fact that the build tree/sources have not been updated.

The issue is caused by the fact that the generated file is listed in the CMAKE_MAKEFILE_PRODUCTS with the wrong path. Which is due to the fact that the relative path of the file is resolved incorrectly.

Step to reproduce:

Create a CMakeLists.txt with the following content:

set(file_path ${CMAKE_BINARY_DIR}//a_file.txt)

file(GENERATE OUTPUT ${file_path} CONTENT "
   Generating file with 2 times in a row slashes to check
   relative path resolution for this file when build byproducts
   are generated")

Configure a build directory referring to the above created cmake list file.

> mkdir build
> cd build
> cmake _path_to/CMakeLists.txt -G "Unix Makefiles"

Now build the project:

> make

Expected result: The project should not be configured upon build, unless anything is changed in the build tree or in the sources.

Actual result: The project is configured one more time before build, as "/a_file.txt" byproduct dependency/existence is never satisfied.

Co-Authored-By: Aregnaz Harutyunyan aregnaz.harutyunyan@here.com
Fixes: #16892 (closed)
Topic-rename: relative-path-handle-empty-components

Merge request reports

Loading