mirror of
https://github.com/Kitware/CMake.git
synced 2026-02-20 14:10:27 -06:00
Restore support for a custom source group for CMakeLists.txt
Since commit v3.11.0-rc1~467^2 (VS,Xcode: Add CMakeLists.txt sources without mutating targets, 2017-10-18) we do not add `CMakeLists.txt` to target sources but instead generate references to them directly. This accidentally dropped generation of the `.vcxproj.filters` entry for a source group in which `CMakeLists.txt` is the only member. Fixes: #18795
This commit is contained in:
@@ -1419,6 +1419,14 @@ void cmVisualStudio10TargetGenerator::WriteGroups()
|
|||||||
groupsUsed.insert(sourceGroup);
|
groupsUsed.insert(sourceGroup);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (cmSourceFile const* srcCMakeLists =
|
||||||
|
this->LocalGenerator->CreateVCProjBuildRule()) {
|
||||||
|
std::string const& source = srcCMakeLists->GetFullPath();
|
||||||
|
cmSourceGroup* sourceGroup =
|
||||||
|
this->Makefile->FindSourceGroup(source, sourceGroups);
|
||||||
|
groupsUsed.insert(sourceGroup);
|
||||||
|
}
|
||||||
|
|
||||||
this->AddMissingSourceGroups(groupsUsed, sourceGroups);
|
this->AddMissingSourceGroups(groupsUsed, sourceGroups);
|
||||||
|
|
||||||
// Write out group file
|
// Write out group file
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
include(RunCMake)
|
include(RunCMake)
|
||||||
|
|
||||||
run_cmake(ExplicitCMakeLists)
|
run_cmake(ExplicitCMakeLists)
|
||||||
|
run_cmake(SourceGroupCMakeLists)
|
||||||
|
|
||||||
run_cmake(VsConfigurationType)
|
run_cmake(VsConfigurationType)
|
||||||
run_cmake(VsTargetsFileReferences)
|
run_cmake(VsTargetsFileReferences)
|
||||||
|
|||||||
33
Tests/RunCMake/VS10Project/SourceGroupCMakeLists-check.cmake
Normal file
33
Tests/RunCMake/VS10Project/SourceGroupCMakeLists-check.cmake
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
set(vcFiltersFile "${RunCMake_TEST_BINARY_DIR}/foo.vcxproj.filters")
|
||||||
|
if(NOT EXISTS "${vcFiltersFile}")
|
||||||
|
set(RunCMake_TEST_FAILED "Filters file ${vcFiltersFile} does not exist.")
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(foundFileFilter 0)
|
||||||
|
set(foundFilter 0)
|
||||||
|
file(STRINGS "${vcFiltersFile}" lines)
|
||||||
|
foreach(line IN LISTS lines)
|
||||||
|
if(line MATCHES "<Filter>CMakeListsSourceGroup</Filter>")
|
||||||
|
set(rule "${CMAKE_MATCH_1}")
|
||||||
|
if(foundFileFilter)
|
||||||
|
set(RunCMake_TEST_FAILED "Multiple files listed with filter for CMakeListsSourceGroup.")
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
set(foundFileFilter 1)
|
||||||
|
endif()
|
||||||
|
if(line MATCHES "<Filter.*Include=\"CMakeListsSourceGroup\"")
|
||||||
|
set(rule "${CMAKE_MATCH_1}")
|
||||||
|
if(foundFilter)
|
||||||
|
set(RunCMake_TEST_FAILED "Multiple copies of CMakeListsSourceGroup filter listed.")
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
set(foundFilter 1)
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
if(NOT foundFileFilter)
|
||||||
|
set(RunCMake_TEST_FAILED "File filter for CMakeListsSourceGroup not found.")
|
||||||
|
endif()
|
||||||
|
if(NOT foundFilter)
|
||||||
|
set(RunCMake_TEST_FAILED "Filter CMakeListsSourceGroup not found.")
|
||||||
|
endif()
|
||||||
3
Tests/RunCMake/VS10Project/SourceGroupCMakeLists.cmake
Normal file
3
Tests/RunCMake/VS10Project/SourceGroupCMakeLists.cmake
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
set(CMAKE_CONFIGURATION_TYPES Debug)
|
||||||
|
add_custom_target(foo)
|
||||||
|
source_group("CMakeListsSourceGroup" FILES CMakeLists.txt)
|
||||||
Reference in New Issue
Block a user