CMake 4.5.0: source_group() undocumented prefix detection change: regression or intentional?

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?

I disagree, the documentation seems pretty clear about this erroneous usage of source_group:

The command fails if the paths within src do not start with root.

A file path must start with the value of root.

The problem is this erroneous usage was not detected previsoulsy.

the documentation seems pretty clear about this […]

I mean, that’s a matter of definition. The paths in question were

/dir/thing
/dir/thing.cpp

Arguments can be made for either side that /dir/thing.cpp does indeed (or does not) start with /dir/thing.

EDIT: In retrospect, “cutting paths to be relative to root” wouldn’t make much sense otherwise…

There is indeed only one correct option here. This is simply a bug fix then.