Tests/RunCMake/CXXModules: add a test with circular imports

The build should fail. However, the error message is completely
generator-dependent as it is the build tool which (should) eventually
detect this case.
This commit is contained in:
Ben Boeckel 2022-10-10 10:19:28 -04:00
parent 7629a1182c
commit e67f5d41af
7 changed files with 44 additions and 1 deletions

View File

@ -120,7 +120,9 @@ function (run_cxx_module_test directory)
if (RunCMake_CXXModules_INSTALL)
run_cmake_command("examples/${test_name}-install" "${CMAKE_COMMAND}" --build . --target install --config Debug)
endif ()
run_cmake_command("examples/${test_name}-test" "${CMAKE_CTEST_COMMAND}" -C Debug --output-on-failure)
if (NOT RunCMake_CXXModules_NO_TEST)
run_cmake_command("examples/${test_name}-test" "${CMAKE_CTEST_COMMAND}" -C Debug --output-on-failure)
endif ()
endfunction ()
string(REPLACE "," ";" CMake_TEST_MODULE_COMPILATION "${CMake_TEST_MODULE_COMPILATION}")
@ -132,6 +134,9 @@ 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)
set(RunCMake_CXXModules_NO_TEST 1)
run_cxx_module_test(circular)
unset(RunCMake_CXXModules_NO_TEST)
endif ()
# Tests which use named modules in shared libraries.

View File

@ -0,0 +1 @@
1

View File

@ -0,0 +1 @@
(Ninja generators)?(build stopped: dependency cycle:)

View File

@ -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.

View File

@ -0,0 +1,15 @@
cmake_minimum_required(VERSION 3.24)
project(cxx_modules_circular CXX)
include("${CMAKE_SOURCE_DIR}/../cxx-modules-rules.cmake")
add_library(circular STATIC)
target_sources(circular
PUBLIC
FILE_SET CXX_MODULES
BASE_DIRS
"${CMAKE_CURRENT_SOURCE_DIR}"
FILES
circular-a.cppm
circular-b.cppm)
target_compile_features(circular PUBLIC cxx_std_20)

View File

@ -0,0 +1,6 @@
export module a;
import b;
export int a() {
return b();
}

View File

@ -0,0 +1,6 @@
export module b;
import a;
export int b() {
return a();
}