diff options
-rw-r--r-- | Source/cmDyndepCollation.cxx | 7 | ||||
-rw-r--r-- | Source/cmVisualStudio10TargetGenerator.cxx | 20 | ||||
-rw-r--r-- | Tests/RunCMake/CXXModules/NoCXX-stderr.txt | 5 | ||||
-rw-r--r-- | Tests/RunCMake/CXXModules/NotCompiledSourceModules-result.txt | 1 | ||||
-rw-r--r-- | Tests/RunCMake/CXXModules/NotCompiledSourceModules-stderr.txt | 16 | ||||
-rw-r--r-- | Tests/RunCMake/CXXModules/NotCompiledSourceModules.cmake | 13 | ||||
-rw-r--r-- | Tests/RunCMake/CXXModules/RunCMakeTest.cmake | 3 | ||||
-rw-r--r-- | Tests/RunCMake/CXXModules/sources/not-compiled.txt | 0 |
8 files changed, 61 insertions, 4 deletions
diff --git a/Source/cmDyndepCollation.cxx b/Source/cmDyndepCollation.cxx index 80e1357..b50718c 100644 --- a/Source/cmDyndepCollation.cxx +++ b/Source/cmDyndepCollation.cxx @@ -106,10 +106,11 @@ Json::Value CollationInformationCxxModules( auto lookup = sf_map.find(file); if (lookup == sf_map.end()) { gt->Makefile->IssueMessage( - MessageType::INTERNAL_ERROR, - cmStrCat("Target \"", tgt->GetName(), "\" has source file \"", + MessageType::FATAL_ERROR, + cmStrCat("Target \"", tgt->GetName(), "\" has source file\n ", file, - R"(" which is not in any of its "FILE_SET BASE_DIRS".)")); + "\nin a \"FILE_SET TYPE CXX_MODULES\" but it is not " + "scheduled for compilation.")); continue; } diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index b3699ae..95d0be2 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -2540,6 +2540,12 @@ void cmVisualStudio10TargetGenerator::WriteAllSources(Elem& e0) break; } + std::string config; + if (!this->Configurations.empty()) { + config = this->Configurations[si.Configs[0]]; + } + auto const* fs = + this->GeneratorTarget->GetFileSetForSource(config, si.Source); if (tool) { // Compute set of configurations to exclude, if any. std::vector<size_t> const& include_configs = si.Configs; @@ -2604,6 +2610,13 @@ void cmVisualStudio10TargetGenerator::WriteAllSources(Elem& e0) if (si.Kind == cmGeneratorTarget::SourceKindObjectSource || si.Kind == cmGeneratorTarget::SourceKindUnityBatched) { this->OutputSourceSpecificFlags(e2, si.Source); + } else if (fs && fs->GetType() == "CXX_MODULES"_s) { + this->GeneratorTarget->Makefile->IssueMessage( + MessageType::FATAL_ERROR, + cmStrCat("Target \"", this->GeneratorTarget->GetName(), + "\" has source file\n ", si.Source->GetFullPath(), + "\nin a \"FILE_SET TYPE CXX_MODULES\" but it is not " + "scheduled for compilation.")); } if (si.Source->GetPropertyAsBool("SKIP_PRECOMPILE_HEADERS")) { e2.Element("PrecompiledHeader", "NotUsing"); @@ -2613,6 +2626,13 @@ void cmVisualStudio10TargetGenerator::WriteAllSources(Elem& e0) } this->FinishWritingSource(e2, toolSettings); + } else if (fs && fs->GetType() == "CXX_MODULES"_s) { + this->GeneratorTarget->Makefile->IssueMessage( + MessageType::FATAL_ERROR, + cmStrCat("Target \"", this->GeneratorTarget->GetName(), + "\" has source file\n ", si.Source->GetFullPath(), + "\nin a \"FILE_SET TYPE CXX_MODULES\" but it is not " + "scheduled for compilation.")); } } 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 |