summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBen Boeckel <ben.boeckel@kitware.com>2024-02-13 19:52:00 (GMT)
committerBen Boeckel <ben.boeckel@kitware.com>2024-02-14 16:51:05 (GMT)
commit0f0d853de7054f2ed31253b21aabdb0855510b8f (patch)
treeee10e8a6dd6e80315f040f73400b40155740f40b
parent5e984bb35232116a54de7db39788cb162ca7c263 (diff)
downloadCMake-0f0d853de7054f2ed31253b21aabdb0855510b8f.zip
CMake-0f0d853de7054f2ed31253b21aabdb0855510b8f.tar.gz
CMake-0f0d853de7054f2ed31253b21aabdb0855510b8f.tar.bz2
cmDyndepCollation: collapse full path before looking up
`cmSourceFile::GetFullPath()` performs a `CollapseFullPath` before storing the path. Match this behavior when looking up paths from the source file set constructions. Fixes: #25614
-rw-r--r--Source/cmDyndepCollation.cxx5
-rw-r--r--Tests/RunCMake/CXXModules/RunCMakeTest.cmake1
-rw-r--r--Tests/RunCMake/CXXModules/examples/file-sets-with-dot/CMakeLists.txt18
-rw-r--r--Tests/RunCMake/CXXModules/examples/file-sets-with-dot/importable.cxx6
-rw-r--r--Tests/RunCMake/CXXModules/examples/file-sets-with-dot/main.cxx6
5 files changed, 34 insertions, 2 deletions
diff --git a/Source/cmDyndepCollation.cxx b/Source/cmDyndepCollation.cxx
index edf56ff..2ce0f54 100644
--- a/Source/cmDyndepCollation.cxx
+++ b/Source/cmDyndepCollation.cxx
@@ -119,7 +119,8 @@ Json::Value CollationInformationCxxModules(
for (auto const& files_per_dir : files_per_dirs) {
for (auto const& file : files_per_dir.second) {
- auto lookup = sf_map.find(file);
+ auto const full_file = cmSystemTools::CollapseFullPath(file);
+ auto lookup = sf_map.find(full_file);
if (lookup == sf_map.end()) {
gt->Makefile->IssueMessage(
MessageType::FATAL_ERROR,
@@ -147,7 +148,7 @@ Json::Value CollationInformationCxxModules(
Json::Value& tdi_module_info = tdi_cxx_module_info[obj_path] =
Json::objectValue;
- tdi_module_info["source"] = file;
+ tdi_module_info["source"] = full_file;
tdi_module_info["bmi-only"] = ct == CompileType::BmiOnly;
tdi_module_info["relative-directory"] = files_per_dir.first;
tdi_module_info["name"] = file_set->GetName();
diff --git a/Tests/RunCMake/CXXModules/RunCMakeTest.cmake b/Tests/RunCMake/CXXModules/RunCMakeTest.cmake
index 0ac60e0..2a93aeb 100644
--- a/Tests/RunCMake/CXXModules/RunCMakeTest.cmake
+++ b/Tests/RunCMake/CXXModules/RunCMakeTest.cmake
@@ -171,6 +171,7 @@ run_cxx_module_test(scan-with-pch)
# Tests which use named modules.
if ("named" IN_LIST CMake_TEST_MODULE_COMPILATION)
run_cxx_module_test(simple)
+ run_cxx_module_test(file-sets-with-dot)
run_cxx_module_test(vs-without-flags)
run_cxx_module_test(library library-static -DBUILD_SHARED_LIBS=OFF)
run_cxx_module_test(unity-build)
diff --git a/Tests/RunCMake/CXXModules/examples/file-sets-with-dot/CMakeLists.txt b/Tests/RunCMake/CXXModules/examples/file-sets-with-dot/CMakeLists.txt
new file mode 100644
index 0000000..2b16a6a
--- /dev/null
+++ b/Tests/RunCMake/CXXModules/examples/file-sets-with-dot/CMakeLists.txt
@@ -0,0 +1,18 @@
+cmake_minimum_required(VERSION 3.28)
+project(cxx_modules_file_sets_with_dot CXX)
+
+include("${CMAKE_SOURCE_DIR}/../cxx-modules-rules.cmake")
+
+add_executable(file_sets_with_dot)
+target_sources(file_sets_with_dot
+ PRIVATE
+ ./main.cxx
+ PRIVATE
+ FILE_SET CXX_MODULES
+ BASE_DIRS
+ "${CMAKE_CURRENT_SOURCE_DIR}"
+ FILES
+ ./importable.cxx)
+target_compile_features(file_sets_with_dot PUBLIC cxx_std_20)
+
+add_test(NAME file_sets_with_dot COMMAND file_sets_with_dot)
diff --git a/Tests/RunCMake/CXXModules/examples/file-sets-with-dot/importable.cxx b/Tests/RunCMake/CXXModules/examples/file-sets-with-dot/importable.cxx
new file mode 100644
index 0000000..607680a
--- /dev/null
+++ b/Tests/RunCMake/CXXModules/examples/file-sets-with-dot/importable.cxx
@@ -0,0 +1,6 @@
+export module importable;
+
+export int from_import()
+{
+ return 0;
+}
diff --git a/Tests/RunCMake/CXXModules/examples/file-sets-with-dot/main.cxx b/Tests/RunCMake/CXXModules/examples/file-sets-with-dot/main.cxx
new file mode 100644
index 0000000..feb38d2
--- /dev/null
+++ b/Tests/RunCMake/CXXModules/examples/file-sets-with-dot/main.cxx
@@ -0,0 +1,6 @@
+import importable;
+
+int main(int argc, char* argv[])
+{
+ return from_import();
+}