summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2019-01-15 18:19:56 (GMT)
committerKitware Robot <kwrobot@kitware.com>2019-01-15 18:20:01 (GMT)
commitd7835e4d0e6858eeff12c6e8d09a42db6acad4bd (patch)
tree6ef6ceb876c0613e3bead8a54f06627433155a36
parent1d328d8119482ca658434c7eddc07178fd363ae0 (diff)
parent77303314dcd58cc820c5e9ad9c30c0428d59b45a (diff)
downloadCMake-d7835e4d0e6858eeff12c6e8d09a42db6acad4bd.zip
CMake-d7835e4d0e6858eeff12c6e8d09a42db6acad4bd.tar.gz
CMake-d7835e4d0e6858eeff12c6e8d09a42db6acad4bd.tar.bz2
Merge topic 'fix-source-group-CMakeLists.txt'
77303314dc Restore support for a custom source group for CMakeLists.txt Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !2803
-rw-r--r--Source/cmVisualStudio10TargetGenerator.cxx8
-rw-r--r--Tests/RunCMake/VS10Project/RunCMakeTest.cmake1
-rw-r--r--Tests/RunCMake/VS10Project/SourceGroupCMakeLists-check.cmake33
-rw-r--r--Tests/RunCMake/VS10Project/SourceGroupCMakeLists.cmake3
4 files changed, 45 insertions, 0 deletions
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index 5140648..655d6f0 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -1450,6 +1450,14 @@ void cmVisualStudio10TargetGenerator::WriteGroups()
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);
// Write out group file
diff --git a/Tests/RunCMake/VS10Project/RunCMakeTest.cmake b/Tests/RunCMake/VS10Project/RunCMakeTest.cmake
index db375ae..c796840 100644
--- a/Tests/RunCMake/VS10Project/RunCMakeTest.cmake
+++ b/Tests/RunCMake/VS10Project/RunCMakeTest.cmake
@@ -1,6 +1,7 @@
include(RunCMake)
run_cmake(ExplicitCMakeLists)
+run_cmake(SourceGroupCMakeLists)
run_cmake(VsConfigurationType)
run_cmake(VsTargetsFileReferences)
diff --git a/Tests/RunCMake/VS10Project/SourceGroupCMakeLists-check.cmake b/Tests/RunCMake/VS10Project/SourceGroupCMakeLists-check.cmake
new file mode 100644
index 0000000..c2a94bb
--- /dev/null
+++ b/Tests/RunCMake/VS10Project/SourceGroupCMakeLists-check.cmake
@@ -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()
diff --git a/Tests/RunCMake/VS10Project/SourceGroupCMakeLists.cmake b/Tests/RunCMake/VS10Project/SourceGroupCMakeLists.cmake
new file mode 100644
index 0000000..4ad87ec
--- /dev/null
+++ b/Tests/RunCMake/VS10Project/SourceGroupCMakeLists.cmake
@@ -0,0 +1,3 @@
+set(CMAKE_CONFIGURATION_TYPES Debug)
+add_custom_target(foo)
+source_group("CMakeListsSourceGroup" FILES CMakeLists.txt)