diff options
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmAddLibraryCommand.cxx | 16 | ||||
-rw-r--r-- | Source/cmAddLibraryCommand.h | 2 | ||||
-rw-r--r-- | Source/cmComputeLinkDepends.cxx | 12 | ||||
-rw-r--r-- | Source/cmComputeLinkInformation.cxx | 13 | ||||
-rw-r--r-- | Source/cmLocalGenerator.cxx | 1 | ||||
-rw-r--r-- | Source/cmTarget.cxx | 20 | ||||
-rw-r--r-- | Source/cmTarget.h | 6 |
7 files changed, 60 insertions, 10 deletions
diff --git a/Source/cmAddLibraryCommand.cxx b/Source/cmAddLibraryCommand.cxx index 575dd04..2bc65ce 100644 --- a/Source/cmAddLibraryCommand.cxx +++ b/Source/cmAddLibraryCommand.cxx @@ -68,6 +68,12 @@ bool cmAddLibraryCommand type = cmTarget::MODULE_LIBRARY; haveSpecifiedType = true; } + else if(libType == "UNKNOWN") + { + ++s; + type = cmTarget::UNKNOWN_LIBRARY; + haveSpecifiedType = true; + } else if(*s == "EXCLUDE_FROM_ALL") { ++s; @@ -127,6 +133,16 @@ bool cmAddLibraryCommand return true; } + // A non-imported target may not have UNKNOWN type. + if(type == cmTarget::UNKNOWN_LIBRARY) + { + this->Makefile->IssueMessage( + cmake::FATAL_ERROR, + "The UNKNOWN library type may be used only for IMPORTED libraries." + ); + return true; + } + // Enforce name uniqueness. { std::string msg; diff --git a/Source/cmAddLibraryCommand.h b/Source/cmAddLibraryCommand.h index ad23ffc..6cad681 100644 --- a/Source/cmAddLibraryCommand.h +++ b/Source/cmAddLibraryCommand.h @@ -100,7 +100,7 @@ public: "\n" "The add_library command can also create IMPORTED library " "targets using this signature:\n" - " add_library(<name> <SHARED|STATIC|MODULE> IMPORTED)\n" + " add_library(<name> <SHARED|STATIC|MODULE|UNKNOWN> IMPORTED)\n" "An IMPORTED library target references a library file located " "outside the project. " "No rules are generated to build it. " diff --git a/Source/cmComputeLinkDepends.cxx b/Source/cmComputeLinkDepends.cxx index 177ec58..df329a6 100644 --- a/Source/cmComputeLinkDepends.cxx +++ b/Source/cmComputeLinkDepends.cxx @@ -891,6 +891,14 @@ void cmComputeLinkDepends::CheckWrongConfigItem(std::string const& item) } //---------------------------------------------------------------------------- +static bool cmComputeLinkDependsNotStatic(cmTarget* tgt) +{ + return (tgt && + tgt->GetType() != cmTarget::STATIC_LIBRARY && + tgt->GetType() != cmTarget::UNKNOWN_LIBRARY); +} + +//---------------------------------------------------------------------------- void cmComputeLinkDepends::PreserveOriginalEntries() { // Skip the part of the input sequence that already appears in the @@ -901,7 +909,7 @@ void cmComputeLinkDepends::PreserveOriginalEntries() out != this->FinalLinkOrder.end()) { cmTarget* tgt = this->EntryList[*in].Target; - if(tgt && tgt->GetType() != cmTarget::STATIC_LIBRARY) + if(cmComputeLinkDependsNotStatic(tgt)) { // Skip input items known to not be static libraries. ++in; @@ -924,7 +932,7 @@ void cmComputeLinkDepends::PreserveOriginalEntries() while(in != this->OriginalEntries.end()) { cmTarget* tgt = this->EntryList[*in].Target; - if(tgt && tgt->GetType() != cmTarget::STATIC_LIBRARY) + if(cmComputeLinkDependsNotStatic(tgt)) { // Skip input items known to not be static libraries. ++in; diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index 6e0f10b..0b02ae1 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -581,10 +581,7 @@ void cmComputeLinkInformation::AddItem(std::string const& item, cmTarget* tgt) return; } - if(tgt && (tgt->GetType() == cmTarget::STATIC_LIBRARY || - tgt->GetType() == cmTarget::SHARED_LIBRARY || - tgt->GetType() == cmTarget::MODULE_LIBRARY || - impexe)) + if(tgt && tgt->IsLinkable()) { // This is a CMake target. Ask the target for its real name. if(impexe && this->LoaderFlag) @@ -1555,6 +1552,14 @@ void cmComputeLinkInformation::AddLibraryRuntimeInfo(std::string const& fullPath, cmTarget* target) { + // Libraries with unknown type must be handled using just the file + // on disk. + if(target->GetType() == cmTarget::UNKNOWN_LIBRARY) + { + this->AddLibraryRuntimeInfo(fullPath); + return; + } + // Skip targets that are not shared libraries (modules cannot be linked). if(target->GetType() != cmTarget::SHARED_LIBRARY) { diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 064cfb5..4bf1839 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1706,6 +1706,7 @@ std::string cmLocalGenerator::GetRealDependency(const char* inName, case cmTarget::STATIC_LIBRARY: case cmTarget::SHARED_LIBRARY: case cmTarget::MODULE_LIBRARY: + case cmTarget::UNKNOWN_LIBRARY: { // Get the location of the target's output file and depend on it. if(const char* location = target->GetLocation(config)) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index caa534f..296e93d 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -30,7 +30,8 @@ const char* cmTarget::TargetTypeNames[] = { "EXECUTABLE", "STATIC_LIBRARY", "SHARED_LIBRARY", "MODULE_LIBRARY", "UTILITY", "GLOBAL_TARGET", - "INSTALL_FILES", "INSTALL_PROGRAMS", "INSTALL_DIRECTORY" + "INSTALL_FILES", "INSTALL_PROGRAMS", "INSTALL_DIRECTORY", + "UNKNOWN_LIBRARY" }; //---------------------------------------------------------------------------- @@ -277,6 +278,7 @@ void cmTarget::DefineProperties(cmake *cm) "For frameworks on OS X this is the location of the library file " "symlink just inside the framework folder. " "For DLLs this is the location of the \".dll\" part of the library. " + "For UNKNOWN libraries this is the location of the file to be linked. " "Ignored for non-imported targets."); cm->DefineProperty @@ -787,6 +789,16 @@ bool cmTarget::IsExecutableWithExports() } //---------------------------------------------------------------------------- +bool cmTarget::IsLinkable() +{ + return (this->GetType() == cmTarget::STATIC_LIBRARY || + this->GetType() == cmTarget::SHARED_LIBRARY || + this->GetType() == cmTarget::MODULE_LIBRARY || + this->GetType() == cmTarget::UNKNOWN_LIBRARY || + this->IsExecutableWithExports()); +} + +//---------------------------------------------------------------------------- bool cmTarget::IsFrameworkOnApple() { return (this->GetType() == cmTarget::SHARED_LIBRARY && @@ -1860,7 +1872,8 @@ const char *cmTarget::GetProperty(const char* prop, if(this->GetType() == cmTarget::EXECUTABLE || this->GetType() == cmTarget::STATIC_LIBRARY || this->GetType() == cmTarget::SHARED_LIBRARY || - this->GetType() == cmTarget::MODULE_LIBRARY) + this->GetType() == cmTarget::MODULE_LIBRARY || + this->GetType() == cmTarget::UNKNOWN_LIBRARY) { if(!this->IsImported() && strcmp(prop,"LOCATION") == 0) { @@ -1957,6 +1970,9 @@ const char *cmTarget::GetProperty(const char* prop, case cmTarget::INSTALL_DIRECTORY: return "INSTALL_DIRECTORY"; // break; /* unreachable */ + case cmTarget::UNKNOWN_LIBRARY: + return "UNKNOWN_LIBRARY"; + // break; /* unreachable */ } return 0; } diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 7141e41..07004be 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -80,7 +80,8 @@ public: cmTarget(); enum TargetType { EXECUTABLE, STATIC_LIBRARY, SHARED_LIBRARY, MODULE_LIBRARY, UTILITY, GLOBAL_TARGET, - INSTALL_FILES, INSTALL_PROGRAMS, INSTALL_DIRECTORY}; + INSTALL_FILES, INSTALL_PROGRAMS, INSTALL_DIRECTORY, + UNKNOWN_LIBRARY}; static const char* TargetTypeNames[]; enum CustomCommandType { PRE_BUILD, PRE_LINK, POST_BUILD }; @@ -393,6 +394,9 @@ public: enabled. */ bool IsExecutableWithExports(); + /** Return whether this target may be used to link another target. */ + bool IsLinkable(); + /** Return whether this target is a shared library Framework on Apple. */ bool IsFrameworkOnApple(); |