summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKinan Mahdi <kinan.mahdi@gmail.com>2020-10-02 14:56:01 (GMT)
committerBrad King <brad.king@kitware.com>2020-10-05 16:49:14 (GMT)
commit8d87cfdbf34671ad80cf584456dfdb565007f869 (patch)
treeec5d4aba9a7e8c42f227dbf39e5b1a0783e39ccd
parent177fc020731bcee747295573c92cd0f7ca200e53 (diff)
downloadCMake-8d87cfdbf34671ad80cf584456dfdb565007f869.zip
CMake-8d87cfdbf34671ad80cf584456dfdb565007f869.tar.gz
CMake-8d87cfdbf34671ad80cf584456dfdb565007f869.tar.bz2
VS: Fix regression in C# source links
Fix logic used since commit ac6b18cd90 (CSharp: Add support for source groups with out-of-source builds, 2020-02-18, v3.18.0-rc1~645^2). Add a check of the physical file location for C# source groups.
-rw-r--r--Source/cmVisualStudio10TargetGenerator.cxx9
-rw-r--r--Tests/RunCMake/VS10Project/VsCsharpSourceGroup-check.cmake9
-rw-r--r--Tests/RunCMake/VS10Project/VsCsharpSourceGroup.cmake8
-rw-r--r--Tests/RunCMake/VS10Project/VsCsharpSourceGroup.png0
4 files changed, 20 insertions, 6 deletions
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index a8e424d..f58c6fd 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -4927,6 +4927,7 @@ std::string cmVisualStudio10TargetGenerator::GetCSharpSourceLink(
// for this file exists, otherwise we check if the path relative to current
// source- or binary-dir is used within the link and return that
std::string link;
+ std::string sourceGroupedFile;
std::string const& fullFileName = source->GetFullPath();
std::string const& srcDir = this->Makefile->GetCurrentSourceDirectory();
std::string const& binDir = this->Makefile->GetCurrentBinaryDirectory();
@@ -4936,8 +4937,14 @@ std::string cmVisualStudio10TargetGenerator::GetCSharpSourceLink(
cmSourceGroup* sourceGroup =
this->Makefile->FindSourceGroup(fullFileName, sourceGroups);
if (sourceGroup && !sourceGroup->GetFullName().empty()) {
- link = sourceGroup->GetFullName() + "/" +
+ sourceGroupedFile = sourceGroup->GetFullName() + "/" +
cmsys::SystemTools::GetFilenameName(fullFileName);
+ cmsys::SystemTools::ConvertToUnixSlashes(sourceGroupedFile);
+ }
+
+ if (!sourceGroupedFile.empty() &&
+ cmHasSuffix(fullFileName, sourceGroupedFile)) {
+ link = sourceGroupedFile;
} else if (cmHasPrefix(fullFileName, srcDir)) {
link = fullFileName.substr(srcDir.length() + 1);
} else if (cmHasPrefix(fullFileName, binDir)) {
diff --git a/Tests/RunCMake/VS10Project/VsCsharpSourceGroup-check.cmake b/Tests/RunCMake/VS10Project/VsCsharpSourceGroup-check.cmake
index 3b5c70f..80d76e4 100644
--- a/Tests/RunCMake/VS10Project/VsCsharpSourceGroup-check.cmake
+++ b/Tests/RunCMake/VS10Project/VsCsharpSourceGroup-check.cmake
@@ -9,12 +9,13 @@ file(STRINGS "${csProjFile}" lines)
include(${RunCMake_TEST_SOURCE_DIR}/VsCsharpSourceGroupHelpers.cmake)
set(SOURCE_GROUPS_TO_FIND
- "CSharpSourceGroup"
- "CSharpSourceGroup/nested"
- "Images"
+ "CSharpSourceGroup\\\\foo\\.cs"
+ "CSharpSourceGroup\\\\nested\\\\baz\\.cs"
+ "CSharpSourceGroup\\\\images\\\\empty\\.bmp"
+ "VsCsharpSourceGroup\\.png"
)
-foreach(GROUP_NAME IN LISTS ${SOURCE_GROUPS_TO_FIND})
+foreach(GROUP_NAME IN LISTS SOURCE_GROUPS_TO_FIND)
find_source_group("${lines}" ${GROUP_NAME})
if(NOT ${SOURCE_GROUP_FOUND})
return()
diff --git a/Tests/RunCMake/VS10Project/VsCsharpSourceGroup.cmake b/Tests/RunCMake/VS10Project/VsCsharpSourceGroup.cmake
index 024993c..510d712 100644
--- a/Tests/RunCMake/VS10Project/VsCsharpSourceGroup.cmake
+++ b/Tests/RunCMake/VS10Project/VsCsharpSourceGroup.cmake
@@ -9,8 +9,14 @@ set(SRC_FILES
set(IMAGE_FILES
${CMAKE_CURRENT_SOURCE_DIR}/CSharpSourceGroup/Images/empty.bmp
)
+# We explicitly don't set a source group for a source in the root level
+# because of https://gitlab.kitware.com/cmake/cmake/-/issues/21221
+set(RESOURCE_FILES
+ ${CMAKE_CURRENT_SOURCE_DIR}/VsCsharpSourceGroup.png
+)
+
-add_library(VsCsharpSourceGroup SHARED ${SRC_FILES} ${IMAGE_FILES})
+add_library(VsCsharpSourceGroup SHARED ${SRC_FILES} ${IMAGE_FILES} ${RESOURCE_FILES})
source_group("CSharpSourceGroup" FILES ${CMAKE_CURRENT_SOURCE_DIR}/CSharpSourceGroup/foo.cs)
source_group("CSharpSourceGroup/nested" FILES ${CMAKE_CURRENT_SOURCE_DIR}/CSharpSourceGroup/nested/baz.cs)
source_group("Images" FILES ${IMAGE_FILES})
diff --git a/Tests/RunCMake/VS10Project/VsCsharpSourceGroup.png b/Tests/RunCMake/VS10Project/VsCsharpSourceGroup.png
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Tests/RunCMake/VS10Project/VsCsharpSourceGroup.png