diff options
author | Brad King <brad.king@kitware.com> | 2021-05-29 12:26:45 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2021-05-29 13:28:36 (GMT) |
commit | f530b3a26729d0820c804e312b72e0061d6eeb4b (patch) | |
tree | e2c37973e6a2c1bb3d13fcb3983a1aafff5f7837 | |
parent | 8a4ca110e49c64c4892a37ffe08a91a5a5219acf (diff) | |
download | CMake-f530b3a26729d0820c804e312b72e0061d6eeb4b.zip CMake-f530b3a26729d0820c804e312b72e0061d6eeb4b.tar.gz CMake-f530b3a26729d0820c804e312b72e0061d6eeb4b.tar.bz2 |
OpenWatcom: Add infrastructure to link to object files
-rw-r--r-- | Modules/Compiler/OpenWatcom.cmake | 1 | ||||
-rw-r--r-- | Source/cmComputeLinkDepends.h | 1 | ||||
-rw-r--r-- | Source/cmComputeLinkInformation.cxx | 27 | ||||
-rw-r--r-- | Source/cmComputeLinkInformation.h | 20 | ||||
-rw-r--r-- | Source/cmLinkLineComputer.cxx | 6 |
5 files changed, 44 insertions, 11 deletions
diff --git a/Modules/Compiler/OpenWatcom.cmake b/Modules/Compiler/OpenWatcom.cmake index ec36908..8cfe683 100644 --- a/Modules/Compiler/OpenWatcom.cmake +++ b/Modules/Compiler/OpenWatcom.cmake @@ -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) diff --git a/Source/cmComputeLinkDepends.h b/Source/cmComputeLinkDepends.h index 902500a..00fbd59 100644 --- a/Source/cmComputeLinkDepends.h +++ b/Source/cmComputeLinkDepends.h @@ -42,6 +42,7 @@ public: cmGeneratorTarget const* Target = nullptr; bool IsSharedDep = false; bool IsFlag = false; + bool IsObject = false; }; using EntryVector = std::vector<LinkEntry>; diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index 6371286..2647998 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -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) diff --git a/Source/cmComputeLinkInformation.h b/Source/cmComputeLinkInformation.h index 9afa0eb..7fe30b3 100644 --- a/Source/cmComputeLinkInformation.h +++ b/Source/cmComputeLinkInformation.h @@ -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); diff --git a/Source/cmLinkLineComputer.cxx b/Source/cmLinkLineComputer.cxx index 6eb8d75..5646368 100644 --- a/Source/cmLinkLineComputer.cxx +++ b/Source/cmLinkLineComputer.cxx @@ -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; |