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.
This commit is contained in:
Ben Boeckel
2022-10-10 10:19:28 -04:00
parent e67f5d41af
commit 52e82dbb23
5 changed files with 66 additions and 0 deletions
@@ -134,6 +134,7 @@ if ("named" IN_LIST CMake_TEST_MODULE_COMPILATION)
run_cxx_module_test(generated)
run_cxx_module_test(public-req-private)
run_cxx_module_test(deep-chain)
run_cxx_module_test(duplicate)
set(RunCMake_CXXModules_NO_TEST 1)
run_cxx_module_test(circular)
unset(RunCMake_CXXModules_NO_TEST)
@@ -0,0 +1,9 @@
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.
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.
@@ -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")
@@ -0,0 +1,11 @@
module;
#include <iostream>
export module duplicate;
export int from_import()
{
std::cerr << "From duplicate #" << NDUPLICATE << std::endl;
return 0;
}
@@ -0,0 +1,6 @@
import duplicate;
int main(int argc, char* argv[])
{
return from_import();
}