Просмотр исходного кода

BUG: Fix export/import file generation to not store link dependencies of executables or modules.

Brad King 18 лет назад
Родитель
Сommit
437043bb04

+ 16 - 2
Source/cmExportFileGenerator.cxx

@@ -135,7 +135,22 @@ cmExportFileGenerator
     }
 
   // Add the transitive link dependencies for this configuration.
-  {
+  if(target->GetType() == cmTarget::STATIC_LIBRARY ||
+     target->GetType() == cmTarget::SHARED_LIBRARY)
+    {
+    this->SetImportLinkProperties(config, suffix, target, properties);
+    }
+}
+
+//----------------------------------------------------------------------------
+void
+cmExportFileGenerator
+::SetImportLinkProperties(const char* config, std::string const& suffix,
+                          cmTarget* target, ImportPropertyMap& properties)
+{
+  // Get the makefile in which to lookup target information.
+  cmMakefile* mf = target->GetMakefile();
+
   // Compute which library configuration to link.
   cmTarget::LinkLibraryType linkType = cmTarget::OPTIMIZED;
   if(config && cmSystemTools::UpperCase(config) == "DEBUG")
@@ -193,7 +208,6 @@ cmExportFileGenerator
   std::string prop = "IMPORTED_LINK_LIBRARIES";
   prop += suffix;
   properties[prop] = link_libs;
-  }
 }
 
 //----------------------------------------------------------------------------

+ 3 - 0
Source/cmExportFileGenerator.h

@@ -67,6 +67,9 @@ protected:
   void SetImportDetailProperties(const char* config,
                                  std::string const& suffix, cmTarget* target,
                                  ImportPropertyMap& properties);
+  void SetImportLinkProperties(const char* config,
+                               std::string const& suffix, cmTarget* target,
+                               ImportPropertyMap& properties);
 
   /** Each subclass knows how to generate its kind of export file.  */
   virtual bool GenerateMainFile(std::ostream& os) = 0;

+ 2 - 0
Tests/ExportImport/Export/CMakeLists.txt

@@ -5,7 +5,9 @@ if(CMAKE_ANSI_CFLAGS)
   set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_ANSI_CFLAGS}")
 endif(CMAKE_ANSI_CFLAGS)
 
+add_library(testExe1lib STATIC testExe1lib.c) # not exported
 add_executable(testExe1 testExe1.c)
+target_link_libraries(testExe1 testExe1lib)
 
 add_executable(testExe2 testExe2.c)
 set_property(TARGET testExe2 PROPERTY ENABLE_EXPORTS 1)

+ 3 - 1
Tests/ExportImport/Export/testExe1.c

@@ -1,5 +1,7 @@
 #include <stdio.h>
 
+extern int testExe1lib();
+
 int main(int argc, const char* argv[])
 {
   if(argc < 2)
@@ -20,5 +22,5 @@ int main(int argc, const char* argv[])
     return 1;
     }
   }
-  return 0;
+  return testExe1lib();
 }

+ 1 - 0
Tests/ExportImport/Export/testExe1lib.c

@@ -0,0 +1 @@
+int testExe1lib() { return 0; }