mirror of
https://github.com/Kitware/CMake.git
synced 2026-11-06 05:16:58 +00:00
Extend support of file set LANGUAGE property to custom rules
In case of file set attached to custom rules, the semantic of this property is defined by the custom rule.
This commit is contained in:
1 parent
784727d1de
commit
e529a41ae5
5 files changed
+20
-15
No files matched your search
@@ -19,3 +19,7 @@ different languages' compilers and compilation rules in different targets.
|
||||
The value must be a literal language name. Generator expressions and
|
||||
appending values are not supported. The named language must be enabled by a
|
||||
:command:`project` or :command:`enable_language` command.
|
||||
|
||||
This property can also be specified for file sets of custom rules as defined by
|
||||
the :command:`add_custom_rule` command. In this case, the semantic attached to
|
||||
this property is defined by the custom rule.
|
||||
@@ -30,6 +30,8 @@ cmFileSet::cmFileSet(cmMakefile* makefile, cmTarget* target, std::string name,
|
||||
, Target(target)
|
||||
, Name(std::move(name))
|
||||
, Type(std::move(type))
|
||||
, Domain(Metadata::IsKnownType(this->Type) ? Metadata::FileSetDomain::NATIVE
|
||||
: Metadata::FileSetDomain::RULE)
|
||||
, Visibility(visibility)
|
||||
{
|
||||
}
|
||||
@@ -269,14 +271,16 @@ void cmFileSet::SetProperty(std::string const& prop, cmValue value)
|
||||
this->InterfaceCompileDefinitions.emplace_back(value, lfbt);
|
||||
}
|
||||
} else if (prop == LANGUAGE) {
|
||||
if (this->GetType() != cm::FileSetMetadata::SOURCES &&
|
||||
this->GetType() != cm::FileSetMetadata::HEADERS) {
|
||||
if (this->GetDomain() != Metadata::FileSetDomain::RULE &&
|
||||
this->GetType() != Metadata::SOURCES &&
|
||||
this->GetType() != Metadata::HEADERS) {
|
||||
this->Makefile->IssueMessage(
|
||||
MessageType::FATAL_ERROR,
|
||||
"LANGUAGE property may only be set on a SOURCES or HEADERS file set.");
|
||||
"LANGUAGE property may only be set on a SOURCES, HEADERS, or custom "
|
||||
"rule file set.");
|
||||
return;
|
||||
}
|
||||
if (this->GetType() == cm::FileSetMetadata::HEADERS &&
|
||||
if (this->GetType() == Metadata::HEADERS &&
|
||||
!cmExperimental::HasSupportEnabled(*this->Makefile,
|
||||
cmExperimental::Feature::SYCL)) {
|
||||
this->Makefile->IssueMessage(
|
||||
|
||||
@@ -25,6 +25,7 @@ public:
|
||||
|
||||
std::string const& GetName() const { return this->Name; }
|
||||
std::string const& GetType() const { return this->Type; }
|
||||
cm::FileSetMetadata::FileSetDomain GetDomain() const { return this->Domain; }
|
||||
cm::FileSetMetadata::Visibility GetVisibility() const
|
||||
{
|
||||
return this->Visibility;
|
||||
@@ -95,6 +96,7 @@ private:
|
||||
cmTarget* Target;
|
||||
std::string Name;
|
||||
std::string Type;
|
||||
cm::FileSetMetadata::FileSetDomain Domain;
|
||||
cm::FileSetMetadata::Visibility Visibility;
|
||||
std::vector<BT<std::string>> DirectoryEntries;
|
||||
std::vector<BT<std::string>> FileEntries;
|
||||
|
||||
+4
-10
@@ -3448,7 +3448,9 @@ std::pair<cmFileSet*, bool> cmTarget::GetOrCreateFileSet(
|
||||
this->impl->FileSets.emplace(name, cmFileSet(mf, this, name, type, vis));
|
||||
if (result.second) {
|
||||
auto bt = this->impl->Makefile->GetBacktrace();
|
||||
if (cm::contains(this->impl->FileSetTypes, type)) {
|
||||
// if (cm::contains(this->impl->FileSetTypes, type)) {
|
||||
if (result.first->second.GetDomain() ==
|
||||
cm::FileSetMetadata::FileSetDomain::NATIVE) {
|
||||
this->impl->FileSetTypes.at(type).AddFileSet(name, vis, std::move(bt));
|
||||
} else {
|
||||
this->impl->FileSetRules[type].AddFileSet(name, vis, std::move(bt));
|
||||
@@ -3483,16 +3485,8 @@ std::vector<std::string> cmTarget::GetAllFileSetNames(
|
||||
{
|
||||
std::vector<std::string> result;
|
||||
|
||||
bool const useNative =
|
||||
domains.contains(cm::FileSetMetadata::FileSetDomain::NATIVE);
|
||||
bool const useRule =
|
||||
domains.contains(cm::FileSetMetadata::FileSetDomain::RULE);
|
||||
|
||||
for (auto const& it : this->impl->FileSets) {
|
||||
bool nativeType =
|
||||
cm::contains(this->impl->FileSetTypes, it.second.GetType());
|
||||
|
||||
if ((useNative && nativeType) || (useRule && !nativeType)) {
|
||||
if (domains.contains(it.second.GetDomain())) {
|
||||
result.push_back(it.first);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
^CMake Error at LANGUAGE-WrongType\.cmake:[0-9]+ \(set_property\):
|
||||
LANGUAGE property may only be set on a SOURCES or HEADERS file set\.
|
||||
LANGUAGE property may only be set on a SOURCES, HEADERS, or custom rule
|
||||
file set\.
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists\.txt:[0-9]+ \(include\)
|
||||
Reference in new issue
Block a user