mirror of
https://github.com/Kitware/CMake.git
synced 2026-02-23 07:28:51 -06:00
Defer check for sources within a target until generation.
The `add_library` and `add_executable` commands can now be called with no source-files and won't generate a warning or error message, as long as source-files will be added later via the `target_sources` command. If during the generation step still no sources are associated with targets created by such calls a useful error message will be generated and generation fails. Targets of type `INTERFACE_LIBRARY`, `UTILITY` or `GLOBAL_TARGET` are excluded from this check because we do not need sources for these target types during generation. Fixes: #16872
This commit is contained in:
@@ -362,14 +362,6 @@ bool cmAddLibraryCommand::InitialPass(std::vector<std::string> const& args,
|
||||
return true;
|
||||
}
|
||||
|
||||
if (s == args.end()) {
|
||||
std::string msg = "You have called ADD_LIBRARY for library ";
|
||||
msg += args[0];
|
||||
msg += " without any source files. This typically indicates a problem ";
|
||||
msg += "with your CMakeLists.txt file";
|
||||
cmSystemTools::Message(msg.c_str(), "Warning");
|
||||
}
|
||||
|
||||
srclists.insert(srclists.end(), s, args.end());
|
||||
|
||||
this->Makefile->AddLibrary(libName, type, srclists, excludeFromAll);
|
||||
|
||||
Reference in New Issue
Block a user