summaryrefslogtreecommitdiff
path: root/Source/cmExportBuildFileGenerator.cxx
diff options
context:
space:
mode:
authorRobert Maynard <robert.maynard@kitware.com>2017-03-23 09:32:08 -0400
committerBrad King <brad.king@kitware.com>2017-04-18 11:36:10 -0400
commiteec93bceec5411e4409b5e3ee5dc301fca6fcbfd (patch)
tree58758ce2d61173c52559f55c0979236cafa7f969 /Source/cmExportBuildFileGenerator.cxx
parent93c89bc75ceee599ba7c08b8fe1ac5104942054f (diff)
downloadcmake-eec93bceec5411e4409b5e3ee5dc301fca6fcbfd.tar.gz
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.cxx60
1 files changed, 42 insertions, 18 deletions
diff --git a/Source/cmExportBuildFileGenerator.cxx b/Source/cmExportBuildFileGenerator.cxx
index 539d8541e4..978a7a1a21 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;
+ }
}
}