diff options
author | Ben Boeckel <ben.boeckel@kitware.com> | 2023-09-05 23:21:34 (GMT) |
---|---|---|
committer | Ben Boeckel <ben.boeckel@kitware.com> | 2023-09-12 18:46:36 (GMT) |
commit | 458e3974a8d3827f051201403a1acc4ddca3c19e (patch) | |
tree | 45921bef4608e03f412d86003b82bf16e23cece4 /Tests | |
parent | 8708b41532a01479a96b2d5a67e54b7a1397306f (diff) | |
download | CMake-458e3974a8d3827f051201403a1acc4ddca3c19e.zip CMake-458e3974a8d3827f051201403a1acc4ddca3c19e.tar.gz CMake-458e3974a8d3827f051201403a1acc4ddca3c19e.tar.bz2 |
cxxmodules: detect and message about non-compiled sources
Previously an internal error was raised which ended up causing an
internal exception to be thrown. This is a typo situation that should
fall into an explicit error.
Fixes: #25207
Diffstat (limited to 'Tests')
6 files changed, 37 insertions, 1 deletions
diff --git a/Tests/RunCMake/CXXModules/NoCXX-stderr.txt b/Tests/RunCMake/CXXModules/NoCXX-stderr.txt index aa7f406..7e8f384 100644 --- a/Tests/RunCMake/CXXModules/NoCXX-stderr.txt +++ b/Tests/RunCMake/CXXModules/NoCXX-stderr.txt @@ -15,6 +15,11 @@ CMake Error in CMakeLists.txt: been enabled | The "nocxx" target contains C\+\+ module sources which are not supported by the generator +| Target "nocxx" has source file + + .*/Tests/RunCMake/CXXModules/sources/module.cxx + + in a "FILE_SET TYPE CXX_MODULES" but it is not scheduled for compilation. ) )* CMake Generate step failed. Build files cannot be regenerated correctly. diff --git a/Tests/RunCMake/CXXModules/NotCompiledSourceModules-result.txt b/Tests/RunCMake/CXXModules/NotCompiledSourceModules-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CXXModules/NotCompiledSourceModules-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CXXModules/NotCompiledSourceModules-stderr.txt b/Tests/RunCMake/CXXModules/NotCompiledSourceModules-stderr.txt new file mode 100644 index 0000000..52f4072 --- /dev/null +++ b/Tests/RunCMake/CXXModules/NotCompiledSourceModules-stderr.txt @@ -0,0 +1,16 @@ +CMake Warning \(dev\) at NotCompiledSourceModules.cmake:5 \(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 Error in CMakeLists.txt: + Target "not-cxx-source" has source file + + .*/Tests/RunCMake/CXXModules/sources/not-compiled.txt + + in a "FILE_SET TYPE CXX_MODULES" but it is not scheduled for compilation. + +)+ +CMake Generate step failed. Build files cannot be regenerated correctly. diff --git a/Tests/RunCMake/CXXModules/NotCompiledSourceModules.cmake b/Tests/RunCMake/CXXModules/NotCompiledSourceModules.cmake new file mode 100644 index 0000000..0bab635 --- /dev/null +++ b/Tests/RunCMake/CXXModules/NotCompiledSourceModules.cmake @@ -0,0 +1,13 @@ +enable_language(CXX) +set(CMAKE_EXPERIMENTAL_CXX_SCANDEP_SOURCE "") + +add_library(not-cxx-source) +target_sources(not-cxx-source + PRIVATE + sources/cxx-anchor.cxx + PUBLIC + FILE_SET fs TYPE CXX_MODULES FILES + sources/not-compiled.txt) +target_compile_features(not-cxx-source + PRIVATE + cxx_std_20) diff --git a/Tests/RunCMake/CXXModules/RunCMakeTest.cmake b/Tests/RunCMake/CXXModules/RunCMakeTest.cmake index d324ec9..89c198f 100644 --- a/Tests/RunCMake/CXXModules/RunCMakeTest.cmake +++ b/Tests/RunCMake/CXXModules/RunCMakeTest.cmake @@ -71,8 +71,9 @@ foreach (fileset_type IN LISTS fileset_types) endforeach () run_cmake("FileSet${fileset_type}InterfaceImported") - # Test the error message when a non-C++ source file is found in the source + # Test the error messages when a non-C++ source file is found in the source # list. + run_cmake("NotCompiledSource${fileset_type}") run_cmake("NotCXXSource${fileset_type}") endforeach () diff --git a/Tests/RunCMake/CXXModules/sources/not-compiled.txt b/Tests/RunCMake/CXXModules/sources/not-compiled.txt new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/CXXModules/sources/not-compiled.txt |