summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/CXXModules
diff options
context:
space:
mode:
authorBen Boeckel <ben.boeckel@kitware.com>2022-04-19 14:49:29 (GMT)
committerBen Boeckel <ben.boeckel@kitware.com>2022-07-06 14:15:23 (GMT)
commit95402a0bd7e226d7b02f8620c237b15d9c4326ab (patch)
treedbbb32a51ce203401845fda829c4d5250555a45d /Tests/RunCMake/CXXModules
parentd3e2e61bcdb74899e7ee987c745ded8e7597fb62 (diff)
downloadCMake-95402a0bd7e226d7b02f8620c237b15d9c4326ab.zip
CMake-95402a0bd7e226d7b02f8620c237b15d9c4326ab.tar.gz
CMake-95402a0bd7e226d7b02f8620c237b15d9c4326ab.tar.bz2
cmNinjaTargetGenerator: write out export information for the collator
The collator will use this to know where the target's export information needs to go so that module properties may be provided.
Diffstat (limited to 'Tests/RunCMake/CXXModules')
-rw-r--r--Tests/RunCMake/CXXModules/NinjaDependInfoExport-check.cmake34
-rw-r--r--Tests/RunCMake/CXXModules/NinjaDependInfoExport-stderr.txt11
-rw-r--r--Tests/RunCMake/CXXModules/NinjaDependInfoExport.cmake85
-rw-r--r--Tests/RunCMake/CXXModules/RunCMakeTest.cmake1
-rw-r--r--Tests/RunCMake/CXXModules/expect/NinjaDependInfoExport-private.json72
-rw-r--r--Tests/RunCMake/CXXModules/expect/NinjaDependInfoExport-public.json72
-rw-r--r--Tests/RunCMake/CXXModules/expect/NinjaDependInfoFileSet-private.json1
-rw-r--r--Tests/RunCMake/CXXModules/expect/NinjaDependInfoFileSet-public.json1
8 files changed, 277 insertions, 0 deletions
diff --git a/Tests/RunCMake/CXXModules/NinjaDependInfoExport-check.cmake b/Tests/RunCMake/CXXModules/NinjaDependInfoExport-check.cmake
new file mode 100644
index 0000000..7720257
--- /dev/null
+++ b/Tests/RunCMake/CXXModules/NinjaDependInfoExport-check.cmake
@@ -0,0 +1,34 @@
+include("${CMAKE_CURRENT_LIST_DIR}/check-json.cmake")
+
+if (RunCMake_GENERATOR_IS_MULTI_CONFIG)
+ set(have_file 0)
+ foreach (config IN ITEMS Release Debug RelWithDebInfo MinSizeRel)
+ if (NOT EXISTS "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/ninja-exports-public.dir/${config}/CXXDependInfo.json")
+ continue ()
+ endif ()
+ set(have_file 1)
+
+ set(CMAKE_BUILD_TYPE "${config}")
+
+ file(READ "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/ninja-exports-public.dir/${config}/CXXDependInfo.json" actual_contents)
+ file(READ "${CMAKE_CURRENT_LIST_DIR}/expect/NinjaDependInfoExport-public.json" expect_contents)
+ check_json("${actual_contents}" "${expect_contents}")
+
+ file(READ "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/ninja-exports-private.dir/${config}/CXXDependInfo.json" actual_contents)
+ file(READ "${CMAKE_CURRENT_LIST_DIR}/expect/NinjaDependInfoExport-private.json" expect_contents)
+ check_json("${actual_contents}" "${expect_contents}")
+ endforeach ()
+
+ if (NOT have_file)
+ list(APPEND RunCMake_TEST_FAILED
+ "No recognized build configurations found.")
+ endif ()
+else ()
+ file(READ "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/ninja-exports-public.dir/CXXDependInfo.json" actual_contents)
+ file(READ "${CMAKE_CURRENT_LIST_DIR}/expect/NinjaDependInfoExport-public.json" expect_contents)
+ check_json("${actual_contents}" "${expect_contents}")
+
+ file(READ "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/ninja-exports-private.dir/CXXDependInfo.json" actual_contents)
+ file(READ "${CMAKE_CURRENT_LIST_DIR}/expect/NinjaDependInfoExport-private.json" expect_contents)
+ check_json("${actual_contents}" "${expect_contents}")
+endif ()
diff --git a/Tests/RunCMake/CXXModules/NinjaDependInfoExport-stderr.txt b/Tests/RunCMake/CXXModules/NinjaDependInfoExport-stderr.txt
new file mode 100644
index 0000000..e328223
--- /dev/null
+++ b/Tests/RunCMake/CXXModules/NinjaDependInfoExport-stderr.txt
@@ -0,0 +1,11 @@
+CMake Warning \(dev\) at NinjaDependInfoExport.cmake:14 \(target_sources\):
+ CMake's C\+\+ module support is experimental. It is meant only for
+ experimentation and feedback to CMake developers.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:6 \(include\)
+This warning is for project developers. Use -Wno-dev to suppress it.
+
+CMake Warning \(dev\):
+ C\+\+20 modules support via CMAKE_EXPERIMENTAL_CXX_MODULE_DYNDEP is
+ experimental. It is meant only for compiler developers to try.
+This warning is for project developers. Use -Wno-dev to suppress it.
diff --git a/Tests/RunCMake/CXXModules/NinjaDependInfoExport.cmake b/Tests/RunCMake/CXXModules/NinjaDependInfoExport.cmake
new file mode 100644
index 0000000..05e7ef7
--- /dev/null
+++ b/Tests/RunCMake/CXXModules/NinjaDependInfoExport.cmake
@@ -0,0 +1,85 @@
+# Fake out that we have dyndep; we only need to generate, not actually build
+# here.
+set(CMAKE_EXPERIMENTAL_CXX_MODULE_DYNDEP 1)
+set(CMAKE_EXPERIMENTAL_CXX_SCANDEP_SOURCE "")
+
+enable_language(CXX)
+
+if (NOT CMAKE_GENERATOR MATCHES "Ninja")
+ message(FATAL_ERROR
+ "This test requires a 'Ninja' generator to be used.")
+endif ()
+
+add_library(ninja-exports-public)
+target_sources(ninja-exports-public
+ PRIVATE
+ sources/module-impl.cxx
+ sources/module-internal-part-impl.cxx
+ sources/module-part-impl.cxx
+ sources/module-use.cxx
+ PUBLIC
+ FILE_SET modules TYPE CXX_MODULES
+ BASE_DIRS
+ "${CMAKE_CURRENT_SOURCE_DIR}/sources"
+ FILES
+ sources/module.cxx
+ sources/module-part.cxx
+ FILE_SET internal_partitions TYPE CXX_MODULES FILES
+ sources/module-internal-part.cxx)
+target_compile_features(ninja-exports-public
+ PRIVATE
+ cxx_std_20)
+set_property(TARGET ninja-exports-public
+ PROPERTY EXPORT_NAME "with-public")
+
+install(TARGETS ninja-exports-public
+ EXPORT exp
+ FILE_SET modules
+ DESTINATION "lib/cxx"
+ COMPONENT "modules"
+ FILE_SET internal_partitions
+ DESTINATION "lib/cxx/internals"
+ COMPONENT "modules-internal")
+
+add_library(ninja-exports-private)
+target_sources(ninja-exports-private
+ PRIVATE
+ sources/module-impl.cxx
+ sources/module-internal-part-impl.cxx
+ sources/module-part-impl.cxx
+ sources/module-use.cxx
+ PRIVATE
+ FILE_SET modules TYPE CXX_MODULES
+ BASE_DIRS
+ "${CMAKE_CURRENT_SOURCE_DIR}/sources"
+ FILES
+ sources/module.cxx
+ sources/module-part.cxx
+ FILE_SET internal_partitions TYPE CXX_MODULES FILES
+ sources/module-internal-part.cxx)
+target_compile_features(ninja-exports-private
+ PRIVATE
+ cxx_std_20)
+set_property(TARGET ninja-exports-private
+ PROPERTY EXPORT_NAME "with-private")
+
+install(TARGETS ninja-exports-private
+ EXPORT exp)
+
+# Test multiple build exports.
+export(EXPORT exp
+ FILE "${CMAKE_BINARY_DIR}/lib/cmake/export1/export1-targets.cmake"
+ NAMESPACE export1::
+ CXX_MODULES_DIRECTORY "cxx-modules")
+export(EXPORT exp
+ FILE "${CMAKE_BINARY_DIR}/lib/cmake/export2/export2-targets.cmake"
+ CXX_MODULES_DIRECTORY "cxx-modules")
+
+# Test multiple install exports.
+install(EXPORT exp
+ DESTINATION "lib/cmake/export1"
+ NAMESPACE export1::
+ CXX_MODULES_DIRECTORY "cxx-modules")
+install(EXPORT exp
+ DESTINATION "lib/cmake/export2"
+ CXX_MODULES_DIRECTORY "cxx-modules")
diff --git a/Tests/RunCMake/CXXModules/RunCMakeTest.cmake b/Tests/RunCMake/CXXModules/RunCMakeTest.cmake
index aedaf3c..d3db1d4 100644
--- a/Tests/RunCMake/CXXModules/RunCMakeTest.cmake
+++ b/Tests/RunCMake/CXXModules/RunCMakeTest.cmake
@@ -77,6 +77,7 @@ run_cmake(ExportInstallCxxModules)
# Generator-specific tests.
if (RunCMake_GENERATOR MATCHES "Ninja")
run_cmake(NinjaDependInfoFileSet)
+ run_cmake(NinjaDependInfoExport)
else ()
message(FATAL_ERROR
"Please add 'DependInfo' tests for the '${RunCMake_GENERATOR}' generator.")
diff --git a/Tests/RunCMake/CXXModules/expect/NinjaDependInfoExport-private.json b/Tests/RunCMake/CXXModules/expect/NinjaDependInfoExport-private.json
new file mode 100644
index 0000000..6bff226
--- /dev/null
+++ b/Tests/RunCMake/CXXModules/expect/NinjaDependInfoExport-private.json
@@ -0,0 +1,72 @@
+{
+ "compiler-id": "<IGNORE>",
+ "config": "<CONFIG>",
+ "cxx-modules": {
+ "CMakeFiles/ninja-exports-private.dir/sources/module-internal-part.cxx.o": {
+ "destination": null,
+ "name": "internal_partitions",
+ "relative-directory": "sources",
+ "source": "<SOURCE_DIR>/sources/module-internal-part.cxx",
+ "type": "CXX_MODULES",
+ "visibility": "PRIVATE"
+ },
+ "CMakeFiles/ninja-exports-private.dir/sources/module-part.cxx.o": {
+ "destination": null,
+ "name": "modules",
+ "relative-directory": "",
+ "source": "<SOURCE_DIR>/sources/module-part.cxx",
+ "type": "CXX_MODULES",
+ "visibility": "PRIVATE"
+ },
+ "CMakeFiles/ninja-exports-private.dir/sources/module.cxx.o": {
+ "destination": null,
+ "name": "modules",
+ "relative-directory": "",
+ "source": "<SOURCE_DIR>/sources/module.cxx",
+ "type": "CXX_MODULES",
+ "visibility": "PRIVATE"
+ }
+ },
+ "dir-cur-bld": "<BINARY_DIR>",
+ "dir-cur-src": "<SOURCE_DIR>",
+ "dir-top-bld": "<BINARY_DIR>",
+ "dir-top-src": "<SOURCE_DIR>",
+ "exports": [
+ {
+ "cxx-module-info-dir" : "cxx-modules",
+ "destination" : "lib/cmake/export1",
+ "export-name" : "with-private",
+ "export-prefix" : "<BINARY_DIR>/CMakeFiles/Export/d2e2673818fd2bd8c45c0e3ed0e38fcd",
+ "install" : true,
+ "namespace" : "export1::"
+ },
+ {
+ "cxx-module-info-dir" : "cxx-modules",
+ "destination" : "lib/cmake/export2",
+ "export-name" : "with-private",
+ "export-prefix" : "<BINARY_DIR>/CMakeFiles/Export/28cd47cb4c96ad5cadaa3fb1b0201ae8",
+ "install" : true,
+ "namespace" : ""
+ },
+ {
+ "cxx-module-info-dir" : "cxx-modules",
+ "destination" : "<BINARY_DIR>/lib/cmake/export1",
+ "export-name" : "with-private",
+ "export-prefix" : "<BINARY_DIR>/lib/cmake/export1",
+ "install" : false,
+ "namespace" : "export1::"
+ },
+ {
+ "cxx-module-info-dir" : "cxx-modules",
+ "destination" : "<BINARY_DIR>/lib/cmake/export2",
+ "export-name" : "with-private",
+ "export-prefix" : "<BINARY_DIR>/lib/cmake/export2",
+ "install" : false,
+ "namespace" : ""
+ }
+ ],
+ "include-dirs": [],
+ "language": "CXX",
+ "linked-target-dirs": [],
+ "module-dir": "<BINARY_DIR>/CMakeFiles/ninja-exports-private.dir"
+}
diff --git a/Tests/RunCMake/CXXModules/expect/NinjaDependInfoExport-public.json b/Tests/RunCMake/CXXModules/expect/NinjaDependInfoExport-public.json
new file mode 100644
index 0000000..d17c50e
--- /dev/null
+++ b/Tests/RunCMake/CXXModules/expect/NinjaDependInfoExport-public.json
@@ -0,0 +1,72 @@
+{
+ "compiler-id": "<IGNORE>",
+ "config": "<CONFIG>",
+ "cxx-modules": {
+ "CMakeFiles/ninja-exports-public.dir/sources/module-internal-part.cxx.o": {
+ "destination": "lib/cxx/internals",
+ "name": "internal_partitions",
+ "relative-directory": "sources",
+ "source": "<SOURCE_DIR>/sources/module-internal-part.cxx",
+ "type": "CXX_MODULES",
+ "visibility": "PUBLIC"
+ },
+ "CMakeFiles/ninja-exports-public.dir/sources/module-part.cxx.o": {
+ "destination": "lib/cxx",
+ "name": "modules",
+ "relative-directory": "",
+ "source": "<SOURCE_DIR>/sources/module-part.cxx",
+ "type": "CXX_MODULES",
+ "visibility": "PUBLIC"
+ },
+ "CMakeFiles/ninja-exports-public.dir/sources/module.cxx.o": {
+ "destination": "lib/cxx",
+ "name": "modules",
+ "relative-directory": "",
+ "source": "<SOURCE_DIR>/sources/module.cxx",
+ "type": "CXX_MODULES",
+ "visibility": "PUBLIC"
+ }
+ },
+ "dir-cur-bld": "<BINARY_DIR>",
+ "dir-cur-src": "<SOURCE_DIR>",
+ "dir-top-bld": "<BINARY_DIR>",
+ "dir-top-src": "<SOURCE_DIR>",
+ "exports": [
+ {
+ "cxx-module-info-dir" : "cxx-modules",
+ "destination" : "lib/cmake/export1",
+ "export-name" : "with-public",
+ "export-prefix" : "<BINARY_DIR>/CMakeFiles/Export/d2e2673818fd2bd8c45c0e3ed0e38fcd",
+ "install" : true,
+ "namespace" : "export1::"
+ },
+ {
+ "cxx-module-info-dir" : "cxx-modules",
+ "destination" : "lib/cmake/export2",
+ "export-name" : "with-public",
+ "export-prefix" : "<BINARY_DIR>/CMakeFiles/Export/28cd47cb4c96ad5cadaa3fb1b0201ae8",
+ "install" : true,
+ "namespace" : ""
+ },
+ {
+ "cxx-module-info-dir" : "cxx-modules",
+ "destination" : "<BINARY_DIR>/lib/cmake/export1",
+ "export-name" : "with-public",
+ "export-prefix" : "<BINARY_DIR>/lib/cmake/export1",
+ "install" : false,
+ "namespace" : "export1::"
+ },
+ {
+ "cxx-module-info-dir" : "cxx-modules",
+ "destination" : "<BINARY_DIR>/lib/cmake/export2",
+ "export-name" : "with-public",
+ "export-prefix" : "<BINARY_DIR>/lib/cmake/export2",
+ "install" : false,
+ "namespace" : ""
+ }
+ ],
+ "include-dirs": [],
+ "language": "CXX",
+ "linked-target-dirs": [],
+ "module-dir": "<BINARY_DIR>/CMakeFiles/ninja-exports-public.dir"
+}
diff --git a/Tests/RunCMake/CXXModules/expect/NinjaDependInfoFileSet-private.json b/Tests/RunCMake/CXXModules/expect/NinjaDependInfoFileSet-private.json
index 968502c..d03cf1c 100644
--- a/Tests/RunCMake/CXXModules/expect/NinjaDependInfoFileSet-private.json
+++ b/Tests/RunCMake/CXXModules/expect/NinjaDependInfoFileSet-private.json
@@ -31,6 +31,7 @@
"dir-cur-src": "<SOURCE_DIR>",
"dir-top-bld": "<BINARY_DIR>",
"dir-top-src": "<SOURCE_DIR>",
+ "exports": [],
"include-dirs": [],
"language": "CXX",
"linked-target-dirs": [],
diff --git a/Tests/RunCMake/CXXModules/expect/NinjaDependInfoFileSet-public.json b/Tests/RunCMake/CXXModules/expect/NinjaDependInfoFileSet-public.json
index e836437..6afce06 100644
--- a/Tests/RunCMake/CXXModules/expect/NinjaDependInfoFileSet-public.json
+++ b/Tests/RunCMake/CXXModules/expect/NinjaDependInfoFileSet-public.json
@@ -31,6 +31,7 @@
"dir-cur-src": "<SOURCE_DIR>",
"dir-top-bld": "<BINARY_DIR>",
"dir-top-src": "<SOURCE_DIR>",
+ "exports": [],
"include-dirs": [],
"language": "CXX",
"linked-target-dirs": [],