diff options
author | Robert Maynard <robert.maynard@kitware.com> | 2017-03-23 13:32:08 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2017-04-18 15:36:10 (GMT) |
commit | eec93bceec5411e4409b5e3ee5dc301fca6fcbfd (patch) | |
tree | 58758ce2d61173c52559f55c0979236cafa7f969 /Source/cmExportBuildFileGenerator.cxx | |
parent | 93c89bc75ceee599ba7c08b8fe1ac5104942054f (diff) | |
download | CMake-eec93bceec5411e4409b5e3ee5dc301fca6fcbfd.zip CMake-eec93bceec5411e4409b5e3ee5dc301fca6fcbfd.tar.gz CMake-eec93bceec5411e4409b5e3ee5dc301fca6fcbfd.tar.bz2 |
Allow OBJECT libraries to be installed, exported, and imported
Teach install() and export() to handle the actual object files.
Disallow this on Xcode with multiple architectures because it
still cannot be cleanly supported there.
Co-Author: Brad King <brad.king@kitware.com>
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; + } } } |