From 437043bb04da113bf822aa42d5cf3a3cc3366be1 Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 28 Jan 2008 13:37:59 -0500 Subject: BUG: Fix export/import file generation to not store link dependencies of executables or modules. --- Source/cmExportFileGenerator.cxx | 18 ++++++++++++++++-- Source/cmExportFileGenerator.h | 3 +++ Tests/ExportImport/Export/CMakeLists.txt | 2 ++ Tests/ExportImport/Export/testExe1.c | 4 +++- Tests/ExportImport/Export/testExe1lib.c | 1 + 5 files changed, 25 insertions(+), 3 deletions(-) create mode 100644 Tests/ExportImport/Export/testExe1lib.c diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index dd0c33a..d2c8ccb 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/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; - } } //---------------------------------------------------------------------------- diff --git a/Source/cmExportFileGenerator.h b/Source/cmExportFileGenerator.h index 8edf82e..27d998b 100644 --- a/Source/cmExportFileGenerator.h +++ b/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; diff --git a/Tests/ExportImport/Export/CMakeLists.txt b/Tests/ExportImport/Export/CMakeLists.txt index 62fe811..ac2f10f 100644 --- a/Tests/ExportImport/Export/CMakeLists.txt +++ b/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) diff --git a/Tests/ExportImport/Export/testExe1.c b/Tests/ExportImport/Export/testExe1.c index 39177d0..8ac154f 100644 --- a/Tests/ExportImport/Export/testExe1.c +++ b/Tests/ExportImport/Export/testExe1.c @@ -1,5 +1,7 @@ #include +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(); } diff --git a/Tests/ExportImport/Export/testExe1lib.c b/Tests/ExportImport/Export/testExe1lib.c new file mode 100644 index 0000000..60cd746 --- /dev/null +++ b/Tests/ExportImport/Export/testExe1lib.c @@ -0,0 +1 @@ +int testExe1lib() { return 0; } -- cgit v0.12