mirror of
https://github.com/Kitware/CMake.git
synced 2026-02-18 05:01:50 -06:00
Merge branch 'cxxmodules-non-compiled-source-release' into cxxmodules-non-compiled-source
* cxxmodules-non-compiled-source-release: cxxmodules: detect and message about non-compiled sources
This commit is contained in:
@@ -122,10 +122,11 @@ Json::Value CollationInformationCxxModules(
|
|||||||
auto lookup = sf_map.find(file);
|
auto lookup = sf_map.find(file);
|
||||||
if (lookup == sf_map.end()) {
|
if (lookup == sf_map.end()) {
|
||||||
gt->Makefile->IssueMessage(
|
gt->Makefile->IssueMessage(
|
||||||
MessageType::INTERNAL_ERROR,
|
MessageType::FATAL_ERROR,
|
||||||
cmStrCat("Target \"", tgt->GetName(), "\" has source file \"",
|
cmStrCat("Target \"", tgt->GetName(), "\" has source file\n ",
|
||||||
file,
|
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;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2551,6 +2551,12 @@ void cmVisualStudio10TargetGenerator::WriteAllSources(Elem& e0)
|
|||||||
break;
|
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) {
|
if (tool) {
|
||||||
// Compute set of configurations to exclude, if any.
|
// Compute set of configurations to exclude, if any.
|
||||||
std::vector<size_t> const& include_configs = si.Configs;
|
std::vector<size_t> const& include_configs = si.Configs;
|
||||||
@@ -2616,6 +2622,13 @@ void cmVisualStudio10TargetGenerator::WriteAllSources(Elem& e0)
|
|||||||
if (si.Kind == cmGeneratorTarget::SourceKindObjectSource ||
|
if (si.Kind == cmGeneratorTarget::SourceKindObjectSource ||
|
||||||
si.Kind == cmGeneratorTarget::SourceKindUnityBatched) {
|
si.Kind == cmGeneratorTarget::SourceKindUnityBatched) {
|
||||||
this->OutputSourceSpecificFlags(e2, si.Source);
|
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")) {
|
if (si.Source->GetPropertyAsBool("SKIP_PRECOMPILE_HEADERS")) {
|
||||||
e2.Element("PrecompiledHeader", "NotUsing");
|
e2.Element("PrecompiledHeader", "NotUsing");
|
||||||
@@ -2625,6 +2638,13 @@ void cmVisualStudio10TargetGenerator::WriteAllSources(Elem& e0)
|
|||||||
}
|
}
|
||||||
|
|
||||||
this->FinishWritingSource(e2, toolSettings);
|
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."));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,11 @@ CMake Error in CMakeLists.txt:
|
|||||||
language has not been enabled
|
language has not been enabled
|
||||||
| The target named "nocxx" contains C\+\+ sources that export modules which is
|
| The target named "nocxx" contains C\+\+ sources that export modules which is
|
||||||
not supported by the generator
|
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.
|
CMake Generate step failed. Build files cannot be regenerated correctly.
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
1
|
||||||
@@ -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.
|
||||||
13
Tests/RunCMake/CXXModules/NotCompiledSourceModules.cmake
Normal file
13
Tests/RunCMake/CXXModules/NotCompiledSourceModules.cmake
Normal file
@@ -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)
|
||||||
@@ -71,8 +71,9 @@ foreach (fileset_type IN LISTS fileset_types)
|
|||||||
endforeach ()
|
endforeach ()
|
||||||
run_cmake("FileSet${fileset_type}InterfaceImported")
|
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.
|
# list.
|
||||||
|
run_cmake("NotCompiledSource${fileset_type}")
|
||||||
run_cmake("NotCXXSource${fileset_type}")
|
run_cmake("NotCXXSource${fileset_type}")
|
||||||
endforeach ()
|
endforeach ()
|
||||||
|
|
||||||
|
|||||||
0
Tests/RunCMake/CXXModules/sources/not-compiled.txt
Normal file
0
Tests/RunCMake/CXXModules/sources/not-compiled.txt
Normal file
Reference in New Issue
Block a user