Browse Source

Optionally skip link dependencies on shared library files

Add target property LINK_DEPENDS_NO_SHARED and initialization variable
CMAKE_LINK_DEPENDS_NO_SHARED to enable this behavior.

Suggested-by: Leif Walsh <[email protected]>
Brad King 13 years ago
parent
commit
ed9763136a

+ 9 - 1
Source/cmComputeLinkInformation.cxx

@@ -277,6 +277,10 @@ cmComputeLinkInformation
   this->UseImportLibrary =
   this->UseImportLibrary =
     this->Makefile->GetDefinition("CMAKE_IMPORT_LIBRARY_SUFFIX")?true:false;
     this->Makefile->GetDefinition("CMAKE_IMPORT_LIBRARY_SUFFIX")?true:false;
 
 
+  // Check whether we should skip dependencies on shared library files.
+  this->LinkDependsNoShared =
+    this->Target->GetPropertyAsBool("LINK_DEPENDS_NO_SHARED");
+
   // On platforms without import libraries there may be a special flag
   // On platforms without import libraries there may be a special flag
   // to use when creating a plugin (module) that obtains symbols from
   // to use when creating a plugin (module) that obtains symbols from
   // the program that will load it.
   // the program that will load it.
@@ -650,7 +654,11 @@ void cmComputeLinkInformation::AddItem(std::string const& item, cmTarget* tgt)
 
 
       // Pass the full path to the target file.
       // Pass the full path to the target file.
       std::string lib = tgt->GetFullPath(config, implib, true);
       std::string lib = tgt->GetFullPath(config, implib, true);
-      this->Depends.push_back(lib);
+      if(!this->LinkDependsNoShared ||
+         tgt->GetType() != cmTarget::SHARED_LIBRARY)
+        {
+        this->Depends.push_back(lib);
+        }
 
 
       this->AddTargetItem(lib, tgt);
       this->AddTargetItem(lib, tgt);
       this->AddLibraryRuntimeInfo(lib, tgt);
       this->AddLibraryRuntimeInfo(lib, tgt);

+ 1 - 0
Source/cmComputeLinkInformation.h

@@ -82,6 +82,7 @@ private:
   // Configuration information.
   // Configuration information.
   const char* Config;
   const char* Config;
   const char* LinkLanguage;
   const char* LinkLanguage;
+  bool LinkDependsNoShared;
 
 
   // Modes for dealing with dependent shared libraries.
   // Modes for dealing with dependent shared libraries.
   enum SharedDepMode
   enum SharedDepMode

+ 9 - 0
Source/cmDocumentVariables.cxx

@@ -1221,6 +1221,15 @@ void cmDocumentVariables::DefineVariables(cmake* cm)
      false,
      false,
      "Variables that Control the Build");
      "Variables that Control the Build");
 
 
+  cm->DefineProperty
+    ("CMAKE_LINK_DEPENDS_NO_SHARED", cmProperty::VARIABLE,
+     "Whether to skip link dependencies on shared library files.",
+     "This variable initializes the LINK_DEPENDS_NO_SHARED "
+     "property on targets when they are created.  "
+     "See that target property for additional information.",
+     false,
+     "Variables that Control the Build");
+
   cm->DefineProperty
   cm->DefineProperty
     ("CMAKE_AUTOMOC", cmProperty::VARIABLE,
     ("CMAKE_AUTOMOC", cmProperty::VARIABLE,
      "Whether to handle moc automatically for Qt targets.",
      "Whether to handle moc automatically for Qt targets.",

+ 17 - 0
Source/cmTarget.cxx

@@ -650,6 +650,22 @@ void cmTarget::DefineProperties(cmake *cm)
      "It is intended to specify dependencies on \"linker scripts\" for "
      "It is intended to specify dependencies on \"linker scripts\" for "
      "custom Makefile link rules.");
      "custom Makefile link rules.");
 
 
+  cm->DefineProperty
+    ("LINK_DEPENDS_NO_SHARED", cmProperty::TARGET,
+     "Do not depend on linked shared library files.",
+     "Set this property to true to tell CMake generators not to add "
+     "file-level dependencies on the shared library files linked by "
+     "this target.  "
+     "Modification to the shared libraries will not be sufficient to "
+     "re-link this target.  "
+     "Logical target-level dependencies will not be affected so the "
+     "linked shared libraries will still be brought up to date before "
+     "this target is built."
+     "\n"
+     "This property is initialized by the value of the variable "
+     "CMAKE_LINK_DEPENDS_NO_SHARED if it is set when a target is "
+     "created.");
+
   cm->DefineProperty
   cm->DefineProperty
     ("LINK_INTERFACE_LIBRARIES", cmProperty::TARGET,
     ("LINK_INTERFACE_LIBRARIES", cmProperty::TARGET,
      "List public interface libraries for a shared library or executable.",
      "List public interface libraries for a shared library or executable.",
@@ -1314,6 +1330,7 @@ void cmTarget::SetMakefile(cmMakefile* mf)
   this->SetPropertyDefault("OSX_ARCHITECTURES", 0);
   this->SetPropertyDefault("OSX_ARCHITECTURES", 0);
   this->SetPropertyDefault("AUTOMOC", 0);
   this->SetPropertyDefault("AUTOMOC", 0);
   this->SetPropertyDefault("AUTOMOC_MOC_OPTIONS", 0);
   this->SetPropertyDefault("AUTOMOC_MOC_OPTIONS", 0);
+  this->SetPropertyDefault("LINK_DEPENDS_NO_SHARED", 0);
   this->SetPropertyDefault("LINK_INTERFACE_LIBRARIES", 0);
   this->SetPropertyDefault("LINK_INTERFACE_LIBRARIES", 0);
   this->SetPropertyDefault("WIN32_EXECUTABLE", 0);
   this->SetPropertyDefault("WIN32_EXECUTABLE", 0);
   this->SetPropertyDefault("MACOSX_BUNDLE", 0);
   this->SetPropertyDefault("MACOSX_BUNDLE", 0);