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:
@@ -7,6 +7,7 @@ include_guard()
|
|||||||
set(CMAKE_LIBRARY_PATH_FLAG "libpath ")
|
set(CMAKE_LIBRARY_PATH_FLAG "libpath ")
|
||||||
set(CMAKE_LINK_LIBRARY_FLAG "library ")
|
set(CMAKE_LINK_LIBRARY_FLAG "library ")
|
||||||
set(CMAKE_LINK_LIBRARY_FILE_FLAG "library ")
|
set(CMAKE_LINK_LIBRARY_FILE_FLAG "library ")
|
||||||
|
set(CMAKE_LINK_OBJECT_FILE_FLAG "file ")
|
||||||
|
|
||||||
if(CMAKE_VERBOSE_MAKEFILE)
|
if(CMAKE_VERBOSE_MAKEFILE)
|
||||||
set(CMAKE_WCL_QUIET)
|
set(CMAKE_WCL_QUIET)
|
||||||
|
@@ -42,6 +42,7 @@ public:
|
|||||||
cmGeneratorTarget const* Target = nullptr;
|
cmGeneratorTarget const* Target = nullptr;
|
||||||
bool IsSharedDep = false;
|
bool IsSharedDep = false;
|
||||||
bool IsFlag = false;
|
bool IsFlag = false;
|
||||||
|
bool IsObject = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
using EntryVector = std::vector<LinkEntry>;
|
using EntryVector = std::vector<LinkEntry>;
|
||||||
|
@@ -309,6 +309,13 @@ cmComputeLinkInformation::cmComputeLinkInformation(
|
|||||||
this->LibLinkSuffix =
|
this->LibLinkSuffix =
|
||||||
this->Makefile->GetSafeDefinition("CMAKE_LINK_LIBRARY_SUFFIX");
|
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.
|
// Get options needed to specify RPATHs.
|
||||||
this->RuntimeUseChrpath = false;
|
this->RuntimeUseChrpath = false;
|
||||||
@@ -514,7 +521,8 @@ bool cmComputeLinkInformation::Compute()
|
|||||||
if (linkEntry.IsSharedDep) {
|
if (linkEntry.IsSharedDep) {
|
||||||
this->AddSharedDepItem(linkEntry.Item, linkEntry.Target);
|
this->AddSharedDepItem(linkEntry.Item, linkEntry.Target);
|
||||||
} else {
|
} 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,
|
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.
|
// Compute the proper name to use to link this library.
|
||||||
const std::string& config = this->Config;
|
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);
|
std::string exe = tgt->GetFullPath(config, artifact, true);
|
||||||
linkItem += exe;
|
linkItem += exe;
|
||||||
this->Items.emplace_back(BT<std::string>(linkItem, item.Backtrace),
|
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));
|
this->Depends.push_back(std::move(exe));
|
||||||
} else if (tgt->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
|
} else if (tgt->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
|
||||||
// Add the interface library as an item so it can be considered as part
|
// Add the interface library as an item so it can be considered as part
|
||||||
// of COMPATIBLE_INTERFACE_ enforcement. The generators will ignore
|
// of COMPATIBLE_INTERFACE_ enforcement. The generators will ignore
|
||||||
// this for the actual link line.
|
// 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.
|
// Also add the item the interface specifies to be used in its place.
|
||||||
std::string const& libName = tgt->GetImportedLibName(config);
|
std::string const& libName = tgt->GetImportedLibName(config);
|
||||||
@@ -719,7 +729,7 @@ void cmComputeLinkInformation::AddItem(BT<std::string> const& item,
|
|||||||
} else {
|
} else {
|
||||||
// Use the full path given to the library file.
|
// Use the full path given to the library file.
|
||||||
this->Depends.push_back(item.Value);
|
this->Depends.push_back(item.Value);
|
||||||
this->AddFullItem(item);
|
this->AddFullItem(item, isObject);
|
||||||
this->AddLibraryRuntimeInfo(item.Value);
|
this->AddLibraryRuntimeInfo(item.Value);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -1084,10 +1094,11 @@ void cmComputeLinkInformation::AddTargetItem(BT<std::string> const& item,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Now add the full path to the library.
|
// 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.
|
// Check for the implicit link directory special case.
|
||||||
if (this->CheckImplicitDirItem(item.Value)) {
|
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.
|
// 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)
|
bool cmComputeLinkInformation::CheckImplicitDirItem(std::string const& item)
|
||||||
|
@@ -41,18 +41,27 @@ public:
|
|||||||
Yes,
|
Yes,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum class ItemIsObject
|
||||||
|
{
|
||||||
|
No,
|
||||||
|
Yes,
|
||||||
|
};
|
||||||
|
|
||||||
struct Item
|
struct Item
|
||||||
{
|
{
|
||||||
Item() = default;
|
Item() = default;
|
||||||
Item(BT<std::string> v, ItemIsPath isPath,
|
Item(BT<std::string> v, ItemIsPath isPath,
|
||||||
|
ItemIsObject isObject = ItemIsObject::No,
|
||||||
cmGeneratorTarget const* target = nullptr)
|
cmGeneratorTarget const* target = nullptr)
|
||||||
: Value(std::move(v))
|
: Value(std::move(v))
|
||||||
, IsPath(isPath)
|
, IsPath(isPath)
|
||||||
|
, IsObject(isObject)
|
||||||
, Target(target)
|
, Target(target)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
BT<std::string> Value;
|
BT<std::string> Value;
|
||||||
ItemIsPath IsPath = ItemIsPath::Yes;
|
ItemIsPath IsPath = ItemIsPath::Yes;
|
||||||
|
ItemIsObject IsObject = ItemIsObject::No;
|
||||||
cmGeneratorTarget const* Target = nullptr;
|
cmGeneratorTarget const* Target = nullptr;
|
||||||
};
|
};
|
||||||
using ItemVector = std::vector<Item>;
|
using ItemVector = std::vector<Item>;
|
||||||
@@ -81,6 +90,11 @@ public:
|
|||||||
return this->LibLinkFileFlag;
|
return this->LibLinkFileFlag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string const& GetObjLinkFileFlag() const
|
||||||
|
{
|
||||||
|
return this->ObjLinkFileFlag;
|
||||||
|
}
|
||||||
|
|
||||||
std::string const& GetRPathLinkFlag() const { return this->RPathLinkFlag; }
|
std::string const& GetRPathLinkFlag() const { return this->RPathLinkFlag; }
|
||||||
std::string GetRPathLinkString() const;
|
std::string GetRPathLinkString() const;
|
||||||
|
|
||||||
@@ -89,7 +103,8 @@ public:
|
|||||||
const cmGeneratorTarget* GetTarget() { return this->Target; }
|
const cmGeneratorTarget* GetTarget() { return this->Target; }
|
||||||
|
|
||||||
private:
|
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,
|
void AddSharedDepItem(BT<std::string> const& item,
|
||||||
cmGeneratorTarget const* tgt);
|
cmGeneratorTarget const* tgt);
|
||||||
void AddRuntimeDLL(cmGeneratorTarget const* tgt);
|
void AddRuntimeDLL(cmGeneratorTarget const* tgt);
|
||||||
@@ -125,6 +140,7 @@ private:
|
|||||||
const char* LoaderFlag;
|
const char* LoaderFlag;
|
||||||
std::string LibLinkFlag;
|
std::string LibLinkFlag;
|
||||||
std::string LibLinkFileFlag;
|
std::string LibLinkFileFlag;
|
||||||
|
std::string ObjLinkFileFlag;
|
||||||
std::string LibLinkSuffix;
|
std::string LibLinkSuffix;
|
||||||
std::string RuntimeFlag;
|
std::string RuntimeFlag;
|
||||||
std::string RuntimeSep;
|
std::string RuntimeSep;
|
||||||
@@ -166,7 +182,7 @@ private:
|
|||||||
// Handling of link items.
|
// Handling of link items.
|
||||||
void AddTargetItem(BT<std::string> const& item,
|
void AddTargetItem(BT<std::string> const& item,
|
||||||
const cmGeneratorTarget* target);
|
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);
|
bool CheckImplicitDirItem(std::string const& item);
|
||||||
void AddUserItem(BT<std::string> const& item, bool pathNotKnown);
|
void AddUserItem(BT<std::string> const& item, bool pathNotKnown);
|
||||||
void AddFrameworkItem(std::string const& item);
|
void AddFrameworkItem(std::string const& item);
|
||||||
|
@@ -75,7 +75,11 @@ void cmLinkLineComputer::ComputeLinkLibs(
|
|||||||
|
|
||||||
BT<std::string> linkLib;
|
BT<std::string> linkLib;
|
||||||
if (item.IsPath == cmComputeLinkInformation::ItemIsPath::Yes) {
|
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(
|
linkLib.Value += this->ConvertToOutputFormat(
|
||||||
this->ConvertToLinkReference(item.Value.Value));
|
this->ConvertToLinkReference(item.Value.Value));
|
||||||
linkLib.Backtrace = item.Value.Backtrace;
|
linkLib.Backtrace = item.Value.Backtrace;
|
||||||
|
Reference in New Issue
Block a user