diff options
author | Brad King <brad.king@kitware.com> | 2017-04-19 14:47:28 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2017-04-19 14:47:31 (GMT) |
commit | 44f0d2d9913595e214048b6d5a2b9ab2e9d1cf46 (patch) | |
tree | c95b4621b9a71adc962c9c2e3e3140a0fb73e627 /Source/cmExportBuildFileGenerator.cxx | |
parent | 9db9bb27ea3f3dd3db3913c2bc2233f03018d5b0 (diff) | |
parent | eec93bceec5411e4409b5e3ee5dc301fca6fcbfd (diff) | |
download | CMake-44f0d2d9913595e214048b6d5a2b9ab2e9d1cf46.zip CMake-44f0d2d9913595e214048b6d5a2b9ab2e9d1cf46.tar.gz CMake-44f0d2d9913595e214048b6d5a2b9ab2e9d1cf46.tar.bz2 |
Merge topic 'objlib-extend'
eec93bce Allow OBJECT libraries to be installed, exported, and imported
93c89bc7 Genex: Allow TARGET_OBJECTS to be used everywhere
ac0cf7ff Genex: Reject TARGET_OBJECTS on non-object libraries earlier
8577978c Tests: ExportImport C code should use explicit (void) in prototypes
26cfd039 cmInstallTargetGenerator: Re-order GenerateScriptForConfig logic
25f3f22a cmGlobalGenerator: Add method to check if object file location is known
d596c550 cmGeneratorTarget: Add method to get the object file directory
930042f2 cmGeneratorTarget: Factor out a GetTargetObjectNames method
...
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !712
Diffstat (limited to 'Source/cmExportBuildFileGenerator.cxx')
-rw-r--r-- | Source/cmExportBuildFileGenerator.cxx | 60 |
1 files changed, 42 insertions, 18 deletions
diff --git a/Source/cmExportBuildFileGenerator.cxx b/Source/cmExportBuildFileGenerator.cxx index 539d854..978a7a1 100644 --- a/Source/cmExportBuildFileGenerator.cxx +++ b/Source/cmExportBuildFileGenerator.cxx @@ -2,6 +2,7 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmExportBuildFileGenerator.h" +#include "cmAlgorithms.h" #include "cmExportSet.h" #include "cmGeneratorExpression.h" #include "cmGeneratorTarget.h" @@ -21,6 +22,8 @@ #include <sstream> #include <utility> +class cmSourceFile; + cmExportBuildFileGenerator::cmExportBuildFileGenerator() { this->LG = CM_NULLPTR; @@ -171,27 +174,48 @@ void cmExportBuildFileGenerator::SetImportLocationProperty( // Get the makefile in which to lookup target information. cmMakefile* mf = target->Makefile; - // Add the main target file. - { - std::string prop = "IMPORTED_LOCATION"; + if (target->GetType() == cmStateEnums::OBJECT_LIBRARY) { + std::string prop = "IMPORTED_OBJECTS"; prop += suffix; - std::string value; - if (target->IsAppBundleOnApple()) { - value = target->GetFullPath(config, false); - } else { - value = target->GetFullPath(config, false, true); + + // Compute all the object files inside this target and setup + // IMPORTED_OBJECTS as a list of object files + std::vector<cmSourceFile const*> objectSources; + target->GetObjectSources(objectSources, config); + std::string const obj_dir = target->GetObjectDirectory(config); + std::vector<std::string> objects; + for (std::vector<cmSourceFile const*>::const_iterator si = + objectSources.begin(); + si != objectSources.end(); ++si) { + const std::string& obj = target->GetObjectName(*si); + objects.push_back(obj_dir + obj); } - properties[prop] = value; - } - // Add the import library for windows DLLs. - if (target->HasImportLibrary() && - mf->GetDefinition("CMAKE_IMPORT_LIBRARY_SUFFIX")) { - std::string prop = "IMPORTED_IMPLIB"; - prop += suffix; - std::string value = target->GetFullPath(config, true); - target->GetImplibGNUtoMS(value, value, "${CMAKE_IMPORT_LIBRARY_SUFFIX}"); - properties[prop] = value; + // Store the property. + properties[prop] = cmJoin(objects, ";"); + } else { + // Add the main target file. + { + std::string prop = "IMPORTED_LOCATION"; + prop += suffix; + std::string value; + if (target->IsAppBundleOnApple()) { + value = target->GetFullPath(config, false); + } else { + value = target->GetFullPath(config, false, true); + } + properties[prop] = value; + } + + // Add the import library for windows DLLs. + if (target->HasImportLibrary() && + mf->GetDefinition("CMAKE_IMPORT_LIBRARY_SUFFIX")) { + std::string prop = "IMPORTED_IMPLIB"; + prop += suffix; + std::string value = target->GetFullPath(config, true); + target->GetImplibGNUtoMS(value, value, "${CMAKE_IMPORT_LIBRARY_SUFFIX}"); + properties[prop] = value; + } } } |