Consider this file tree:
.
├── CMakeLists.txt
├── thing
│ └── file.cpp
└── thing.cpp
Prior to CMake 4.5.0, the following project configured successfully without any errors:
cmake_minimum_required(VERSION 4.4)
project(my_project NONE)
source_group(TREE thing FILES thing.cpp thing/file.cpp)
Output:
$ ./cmake-4.4.5-linux-x86_64/bin/cmake -S . -B build
-- Configuring done (0.0s)
-- Generating done (0.0s)
-- Build files have been written to: /dir/build
However, with the latest CMake (4.5.0), we get
$ cmake -S . -B build
CMake Error at CMakeLists.txt:4 (source_group):
source_group "/dir/thing" is not a prefix of file
"/dir/thing.cpp"
-- Configuring incomplete, errors occurred!
Admittedly, you could claim that doing this is a bit weird, but nothing in the documentation ever gave a precise description of what it meant for the paths in src to “start with” root. As such, we have projects such as Boost.Locale depending on this old behavior that are now unable to be built using CMake.
The change seems to have been introduced in 44fd6ec when they switched the prefix checking mechanism to use cmCMakePath::IsPrefix, which only returns true if its within a subdirectory of that name or is an exact match. Meanwhile, the old mechanism only checked for string prefix.
Was the above change in semantics intended, or is this some sort of regression?