summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2023-06-28 10:37:57 (GMT)
committerBrad King <brad.king@kitware.com>2023-06-28 10:43:10 (GMT)
commitb9c99830c5a1e8e339fcca690b3e8fd62c31e61a (patch)
tree3b5a927c88bc3e3c4545b3462ff989023233fdc9 /Tests
parentf58c7659d8652c1172fc15a0bae9d71ee477c1eb (diff)
downloadCMake-b9c99830c5a1e8e339fcca690b3e8fd62c31e61a.zip
CMake-b9c99830c5a1e8e339fcca690b3e8fd62c31e61a.tar.gz
CMake-b9c99830c5a1e8e339fcca690b3e8fd62c31e61a.tar.bz2
VS: Fix C++ modules in source files with the same name
When multiple source files in a single target have the same name, we already set `ObjectFileName` explicitly to avoid a `.obj` collision. For C++ module sources, set `Module{Output,Dependencies}File` to avoid `.ifc` and `.module.json` collisions. Fixes: #25038
Diffstat (limited to 'Tests')
-rw-r--r--Tests/RunCMake/CXXModules/RunCMakeTest.cmake1
-rw-r--r--Tests/RunCMake/CXXModules/examples/same-src-name-stderr.txt4
-rw-r--r--Tests/RunCMake/CXXModules/examples/same-src-name/CMakeLists.txt20
-rw-r--r--Tests/RunCMake/CXXModules/examples/same-src-name/a/same.cxx5
-rw-r--r--Tests/RunCMake/CXXModules/examples/same-src-name/b/same.cxx5
-rw-r--r--Tests/RunCMake/CXXModules/examples/same-src-name/main.cxx7
6 files changed, 42 insertions, 0 deletions
diff --git a/Tests/RunCMake/CXXModules/RunCMakeTest.cmake b/Tests/RunCMake/CXXModules/RunCMakeTest.cmake
index 1569f91..ada0c65 100644
--- a/Tests/RunCMake/CXXModules/RunCMakeTest.cmake
+++ b/Tests/RunCMake/CXXModules/RunCMakeTest.cmake
@@ -148,6 +148,7 @@ if ("named" IN_LIST CMake_TEST_MODULE_COMPILATION)
set(RunCMake_CXXModules_NO_TEST 1)
run_cxx_module_test(circular)
unset(RunCMake_CXXModules_NO_TEST)
+ run_cxx_module_test(same-src-name)
run_cxx_module_test(scan_properties)
endif ()
diff --git a/Tests/RunCMake/CXXModules/examples/same-src-name-stderr.txt b/Tests/RunCMake/CXXModules/examples/same-src-name-stderr.txt
new file mode 100644
index 0000000..78bdf2b
--- /dev/null
+++ b/Tests/RunCMake/CXXModules/examples/same-src-name-stderr.txt
@@ -0,0 +1,4 @@
+CMake Warning \(dev\) at CMakeLists.txt:7 \(target_sources\):
+ CMake's C\+\+ module support is experimental. It is meant only for
+ experimentation and feedback to CMake developers.
+This warning is for project developers. Use -Wno-dev to suppress it.
diff --git a/Tests/RunCMake/CXXModules/examples/same-src-name/CMakeLists.txt b/Tests/RunCMake/CXXModules/examples/same-src-name/CMakeLists.txt
new file mode 100644
index 0000000..997bbb1
--- /dev/null
+++ b/Tests/RunCMake/CXXModules/examples/same-src-name/CMakeLists.txt
@@ -0,0 +1,20 @@
+cmake_minimum_required(VERSION 3.27)
+project(cxx_modules_same_src_name CXX)
+
+include("${CMAKE_SOURCE_DIR}/../cxx-modules-rules.cmake")
+
+add_executable(same_src_name)
+target_sources(same_src_name
+ PRIVATE
+ main.cxx
+ PRIVATE
+ FILE_SET CXX_MODULES
+ BASE_DIRS
+ "${CMAKE_CURRENT_SOURCE_DIR}"
+ FILES
+ a/same.cxx
+ b/same.cxx
+ )
+target_compile_features(same_src_name PUBLIC cxx_std_20)
+
+add_test(NAME same_src_name COMMAND same_src_name)
diff --git a/Tests/RunCMake/CXXModules/examples/same-src-name/a/same.cxx b/Tests/RunCMake/CXXModules/examples/same-src-name/a/same.cxx
new file mode 100644
index 0000000..8aa79cb
--- /dev/null
+++ b/Tests/RunCMake/CXXModules/examples/same-src-name/a/same.cxx
@@ -0,0 +1,5 @@
+export module a.same;
+export int a_same()
+{
+ return 0;
+}
diff --git a/Tests/RunCMake/CXXModules/examples/same-src-name/b/same.cxx b/Tests/RunCMake/CXXModules/examples/same-src-name/b/same.cxx
new file mode 100644
index 0000000..7aa3703
--- /dev/null
+++ b/Tests/RunCMake/CXXModules/examples/same-src-name/b/same.cxx
@@ -0,0 +1,5 @@
+export module b.same;
+export int b_same()
+{
+ return 0;
+}
diff --git a/Tests/RunCMake/CXXModules/examples/same-src-name/main.cxx b/Tests/RunCMake/CXXModules/examples/same-src-name/main.cxx
new file mode 100644
index 0000000..30f2250
--- /dev/null
+++ b/Tests/RunCMake/CXXModules/examples/same-src-name/main.cxx
@@ -0,0 +1,7 @@
+import a.same;
+import b.same;
+
+int main()
+{
+ return a_same() + b_same();
+}