Pārlūkot izejas kodu

Tests/CXXModules: add a test case for VS generation without flags

Previously, the `ScanSourceForModuleDependencies` flag was not added to
the VS project if "nothing" prompted custom flags.

See: #25519
Ben Boeckel 1 gadu atpakaļ
vecāks
revīzija
6c9614cbf4

+ 1 - 0
Tests/RunCMake/CXXModules/RunCMakeTest.cmake

@@ -170,6 +170,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(vs-without-flags)
   run_cxx_module_test(library library-static -DBUILD_SHARED_LIBS=OFF)
   run_cxx_module_test(object-library)
   run_cxx_module_test(generated)

+ 22 - 0
Tests/RunCMake/CXXModules/examples/vs-without-flags/CMakeLists.txt

@@ -0,0 +1,22 @@
+cmake_minimum_required(VERSION 3.28)
+project(cxx_modules_vs_without_flags CXX)
+
+include("${CMAKE_SOURCE_DIR}/../cxx-modules-rules.cmake")
+
+set(CMAKE_CXX_STANDARD 23)
+set(CMAKE_CXX_STANDARD_REQUIRED ON)
+set(CMAKE_CXX_EXTENSIONS OFF)
+set(CMAKE_CXX_SCAN_FOR_MODULES ON)
+
+add_executable(vs_without_flags)
+target_sources(vs_without_flags
+  PRIVATE
+    main.cxx
+  PRIVATE
+    FILE_SET CXX_MODULES
+      BASE_DIRS
+        "${CMAKE_CURRENT_SOURCE_DIR}"
+      FILES
+        module.cxx)
+
+add_test(NAME vs_without_flags COMMAND vs_without_flags)

+ 6 - 0
Tests/RunCMake/CXXModules/examples/vs-without-flags/main.cxx

@@ -0,0 +1,6 @@
+import mod;
+
+int main(int argc, char* argv[])
+{
+  return f();
+}

+ 6 - 0
Tests/RunCMake/CXXModules/examples/vs-without-flags/module.cxx

@@ -0,0 +1,6 @@
+export module mod;
+
+export int f()
+{
+  return 0;
+}