summaryrefslogtreecommitdiffstats
path: root/Source/cmComputeLinkInformation.h
diff options
context:
space:
mode:
authorMarc Chevrier <marc.chevrier@gmail.com>2021-11-01 14:27:05 (GMT)
committerMarc Chevrier <marc.chevrier@gmail.com>2022-02-07 23:02:32 (GMT)
commit42965799b4747ab1e0afa6546be13444f68c1987 (patch)
tree6149298a0fc9fd0f836cbe92b602d6eb863dc581 /Source/cmComputeLinkInformation.h
parent78dd7d5292cef930b3d435e6901cc3b10ee02513 (diff)
downloadCMake-42965799b4747ab1e0afa6546be13444f68c1987.zip
CMake-42965799b4747ab1e0afa6546be13444f68c1987.tar.gz
CMake-42965799b4747ab1e0afa6546be13444f68c1987.tar.bz2
Genex: Add $<LINK_LIBRARY:...>
This generator expression offers the capability, for the link step, to decorate libraries with prefix/suffix flags and/or adding any specific flag for each library. Fixes: #22812, #18751, #20078, #22703
Diffstat (limited to 'Source/cmComputeLinkInformation.h')
-rw-r--r--Source/cmComputeLinkInformation.h65
1 files changed, 53 insertions, 12 deletions
diff --git a/Source/cmComputeLinkInformation.h b/Source/cmComputeLinkInformation.h
index 2edcd5f..ce9f393 100644
--- a/Source/cmComputeLinkInformation.h
+++ b/Source/cmComputeLinkInformation.h
@@ -5,6 +5,7 @@
#include "cmConfigure.h" // IWYU pragma: keep
#include <iosfwd>
+#include <map>
#include <memory>
#include <set>
#include <string>
@@ -28,6 +29,9 @@ class cmake;
*/
class cmComputeLinkInformation
{
+private:
+ class FeatureDescriptor;
+
public:
cmComputeLinkInformation(cmGeneratorTarget const* target,
const std::string& config);
@@ -43,28 +47,33 @@ public:
Yes,
};
- enum class ItemIsObject
- {
- No,
- Yes,
- };
-
struct Item
{
- Item() = default;
Item(BT<std::string> v, ItemIsPath isPath,
- ItemIsObject isObject = ItemIsObject::No,
- cmGeneratorTarget const* target = nullptr)
+ cmGeneratorTarget const* target = nullptr,
+ FeatureDescriptor const* feature = nullptr)
: Value(std::move(v))
, IsPath(isPath)
- , IsObject(isObject)
, Target(target)
+ , Feature(feature)
{
}
BT<std::string> Value;
- ItemIsPath IsPath = ItemIsPath::Yes;
- ItemIsObject IsObject = ItemIsObject::No;
+ ItemIsPath IsPath = ItemIsPath::No;
cmGeneratorTarget const* Target = nullptr;
+
+ bool HasFeature() const { return this->Feature != nullptr; }
+
+ BT<std::string> GetFormattedItem(std::string const& path) const
+ {
+ return { (this->Feature != nullptr)
+ ? this->Feature->GetDecoratedItem(path, this->IsPath)
+ : path,
+ Value.Backtrace };
+ }
+
+ private:
+ FeatureDescriptor const* Feature = nullptr;
};
using ItemVector = std::vector<Item>;
void AppendValues(std::string& result, std::vector<BT<std::string>>& values);
@@ -237,4 +246,36 @@ private:
void AddLibraryRuntimeInfo(std::string const& fullPath,
const cmGeneratorTarget* target);
void AddLibraryRuntimeInfo(std::string const& fullPath);
+
+ class FeatureDescriptor
+ {
+ public:
+ FeatureDescriptor() = default;
+ FeatureDescriptor(std::string name, std::string itemFormat);
+ FeatureDescriptor(std::string name, std::string itemPathFormat,
+ std::string itemNameFormat);
+ FeatureDescriptor(std::string name, std::string prefix,
+ std::string itemPathFormat, std::string itemNameFormat,
+ std::string suffix);
+
+ const std::string Name;
+ const bool Supported = false;
+ const std::string Prefix;
+ const std::string Suffix;
+ std::string GetDecoratedItem(std::string const& library,
+ ItemIsPath isPath) const;
+ std::string GetDecoratedItem(std::string const& library,
+ std::string const& linkItem,
+ std::string const& defaultValue,
+ ItemIsPath isPath) const;
+
+ private:
+ std::string ItemPathFormat;
+ std::string ItemNameFormat;
+ };
+ std::map<std::string, FeatureDescriptor> LibraryFeatureDescriptors;
+ bool AddLibraryFeature(std::string const& feature);
+ FeatureDescriptor const& GetLibraryFeature(std::string const& feature) const;
+ FeatureDescriptor const* FindLibraryFeature(
+ std::string const& feature) const;
};