mirror of
https://github.com/Kitware/CMake.git
synced 2025-12-30 10:20:56 -06:00
FILE_SET: Fix source group detection
Call MatchChildrenFiles() instead of MatchesFiles() in order to account for files being in subgroups of source groups. Fixes: #23880
This commit is contained in:
@@ -1702,7 +1702,7 @@ void addFileSetEntry(cmGeneratorTarget const* headTarget,
|
||||
}
|
||||
bool found = false;
|
||||
for (auto const& sg : headTarget->Makefile->GetSourceGroups()) {
|
||||
if (sg.MatchesFiles(path)) {
|
||||
if (sg.MatchChildrenFiles(path)) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -124,6 +124,21 @@ cmSourceGroup* cmSourceGroup::MatchChildrenFiles(const std::string& name)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const cmSourceGroup* cmSourceGroup::MatchChildrenFiles(
|
||||
const std::string& name) const
|
||||
{
|
||||
if (this->MatchesFiles(name)) {
|
||||
return this;
|
||||
}
|
||||
for (const cmSourceGroup& group : this->Internal->GroupChildren) {
|
||||
const cmSourceGroup* result = group.MatchChildrenFiles(name);
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
cmSourceGroup* cmSourceGroup::MatchChildrenRegex(const std::string& name)
|
||||
{
|
||||
for (cmSourceGroup& group : this->Internal->GroupChildren) {
|
||||
|
||||
@@ -79,6 +79,12 @@ public:
|
||||
*/
|
||||
cmSourceGroup* MatchChildrenFiles(const std::string& name);
|
||||
|
||||
/**
|
||||
* Check if the given name matches this group's explicit file list
|
||||
* in children.
|
||||
*/
|
||||
const cmSourceGroup* MatchChildrenFiles(const std::string& name) const;
|
||||
|
||||
/**
|
||||
* Check if the given name matches this group's regex in children.
|
||||
*/
|
||||
|
||||
@@ -16,6 +16,7 @@ run_cmake(NoImpLib)
|
||||
run_cmake(RuntimeLibrary)
|
||||
run_cmake(SourceGroupCMakeLists)
|
||||
run_cmake(SourceGroupTreeCMakeLists)
|
||||
run_cmake(SourceGroupFileSet)
|
||||
run_cmake(VsConfigurationType)
|
||||
run_cmake(VsTargetsFileReferences)
|
||||
run_cmake(VsCustomProps)
|
||||
|
||||
13
Tests/RunCMake/VS10Project/SourceGroupFileSet-check.cmake
Normal file
13
Tests/RunCMake/VS10Project/SourceGroupFileSet-check.cmake
Normal file
@@ -0,0 +1,13 @@
|
||||
cmake_policy(SET CMP0011 NEW)
|
||||
|
||||
set(vcFiltersFile "${RunCMake_TEST_BINARY_DIR}/SourceGroupFileSet.vcxproj.filters")
|
||||
if(NOT EXISTS "${vcFiltersFile}")
|
||||
set(RunCMake_TEST_FAILED "Filters file ${vcFiltersFile} does not exist.")
|
||||
return()
|
||||
endif()
|
||||
|
||||
file(STRINGS "${vcFiltersFile}" lines)
|
||||
|
||||
include(${RunCMake_TEST_SOURCE_DIR}/SourceGroupHelpers.cmake)
|
||||
|
||||
find_source_group("${lines}" "Header Files\\SourceGroupFileSet")
|
||||
3
Tests/RunCMake/VS10Project/SourceGroupFileSet.cmake
Normal file
3
Tests/RunCMake/VS10Project/SourceGroupFileSet.cmake
Normal file
@@ -0,0 +1,3 @@
|
||||
add_library(SourceGroupFileSet INTERFACE)
|
||||
target_sources(SourceGroupFileSet PUBLIC FILE_SET HEADERS FILES iface.h)
|
||||
source_group("Header Files/SourceGroupFileSet" FILES iface.h)
|
||||
Reference in New Issue
Block a user