summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
authorBen Boeckel <ben.boeckel@kitware.com>2023-10-17 14:26:33 (GMT)
committerBen Boeckel <ben.boeckel@kitware.com>2023-10-17 18:47:18 (GMT)
commit17fd7fe2aed20357275918591544b292d86f0fe1 (patch)
tree4f1b0101d6a720a7e68a1e2571ef068f17b45d8d /Tests
parentbadb6ab120bb3bb01c6b41e50aadb234d16e8e21 (diff)
downloadCMake-17fd7fe2aed20357275918591544b292d86f0fe1.zip
CMake-17fd7fe2aed20357275918591544b292d86f0fe1.tar.gz
CMake-17fd7fe2aed20357275918591544b292d86f0fe1.tar.bz2
Tests/CXXModules: test Visual Studio synthetic target error
Diffstat (limited to 'Tests')
-rw-r--r--Tests/RunCMake/CXXModules/RunCMakeTest.cmake2
-rw-r--r--Tests/RunCMake/CXXModules/VisualStudioNoSyntheticTargets-result.txt1
-rw-r--r--Tests/RunCMake/CXXModules/VisualStudioNoSyntheticTargets-stderr.txt6
-rw-r--r--Tests/RunCMake/CXXModules/VisualStudioNoSyntheticTargets.cmake27
-rw-r--r--Tests/RunCMake/CXXModules/sources/module-simple-use.cxx6
-rw-r--r--Tests/RunCMake/CXXModules/sources/module-simple.cxx6
6 files changed, 47 insertions, 1 deletions
diff --git a/Tests/RunCMake/CXXModules/RunCMakeTest.cmake b/Tests/RunCMake/CXXModules/RunCMakeTest.cmake
index e13b2d4..2938fa8 100644
--- a/Tests/RunCMake/CXXModules/RunCMakeTest.cmake
+++ b/Tests/RunCMake/CXXModules/RunCMakeTest.cmake
@@ -95,7 +95,7 @@ if (RunCMake_GENERATOR MATCHES "Ninja")
run_cmake(NinjaDependInfoExport)
run_cmake(NinjaDependInfoBMIInstall)
elseif (RunCMake_GENERATOR MATCHES "Visual Studio")
- # Not supported yet.
+ run_cmake(VisualStudioNoSyntheticTargets)
else ()
message(FATAL_ERROR
"Please add 'DependInfo' tests for the '${RunCMake_GENERATOR}' generator.")
diff --git a/Tests/RunCMake/CXXModules/VisualStudioNoSyntheticTargets-result.txt b/Tests/RunCMake/CXXModules/VisualStudioNoSyntheticTargets-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/CXXModules/VisualStudioNoSyntheticTargets-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CXXModules/VisualStudioNoSyntheticTargets-stderr.txt b/Tests/RunCMake/CXXModules/VisualStudioNoSyntheticTargets-stderr.txt
new file mode 100644
index 0000000..a8ef008
--- /dev/null
+++ b/Tests/RunCMake/CXXModules/VisualStudioNoSyntheticTargets-stderr.txt
@@ -0,0 +1,6 @@
+^(CMake Error in CMakeLists.txt:
+ Target "imported-cxx-modules@synth_[0-9a-f]+" contains C\+\+ modules
+ intended for BMI-only compilation. This is not yet supported by the Visual
+ Studio generator.
+*
+)+CMake Generate step failed. Build files cannot be regenerated correctly.
diff --git a/Tests/RunCMake/CXXModules/VisualStudioNoSyntheticTargets.cmake b/Tests/RunCMake/CXXModules/VisualStudioNoSyntheticTargets.cmake
new file mode 100644
index 0000000..e5e178d
--- /dev/null
+++ b/Tests/RunCMake/CXXModules/VisualStudioNoSyntheticTargets.cmake
@@ -0,0 +1,27 @@
+enable_language(CXX)
+
+if (NOT CMAKE_GENERATOR MATCHES "Visual Studio")
+ message(FATAL_ERROR
+ "This test requires a 'Visual Studio' generator to be used.")
+endif ()
+
+add_library(imported-cxx-modules IMPORTED INTERFACE)
+target_sources(imported-cxx-modules
+ INTERFACE
+ FILE_SET modules TYPE CXX_MODULES
+ BASE_DIRS
+ "${CMAKE_CURRENT_SOURCE_DIR}/sources"
+ FILES
+ sources/module-simple.cxx)
+set_target_properties(imported-cxx-modules PROPERTIES
+ IMPORTED_CONFIGURATIONS DEBUG
+ IMPORTED_LINK_INTERFACE_LANGUAGES_DEBUG "CXX"
+ IMPORTED_CXX_MODULES_COMPILE_FEATURES "cxx_std_20"
+ INTERFACE_COMPILE_FEATURES "cxx_std_20"
+ IMPORTED_CXX_MODULES_DEBUG "simple=${CMAKE_CURRENT_SOURCE_DIR}/sources/module-simple.cxx")
+
+add_executable(vs-use-imported-cxx-modules
+ sources/module-simple-use.cxx)
+target_link_libraries(vs-use-imported-cxx-modules
+ PRIVATE
+ imported-cxx-modules)
diff --git a/Tests/RunCMake/CXXModules/sources/module-simple-use.cxx b/Tests/RunCMake/CXXModules/sources/module-simple-use.cxx
new file mode 100644
index 0000000..b0bfeec
--- /dev/null
+++ b/Tests/RunCMake/CXXModules/sources/module-simple-use.cxx
@@ -0,0 +1,6 @@
+import simple;
+
+int main(int argc, char* argv[])
+{
+ return g();
+}
diff --git a/Tests/RunCMake/CXXModules/sources/module-simple.cxx b/Tests/RunCMake/CXXModules/sources/module-simple.cxx
new file mode 100644
index 0000000..21b087c
--- /dev/null
+++ b/Tests/RunCMake/CXXModules/sources/module-simple.cxx
@@ -0,0 +1,6 @@
+export module simple;
+
+int g()
+{
+ return 0;
+}