1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-10-14 02:08:27 +08:00

OpenWatcom: Add infrastructure to link to object files

This commit is contained in:
Brad King
2021-05-29 08:26:45 -04:00
parent 8a4ca110e4
commit f530b3a267
5 changed files with 44 additions and 11 deletions

View File

@@ -7,6 +7,7 @@ include_guard()
set(CMAKE_LIBRARY_PATH_FLAG "libpath ")
set(CMAKE_LINK_LIBRARY_FLAG "library ")
set(CMAKE_LINK_LIBRARY_FILE_FLAG "library ")
set(CMAKE_LINK_OBJECT_FILE_FLAG "file ")
if(CMAKE_VERBOSE_MAKEFILE)
set(CMAKE_WCL_QUIET)

View File

@@ -42,6 +42,7 @@ public:
cmGeneratorTarget const* Target = nullptr;
bool IsSharedDep = false;
bool IsFlag = false;
bool IsObject = false;
};
using EntryVector = std::vector<LinkEntry>;

View File

@@ -309,6 +309,13 @@ cmComputeLinkInformation::cmComputeLinkInformation(
this->LibLinkSuffix =
this->Makefile->GetSafeDefinition("CMAKE_LINK_LIBRARY_SUFFIX");
}
if (cmProp flag = this->Makefile->GetDefinition(
"CMAKE_" + this->LinkLanguage + "_LINK_OBJECT_FILE_FLAG")) {
this->ObjLinkFileFlag = *flag;
} else {
this->ObjLinkFileFlag =
this->Makefile->GetSafeDefinition("CMAKE_LINK_OBJECT_FILE_FLAG");
}
// Get options needed to specify RPATHs.
this->RuntimeUseChrpath = false;
@@ -514,7 +521,8 @@ bool cmComputeLinkInformation::Compute()
if (linkEntry.IsSharedDep) {
this->AddSharedDepItem(linkEntry.Item, linkEntry.Target);
} else {
this->AddItem(linkEntry.Item, linkEntry.Target);
this->AddItem(linkEntry.Item, linkEntry.Target,
linkEntry.IsObject ? ItemIsObject::Yes : ItemIsObject::No);
}
}
@@ -634,7 +642,8 @@ void cmComputeLinkInformation::AddImplicitLinkInfo(std::string const& lang)
}
void cmComputeLinkInformation::AddItem(BT<std::string> const& item,
cmGeneratorTarget const* tgt)
cmGeneratorTarget const* tgt,
ItemIsObject isObject)
{
// Compute the proper name to use to link this library.
const std::string& config = this->Config;
@@ -660,13 +669,14 @@ void cmComputeLinkInformation::AddItem(BT<std::string> const& item,
std::string exe = tgt->GetFullPath(config, artifact, true);
linkItem += exe;
this->Items.emplace_back(BT<std::string>(linkItem, item.Backtrace),
ItemIsPath::Yes, tgt);
ItemIsPath::Yes, ItemIsObject::No, tgt);
this->Depends.push_back(std::move(exe));
} else if (tgt->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
// Add the interface library as an item so it can be considered as part
// of COMPATIBLE_INTERFACE_ enforcement. The generators will ignore
// this for the actual link line.
this->Items.emplace_back(std::string(), ItemIsPath::No, tgt);
this->Items.emplace_back(std::string(), ItemIsPath::No, ItemIsObject::No,
tgt);
// Also add the item the interface specifies to be used in its place.
std::string const& libName = tgt->GetImportedLibName(config);
@@ -719,7 +729,7 @@ void cmComputeLinkInformation::AddItem(BT<std::string> const& item,
} else {
// Use the full path given to the library file.
this->Depends.push_back(item.Value);
this->AddFullItem(item);
this->AddFullItem(item, isObject);
this->AddLibraryRuntimeInfo(item.Value);
}
} else {
@@ -1084,10 +1094,11 @@ void cmComputeLinkInformation::AddTargetItem(BT<std::string> const& item,
}
// Now add the full path to the library.
this->Items.emplace_back(item, ItemIsPath::Yes, target);
this->Items.emplace_back(item, ItemIsPath::Yes, ItemIsObject::No, target);
}
void cmComputeLinkInformation::AddFullItem(BT<std::string> const& item)
void cmComputeLinkInformation::AddFullItem(BT<std::string> const& item,
ItemIsObject isObject)
{
// Check for the implicit link directory special case.
if (this->CheckImplicitDirItem(item.Value)) {
@@ -1138,7 +1149,7 @@ void cmComputeLinkInformation::AddFullItem(BT<std::string> const& item)
}
// Now add the full path to the library.
this->Items.emplace_back(item, ItemIsPath::Yes);
this->Items.emplace_back(item, ItemIsPath::Yes, isObject);
}
bool cmComputeLinkInformation::CheckImplicitDirItem(std::string const& item)

View File

@@ -41,18 +41,27 @@ 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)
: Value(std::move(v))
, IsPath(isPath)
, IsObject(isObject)
, Target(target)
{
}
BT<std::string> Value;
ItemIsPath IsPath = ItemIsPath::Yes;
ItemIsObject IsObject = ItemIsObject::No;
cmGeneratorTarget const* Target = nullptr;
};
using ItemVector = std::vector<Item>;
@@ -81,6 +90,11 @@ public:
return this->LibLinkFileFlag;
}
std::string const& GetObjLinkFileFlag() const
{
return this->ObjLinkFileFlag;
}
std::string const& GetRPathLinkFlag() const { return this->RPathLinkFlag; }
std::string GetRPathLinkString() const;
@@ -89,7 +103,8 @@ public:
const cmGeneratorTarget* GetTarget() { return this->Target; }
private:
void AddItem(BT<std::string> const& item, const cmGeneratorTarget* tgt);
void AddItem(BT<std::string> const& item, const cmGeneratorTarget* tgt,
ItemIsObject isObject = ItemIsObject::No);
void AddSharedDepItem(BT<std::string> const& item,
cmGeneratorTarget const* tgt);
void AddRuntimeDLL(cmGeneratorTarget const* tgt);
@@ -125,6 +140,7 @@ private:
const char* LoaderFlag;
std::string LibLinkFlag;
std::string LibLinkFileFlag;
std::string ObjLinkFileFlag;
std::string LibLinkSuffix;
std::string RuntimeFlag;
std::string RuntimeSep;
@@ -166,7 +182,7 @@ private:
// Handling of link items.
void AddTargetItem(BT<std::string> const& item,
const cmGeneratorTarget* target);
void AddFullItem(BT<std::string> const& item);
void AddFullItem(BT<std::string> const& item, ItemIsObject isObject);
bool CheckImplicitDirItem(std::string const& item);
void AddUserItem(BT<std::string> const& item, bool pathNotKnown);
void AddFrameworkItem(std::string const& item);

View File

@@ -75,7 +75,11 @@ void cmLinkLineComputer::ComputeLinkLibs(
BT<std::string> linkLib;
if (item.IsPath == cmComputeLinkInformation::ItemIsPath::Yes) {
linkLib.Value += cli.GetLibLinkFileFlag();
if (item.IsObject == cmComputeLinkInformation::ItemIsObject::Yes) {
linkLib.Value += cli.GetObjLinkFileFlag();
} else {
linkLib.Value += cli.GetLibLinkFileFlag();
}
linkLib.Value += this->ConvertToOutputFormat(
this->ConvertToLinkReference(item.Value.Value));
linkLib.Backtrace = item.Value.Backtrace;