diff options
author | Ben Boeckel <ben.boeckel@kitware.com> | 2022-10-10 14:19:28 (GMT) |
---|---|---|
committer | Ben Boeckel <ben.boeckel@kitware.com> | 2022-10-11 16:51:33 (GMT) |
commit | 52e82dbb23b22a2ede0b26f2f7f1d3ef7b600c41 (patch) | |
tree | cbfe197f23e3cd19e241673487188504c9c49455 /Tests/RunCMake/CXXModules/examples/duplicate | |
parent | e67f5d41af0eb8d08728d2efcad8d57594be579b (diff) | |
download | CMake-52e82dbb23b22a2ede0b26f2f7f1d3ef7b600c41.zip CMake-52e82dbb23b22a2ede0b26f2f7f1d3ef7b600c41.tar.gz CMake-52e82dbb23b22a2ede0b26f2f7f1d3ef7b600c41.tar.bz2 |
Tests/RunCMake/CXXModules: add a test with duplicate modules
Not in the same executable (as that is IFNDR), but in the same project.
This tests to make sure that there's not some project-wide cache that
gets confused.
Diffstat (limited to 'Tests/RunCMake/CXXModules/examples/duplicate')
3 files changed, 56 insertions, 0 deletions
diff --git a/Tests/RunCMake/CXXModules/examples/duplicate/CMakeLists.txt b/Tests/RunCMake/CXXModules/examples/duplicate/CMakeLists.txt new file mode 100644 index 0000000..27be7a8 --- /dev/null +++ b/Tests/RunCMake/CXXModules/examples/duplicate/CMakeLists.txt @@ -0,0 +1,39 @@ +cmake_minimum_required(VERSION 3.24) +project(cxx_modules_duplicate CXX) + +include("${CMAKE_SOURCE_DIR}/../cxx-modules-rules.cmake") + +add_executable(duplicate) +target_sources(duplicate + PRIVATE + main.cxx + PRIVATE + FILE_SET CXX_MODULES + BASE_DIRS + "${CMAKE_CURRENT_SOURCE_DIR}" + FILES + duplicate.cxx) +target_compile_features(duplicate PRIVATE cxx_std_20) +target_compile_definitions(duplicate PRIVATE NDUPLICATE=1) + +add_executable(duplicate2) +target_sources(duplicate2 + PRIVATE + main.cxx + PRIVATE + FILE_SET CXX_MODULES + BASE_DIRS + "${CMAKE_CURRENT_SOURCE_DIR}" + FILES + duplicate.cxx) +target_compile_features(duplicate2 PRIVATE cxx_std_20) +target_compile_definitions(duplicate2 PRIVATE NDUPLICATE=2) + +add_test(NAME duplicate COMMAND duplicate) +set_property(TEST duplicate + PROPERTY + PASS_REGULAR_EXPRESSION "From duplicate #1") +add_test(NAME duplicate2 COMMAND duplicate2) +set_property(TEST duplicate2 + PROPERTY + PASS_REGULAR_EXPRESSION "From duplicate #2") diff --git a/Tests/RunCMake/CXXModules/examples/duplicate/duplicate.cxx b/Tests/RunCMake/CXXModules/examples/duplicate/duplicate.cxx new file mode 100644 index 0000000..c0c820b --- /dev/null +++ b/Tests/RunCMake/CXXModules/examples/duplicate/duplicate.cxx @@ -0,0 +1,11 @@ +module; + +#include <iostream> + +export module duplicate; + +export int from_import() +{ + std::cerr << "From duplicate #" << NDUPLICATE << std::endl; + return 0; +} diff --git a/Tests/RunCMake/CXXModules/examples/duplicate/main.cxx b/Tests/RunCMake/CXXModules/examples/duplicate/main.cxx new file mode 100644 index 0000000..c2c0636 --- /dev/null +++ b/Tests/RunCMake/CXXModules/examples/duplicate/main.cxx @@ -0,0 +1,6 @@ +import duplicate; + +int main(int argc, char* argv[]) +{ + return from_import(); +} |