mirror of
https://gitlab.kitware.com/cmake/cmake.git
synced 2026-09-25 04:09:36 +03:00
Print CMake entities' properties in human-readable form for debugging. Issue: #27513
51 lines
1.9 KiB
C++
51 lines
1.9 KiB
C++
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
|
file LICENSE.rst or https://cmake.org/licensing for details. */
|
|
#include "cmTargetPropertyHelper.h"
|
|
|
|
#include "cmGlobalGenerator.h"
|
|
#include "cmMakefile.h"
|
|
#include "cmTarget.h"
|
|
#include "cmValue.h"
|
|
|
|
cmGetTargetPropertyResult cmGetTargetProperty(std::string const& targetName,
|
|
std::string const& propertyName,
|
|
cmMakefile& mf,
|
|
cmValue& propertyValue)
|
|
{
|
|
cmTarget* target = mf.FindTargetToUse(targetName);
|
|
if (!target) {
|
|
return cmGetTargetPropertyResult::TargetNotFound;
|
|
}
|
|
return cmGetTargetProperty(targetName, target, propertyName, mf,
|
|
propertyValue);
|
|
}
|
|
|
|
cmGetTargetPropertyResult cmGetTargetProperty(std::string const& targetName,
|
|
cmTarget const* target,
|
|
std::string const& propertyName,
|
|
cmMakefile& mf,
|
|
cmValue& propertyValue)
|
|
{
|
|
if (propertyName == "ALIASED_TARGET" || propertyName == "ALIAS_GLOBAL") {
|
|
if (mf.IsAlias(targetName)) {
|
|
if (propertyName == "ALIASED_TARGET") {
|
|
propertyValue = cmValue(target->GetName());
|
|
} else {
|
|
static std::string const sTrue = "TRUE";
|
|
static std::string const sFalse = "FALSE";
|
|
propertyValue = cmValue(
|
|
mf.GetGlobalGenerator()->IsAlias(targetName) ? sTrue : sFalse);
|
|
}
|
|
} else {
|
|
propertyValue = cmValue(nullptr);
|
|
}
|
|
return cmGetTargetPropertyResult::Success;
|
|
}
|
|
|
|
propertyValue = target->GetComputedProperty(propertyName, mf);
|
|
if (!propertyValue) {
|
|
propertyValue = target->GetProperty(propertyName);
|
|
}
|
|
return cmGetTargetPropertyResult::Success;
|
|
}
|