mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-05 21:31:08 -06:00
Merge topic 'cps-symbolic-info'
62a1d3e7f1FileAPI: Add symbolic property to targetsd92b6c3e20CPS: Add Symbolic Components03284e018fHelp: Simplify file-api version information for "abstract" field Acked-by: Kitware Robot <kwrobot@kitware.com> Acked-by: buildbot <buildbot@kitware.com> Merge-request: !11132
This commit is contained in:
@@ -33,6 +33,7 @@ bool cmAddLibraryCommand(std::vector<std::string> const& args,
|
||||
bool excludeFromAll = false;
|
||||
bool importTarget = false;
|
||||
bool importGlobal = false;
|
||||
bool symbolicTarget = false;
|
||||
|
||||
auto s = args.begin();
|
||||
|
||||
@@ -117,6 +118,9 @@ bool cmAddLibraryCommand(std::vector<std::string> const& args,
|
||||
} else if (*s == "EXCLUDE_FROM_ALL") {
|
||||
++s;
|
||||
excludeFromAll = true;
|
||||
} else if (*s == "SYMBOLIC") {
|
||||
++s;
|
||||
symbolicTarget = true;
|
||||
} else if (*s == "IMPORTED") {
|
||||
++s;
|
||||
importTarget = true;
|
||||
@@ -223,9 +227,9 @@ bool cmAddLibraryCommand(std::vector<std::string> const& args,
|
||||
}
|
||||
|
||||
/* ideally we should check whether for the linker language of the target
|
||||
CMAKE_${LANG}_CREATE_SHARED_LIBRARY is defined and if not default to
|
||||
STATIC. But at this point we know only the name of the target, but not
|
||||
yet its linker language. */
|
||||
CMAKE_${LANG}_CREATE_SHARED_LIBRARY is defined and if not default to
|
||||
STATIC. But at this point we know only the name of the target, but not
|
||||
yet its linker language. */
|
||||
if ((type == cmStateEnums::SHARED_LIBRARY ||
|
||||
type == cmStateEnums::MODULE_LIBRARY) &&
|
||||
!mf.GetState()->GetGlobalPropertyAsBool("TARGET_SUPPORTS_SHARED_LIBS")) {
|
||||
@@ -282,7 +286,8 @@ bool cmAddLibraryCommand(std::vector<std::string> const& args,
|
||||
}
|
||||
|
||||
// Create the imported target.
|
||||
mf.AddImportedTarget(libName, type, importGlobal);
|
||||
cmTarget* target = mf.AddImportedTarget(libName, type, importGlobal);
|
||||
target->SetSymbolic(symbolicTarget);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -312,8 +317,15 @@ bool cmAddLibraryCommand(std::vector<std::string> const& args,
|
||||
}
|
||||
}
|
||||
|
||||
if (symbolicTarget && type != cmStateEnums::INTERFACE_LIBRARY) {
|
||||
status.SetError(
|
||||
"SYMBOLIC option may only be used with INTERFACE libraries");
|
||||
return false;
|
||||
}
|
||||
|
||||
std::vector<std::string> srcs(s, args.end());
|
||||
mf.AddLibrary(libName, type, srcs, excludeFromAll);
|
||||
cmTarget* target = mf.AddLibrary(libName, type, srcs, excludeFromAll);
|
||||
target->SetSymbolic(symbolicTarget);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -292,7 +292,20 @@ void cmExportCMakeConfigGenerator::GenerateImportTargetCode(
|
||||
os << "add_library(" << targetName << " OBJECT IMPORTED)\n";
|
||||
break;
|
||||
case cmStateEnums::INTERFACE_LIBRARY:
|
||||
os << "add_library(" << targetName << " INTERFACE IMPORTED)\n";
|
||||
if (target->IsSymbolic()) {
|
||||
os << "if(CMAKE_VERSION VERSION_GREATER_EQUAL \""
|
||||
<< CMake_VERSION_DEVEL(4, 2)
|
||||
<< "\")\n"
|
||||
" add_library("
|
||||
<< targetName << " INTERFACE SYMBOLIC IMPORTED)\n"
|
||||
<< "elseif(CMAKE_VERSION VERSION_GREATER_EQUAL 3.2.0)\n"
|
||||
<< " add_library(" << targetName << " INTERFACE IMPORTED)\n"
|
||||
<< " set_target_properties(" << targetName
|
||||
<< " PROPERTIES SYMBOLIC TRUE)\n"
|
||||
<< "endif()\n";
|
||||
} else {
|
||||
os << "add_library(" << targetName << " INTERFACE IMPORTED)\n";
|
||||
}
|
||||
break;
|
||||
default: // should never happen
|
||||
break;
|
||||
|
||||
@@ -182,6 +182,7 @@ Json::Value* cmExportPackageInfoGenerator::GenerateImportTarget(
|
||||
|
||||
Json::Value& component = components[name];
|
||||
Json::Value& type = component["type"];
|
||||
|
||||
switch (targetType) {
|
||||
case cmStateEnums::EXECUTABLE:
|
||||
type = "executable";
|
||||
@@ -196,7 +197,7 @@ Json::Value* cmExportPackageInfoGenerator::GenerateImportTarget(
|
||||
type = "module";
|
||||
break;
|
||||
case cmStateEnums::INTERFACE_LIBRARY:
|
||||
type = "interface";
|
||||
type = target->IsSymbolic() ? "symbolic" : "interface";
|
||||
break;
|
||||
default:
|
||||
type = "unknown";
|
||||
|
||||
@@ -1269,6 +1269,9 @@ Json::Value Target::Dump()
|
||||
target["local"] = true;
|
||||
}
|
||||
}
|
||||
if (this->GT->IsSymbolic()) {
|
||||
target["symbolic"] = true;
|
||||
}
|
||||
if (!this->GT->IsInBuildSystem()) {
|
||||
target["abstract"] = true;
|
||||
}
|
||||
|
||||
@@ -1153,6 +1153,11 @@ bool cmGeneratorTarget::IsImportedGloballyVisible() const
|
||||
return this->Target->IsImportedGloballyVisible();
|
||||
}
|
||||
|
||||
bool cmGeneratorTarget::IsSymbolic() const
|
||||
{
|
||||
return this->Target->IsSymbolic();
|
||||
}
|
||||
|
||||
bool cmGeneratorTarget::IsForeign() const
|
||||
{
|
||||
return this->Target->IsForeign();
|
||||
|
||||
@@ -70,6 +70,7 @@ public:
|
||||
bool IsImported() const;
|
||||
bool IsImportedGloballyVisible() const;
|
||||
bool IsForeign() const;
|
||||
bool IsSymbolic() const;
|
||||
bool CanCompileSources() const;
|
||||
bool HasKnownRuntimeArtifactLocation(std::string const& config) const;
|
||||
std::string const& GetLocation(std::string const& config) const;
|
||||
|
||||
@@ -773,7 +773,9 @@ bool cmPackageInfoReader::ImportTargets(cmMakefile* makefile,
|
||||
|
||||
cmTarget* target = nullptr;
|
||||
if (type == "symbolic"_s) {
|
||||
// TODO
|
||||
target = this->AddLibraryComponent(
|
||||
makefile, cmStateEnums::INTERFACE_LIBRARY, fullName, *ci, package);
|
||||
target->SetSymbolic(true);
|
||||
} else if (type == "dylib"_s) {
|
||||
target = this->AddLibraryComponent(
|
||||
makefile, cmStateEnums::SHARED_LIBRARY, fullName, *ci, package);
|
||||
|
||||
@@ -634,7 +634,13 @@ bool HandleTargetMode(cmExecutionStatus& status,
|
||||
status.SetError("can not be used on an ALIAS target.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (cmTarget* target = status.GetMakefile().FindTargetToUse(name)) {
|
||||
if (target->IsSymbolic()) {
|
||||
status.SetError("can not be used on a SYMBOLIC target.");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Handle the current target.
|
||||
if (!HandleTarget(target, status.GetMakefile(), propertyName,
|
||||
propertyValue, appendAsString, appendMode, remove)) {
|
||||
|
||||
@@ -40,6 +40,10 @@ bool cmSetTargetPropertiesCommand(std::vector<std::string> const& args,
|
||||
return false;
|
||||
}
|
||||
if (cmTarget* target = mf.FindTargetToUse(tname)) {
|
||||
if (target->IsSymbolic()) {
|
||||
status.SetError("can not be used on a SYMBOLIC target.");
|
||||
return false;
|
||||
}
|
||||
// loop through all the props and set them
|
||||
for (auto k = propsIter + 1; k != args.end(); k += 2) {
|
||||
target->SetProperty(*k, *(k + 1));
|
||||
|
||||
@@ -608,6 +608,7 @@ public:
|
||||
bool IsAndroid;
|
||||
bool BuildInterfaceIncludesAppended;
|
||||
bool PerConfig;
|
||||
bool IsSymbolic;
|
||||
cmTarget::Visibility TargetVisibility;
|
||||
std::set<BT<std::pair<std::string, bool>>> Utilities;
|
||||
std::set<std::string> CodegenDependencies;
|
||||
@@ -885,6 +886,7 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type,
|
||||
this->impl->IsAIX = false;
|
||||
this->impl->IsApple = false;
|
||||
this->impl->IsAndroid = false;
|
||||
this->impl->IsSymbolic = false;
|
||||
this->impl->TargetVisibility = vis;
|
||||
this->impl->BuildInterfaceIncludesAppended = false;
|
||||
this->impl->PerConfig = (perConfig == PerConfig::Yes);
|
||||
@@ -1946,6 +1948,7 @@ MAKE_PROP(LINK_LIBRARIES);
|
||||
MAKE_PROP(MANUALLY_ADDED_DEPENDENCIES);
|
||||
MAKE_PROP(NAME);
|
||||
MAKE_PROP(SOURCES);
|
||||
MAKE_PROP(SYMBOLIC);
|
||||
MAKE_PROP(TYPE);
|
||||
MAKE_PROP(BINARY_DIR);
|
||||
MAKE_PROP(SOURCE_DIR);
|
||||
@@ -2047,6 +2050,7 @@ bool IsSettableProperty(cmMakefile* context, cmTarget* target,
|
||||
{ "MANUALLY_ADDED_DEPENDENCIES", { ROC::All } },
|
||||
{ "NAME", { ROC::All } },
|
||||
{ "SOURCES", { ROC::Imported } },
|
||||
{ "SYMBOLIC", { ROC::All } },
|
||||
{ "TYPE", { ROC::All } },
|
||||
{ "ALIAS_GLOBAL", { ROC::All, cmPolicies::CMP0160 } },
|
||||
{ "BINARY_DIR", { ROC::All, cmPolicies::CMP0160 } },
|
||||
@@ -2067,6 +2071,11 @@ bool IsSettableProperty(cmMakefile* context, cmTarget* target,
|
||||
}
|
||||
}
|
||||
|
||||
void cmTarget::SetSymbolic(bool const value)
|
||||
{
|
||||
this->impl->IsSymbolic = value;
|
||||
}
|
||||
|
||||
void cmTarget::SetProperty(std::string const& prop, cmValue value)
|
||||
{
|
||||
if (!IsSettableProperty(this->impl->Makefile, this, prop)) {
|
||||
@@ -2606,6 +2615,7 @@ cmValue cmTarget::GetProperty(std::string const& prop) const
|
||||
propBINARY_DIR,
|
||||
propSOURCE_DIR,
|
||||
propSOURCES,
|
||||
propSYMBOLIC,
|
||||
propINTERFACE_LINK_LIBRARIES,
|
||||
propINTERFACE_LINK_LIBRARIES_DIRECT,
|
||||
propINTERFACE_LINK_LIBRARIES_DIRECT_EXCLUDE,
|
||||
@@ -2626,6 +2636,10 @@ cmValue cmTarget::GetProperty(std::string const& prop) const
|
||||
return cmValue(propertyIter->second.Value);
|
||||
}
|
||||
|
||||
if (prop == propSYMBOLIC) {
|
||||
return this->IsSymbolic() ? cmValue(propTRUE) : cmValue(propFALSE);
|
||||
}
|
||||
|
||||
UsageRequirementProperty const* usageRequirements[] = {
|
||||
&this->impl->IncludeDirectories,
|
||||
&this->impl->CompileOptions,
|
||||
@@ -2760,6 +2774,11 @@ bool cmTarget::IsApple() const
|
||||
return this->impl->IsApple;
|
||||
}
|
||||
|
||||
bool cmTarget::IsSymbolic() const
|
||||
{
|
||||
return this->impl->IsSymbolic;
|
||||
}
|
||||
|
||||
bool cmTarget::IsNormal() const
|
||||
{
|
||||
switch (this->impl->TargetVisibility) {
|
||||
|
||||
@@ -193,6 +193,8 @@ public:
|
||||
//! Get the utilities used by this target
|
||||
std::set<BT<std::pair<std::string, bool>>> const& GetUtilities() const;
|
||||
|
||||
void SetSymbolic(bool value);
|
||||
|
||||
//! Set/Get a property of this target file
|
||||
void SetProperty(std::string const& prop, cmValue value);
|
||||
void SetProperty(std::string const& prop, std::nullptr_t)
|
||||
@@ -232,6 +234,7 @@ public:
|
||||
bool IsForeign() const;
|
||||
bool IsPerConfig() const;
|
||||
bool IsRuntimeBinary() const;
|
||||
bool IsSymbolic() const;
|
||||
bool CanCompileSources() const;
|
||||
|
||||
bool GetMappedConfig(std::string const& desiredConfig, cmValue& loc,
|
||||
|
||||
@@ -102,6 +102,11 @@ bool cmTargetLinkLibrariesCommand(std::vector<std::string> const& args,
|
||||
return true;
|
||||
}
|
||||
|
||||
if (target->IsSymbolic()) {
|
||||
status.SetError("can not be used on a SYMBOLIC target.");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Having a UTILITY library on the LHS is a bug.
|
||||
if (target->GetType() == cmStateEnums::UTILITY) {
|
||||
mf.IssueMessage(
|
||||
|
||||
@@ -42,6 +42,10 @@ bool cmTargetPropCommandBase::HandleArguments(
|
||||
this->HandleMissingTarget(args[0]);
|
||||
return false;
|
||||
}
|
||||
if (this->Target->IsSymbolic()) {
|
||||
this->SetError("can not be used on a SYMBOLIC target.");
|
||||
return false;
|
||||
}
|
||||
bool const isRegularTarget =
|
||||
(this->Target->GetType() == cmStateEnums::EXECUTABLE) ||
|
||||
(this->Target->GetType() == cmStateEnums::STATIC_LIBRARY) ||
|
||||
|
||||
Reference in New Issue
Block a user