2009-09-28 19:43:28 +04:00
|
|
|
/*============================================================================
|
|
|
|
CMake - Cross Platform Makefile Generator
|
|
|
|
Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
|
2008-01-28 16:38:36 +03:00
|
|
|
|
2009-09-28 19:43:28 +04:00
|
|
|
Distributed under the OSI-approved BSD License (the "License");
|
|
|
|
see accompanying file Copyright.txt for details.
|
2008-01-28 16:38:36 +03:00
|
|
|
|
2009-09-28 19:43:28 +04:00
|
|
|
This software is distributed WITHOUT ANY WARRANTY; without even the
|
|
|
|
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
See the License for more information.
|
|
|
|
============================================================================*/
|
2008-01-28 16:38:36 +03:00
|
|
|
#include "cmExportInstallFileGenerator.h"
|
|
|
|
|
2012-09-28 23:47:37 +04:00
|
|
|
#include "cmExportSet.h"
|
|
|
|
#include "cmExportSetMap.h"
|
2008-01-28 16:38:36 +03:00
|
|
|
#include "cmGeneratedFileStream.h"
|
2012-09-28 23:47:37 +04:00
|
|
|
#include "cmGlobalGenerator.h"
|
|
|
|
#include "cmLocalGenerator.h"
|
2008-01-28 16:38:36 +03:00
|
|
|
#include "cmInstallExportGenerator.h"
|
|
|
|
#include "cmInstallTargetGenerator.h"
|
2012-02-27 00:05:17 +04:00
|
|
|
#include "cmTargetExport.h"
|
2015-03-08 15:51:20 +03:00
|
|
|
#include "cmAlgorithms.h"
|
2008-01-28 16:38:36 +03:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
cmExportInstallFileGenerator
|
|
|
|
::cmExportInstallFileGenerator(cmInstallExportGenerator* iegen):
|
2012-03-01 14:52:32 +04:00
|
|
|
IEGen(iegen)
|
2008-01-28 16:38:36 +03:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2009-01-07 22:16:28 +03:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
std::string cmExportInstallFileGenerator::GetConfigImportFileGlob()
|
|
|
|
{
|
|
|
|
std::string glob = this->FileBase;
|
|
|
|
glob += "-*";
|
|
|
|
glob += this->FileExt;
|
|
|
|
return glob;
|
|
|
|
}
|
|
|
|
|
2008-01-28 16:38:36 +03:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os)
|
|
|
|
{
|
2013-01-05 15:13:49 +04:00
|
|
|
std::vector<cmTargetExport*> allTargets;
|
2012-11-30 12:26:09 +04:00
|
|
|
{
|
|
|
|
std::string expectedTargets;
|
|
|
|
std::string sep;
|
|
|
|
for(std::vector<cmTargetExport*>::const_iterator
|
|
|
|
tei = this->IEGen->GetExportSet()->GetTargetExports()->begin();
|
|
|
|
tei != this->IEGen->GetExportSet()->GetTargetExports()->end(); ++tei)
|
|
|
|
{
|
2015-10-17 14:31:33 +03:00
|
|
|
expectedTargets +=
|
2015-10-17 16:08:13 +03:00
|
|
|
sep + this->Namespace + (*tei)->Target->GetExportName();
|
2012-11-30 12:26:09 +04:00
|
|
|
sep = " ";
|
2013-01-05 15:13:49 +04:00
|
|
|
cmTargetExport * te = *tei;
|
2015-10-17 15:33:51 +03:00
|
|
|
if(this->ExportedTargets.insert(te->Target).second)
|
2008-02-06 22:20:36 +03:00
|
|
|
{
|
2013-01-05 15:13:49 +04:00
|
|
|
allTargets.push_back(te);
|
2008-02-06 22:20:36 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-01-05 22:31:31 +03:00
|
|
|
std::ostringstream e;
|
2013-01-20 21:02:13 +04:00
|
|
|
e << "install(EXPORT \""
|
2012-03-01 14:52:32 +04:00
|
|
|
<< this->IEGen->GetExportSet()->GetName()
|
|
|
|
<< "\" ...) " << "includes target \"" << te->Target->GetName()
|
2008-02-06 22:20:36 +03:00
|
|
|
<< "\" more than once in the export set.";
|
|
|
|
cmSystemTools::Error(e.str().c_str());
|
|
|
|
return false;
|
|
|
|
}
|
2008-01-28 16:38:36 +03:00
|
|
|
}
|
|
|
|
|
2012-12-31 01:06:12 +04:00
|
|
|
this->GenerateExpectedTargetsCode(os, expectedTargets);
|
|
|
|
}
|
|
|
|
|
2014-12-15 17:52:48 +03:00
|
|
|
// Set an _IMPORT_PREFIX variable for import location properties
|
|
|
|
// to reference if they are relative to the install prefix.
|
2015-08-06 00:05:22 +03:00
|
|
|
std::string installPrefix = this->IEGen->GetLocalGenerator()
|
|
|
|
->GetMakefile()->GetSafeDefinition("CMAKE_INSTALL_PREFIX");
|
2015-02-11 19:45:41 +03:00
|
|
|
std::string const& expDest = this->IEGen->GetDestination();
|
|
|
|
if(cmSystemTools::FileIsFullPath(expDest))
|
2013-01-27 12:42:54 +04:00
|
|
|
{
|
2014-12-15 17:52:48 +03:00
|
|
|
// The export file is being installed to an absolute path so the
|
|
|
|
// package is not relocatable. Use the configured install prefix.
|
|
|
|
os <<
|
|
|
|
"# The installation prefix configured by this project.\n"
|
|
|
|
"set(_IMPORT_PREFIX \"" << installPrefix << "\")\n"
|
|
|
|
"\n";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Add code to compute the installation prefix relative to the
|
|
|
|
// import file location.
|
2015-02-11 19:45:41 +03:00
|
|
|
std::string absDest = installPrefix + "/" + expDest;
|
2013-04-03 18:54:08 +04:00
|
|
|
std::string absDestS = absDest + "/";
|
|
|
|
os << "# Compute the installation prefix relative to this file.\n"
|
|
|
|
<< "get_filename_component(_IMPORT_PREFIX"
|
|
|
|
<< " \"${CMAKE_CURRENT_LIST_FILE}\" PATH)\n";
|
2013-11-20 05:12:00 +04:00
|
|
|
if(cmHasLiteralPrefix(absDestS.c_str(), "/lib/") ||
|
|
|
|
cmHasLiteralPrefix(absDestS.c_str(), "/lib64/") ||
|
|
|
|
cmHasLiteralPrefix(absDestS.c_str(), "/usr/lib/") ||
|
|
|
|
cmHasLiteralPrefix(absDestS.c_str(), "/usr/lib64/"))
|
2013-01-27 12:42:54 +04:00
|
|
|
{
|
2013-04-03 18:54:08 +04:00
|
|
|
// Handle "/usr move" symlinks created by some Linux distros.
|
|
|
|
os <<
|
|
|
|
"# Use original install prefix when loaded through a\n"
|
|
|
|
"# cross-prefix symbolic link such as /lib -> /usr/lib.\n"
|
|
|
|
"get_filename_component(_realCurr \"${_IMPORT_PREFIX}\" REALPATH)\n"
|
|
|
|
"get_filename_component(_realOrig \"" << absDest << "\" REALPATH)\n"
|
|
|
|
"if(_realCurr STREQUAL _realOrig)\n"
|
|
|
|
" set(_IMPORT_PREFIX \"" << absDest << "\")\n"
|
|
|
|
"endif()\n"
|
|
|
|
"unset(_realOrig)\n"
|
|
|
|
"unset(_realCurr)\n";
|
2013-03-08 18:23:44 +04:00
|
|
|
}
|
2015-02-11 19:45:41 +03:00
|
|
|
std::string dest = expDest;
|
2013-04-03 18:54:08 +04:00
|
|
|
while(!dest.empty())
|
2013-03-08 18:23:44 +04:00
|
|
|
{
|
2013-04-03 18:54:08 +04:00
|
|
|
os <<
|
|
|
|
"get_filename_component(_IMPORT_PREFIX \"${_IMPORT_PREFIX}\" PATH)\n";
|
|
|
|
dest = cmSystemTools::GetFilenamePath(dest);
|
2013-01-27 12:42:54 +04:00
|
|
|
}
|
2013-04-03 18:54:08 +04:00
|
|
|
os << "\n";
|
2013-01-27 12:42:54 +04:00
|
|
|
}
|
|
|
|
|
2012-09-23 15:45:17 +04:00
|
|
|
std::vector<std::string> missingTargets;
|
|
|
|
|
2013-06-04 18:47:57 +04:00
|
|
|
bool require2_8_12 = false;
|
2013-12-10 21:59:21 +04:00
|
|
|
bool require3_0_0 = false;
|
2014-11-28 20:58:38 +03:00
|
|
|
bool require3_1_0 = false;
|
2013-12-26 11:19:33 +04:00
|
|
|
bool requiresConfigFiles = false;
|
2012-12-31 01:06:12 +04:00
|
|
|
// Create all the imported targets.
|
2013-01-05 15:13:49 +04:00
|
|
|
for(std::vector<cmTargetExport*>::const_iterator
|
2012-12-31 01:06:12 +04:00
|
|
|
tei = allTargets.begin();
|
|
|
|
tei != allTargets.end(); ++tei)
|
|
|
|
{
|
2015-10-17 14:31:33 +03:00
|
|
|
cmGeneratorTarget* gt = (*tei)->Target;
|
2013-12-26 11:19:33 +04:00
|
|
|
|
|
|
|
requiresConfigFiles = requiresConfigFiles
|
2015-10-17 15:33:51 +03:00
|
|
|
|| gt->GetType() != cmState::INTERFACE_LIBRARY;
|
2013-12-26 11:19:33 +04:00
|
|
|
|
2015-10-17 15:33:51 +03:00
|
|
|
this->GenerateImportTargetCode(os, gt);
|
2012-09-23 15:45:17 +04:00
|
|
|
|
|
|
|
ImportPropertyMap properties;
|
|
|
|
|
2013-01-05 15:13:49 +04:00
|
|
|
this->PopulateIncludeDirectoriesInterface(*tei,
|
2012-09-23 15:45:17 +04:00
|
|
|
cmGeneratorExpression::InstallInterface,
|
|
|
|
properties, missingTargets);
|
2014-11-28 20:58:38 +03:00
|
|
|
this->PopulateSourcesInterface(*tei,
|
|
|
|
cmGeneratorExpression::InstallInterface,
|
|
|
|
properties, missingTargets);
|
2013-07-02 16:30:10 +04:00
|
|
|
this->PopulateInterfaceProperty("INTERFACE_SYSTEM_INCLUDE_DIRECTORIES",
|
2015-10-17 15:33:51 +03:00
|
|
|
gt,
|
2013-07-02 16:30:10 +04:00
|
|
|
cmGeneratorExpression::InstallInterface,
|
2012-09-23 15:45:17 +04:00
|
|
|
properties, missingTargets);
|
|
|
|
this->PopulateInterfaceProperty("INTERFACE_COMPILE_DEFINITIONS",
|
2015-10-17 15:33:51 +03:00
|
|
|
gt,
|
2012-09-23 15:45:17 +04:00
|
|
|
cmGeneratorExpression::InstallInterface,
|
|
|
|
properties, missingTargets);
|
2013-06-10 18:20:22 +04:00
|
|
|
this->PopulateInterfaceProperty("INTERFACE_COMPILE_OPTIONS",
|
2015-10-17 15:33:51 +03:00
|
|
|
gt,
|
2013-06-10 18:20:22 +04:00
|
|
|
cmGeneratorExpression::InstallInterface,
|
|
|
|
properties, missingTargets);
|
2013-11-20 17:54:39 +04:00
|
|
|
this->PopulateInterfaceProperty("INTERFACE_AUTOUIC_OPTIONS",
|
2015-10-17 15:33:51 +03:00
|
|
|
gt,
|
2013-11-20 17:54:39 +04:00
|
|
|
cmGeneratorExpression::InstallInterface,
|
|
|
|
properties, missingTargets);
|
2013-12-17 22:23:40 +04:00
|
|
|
this->PopulateInterfaceProperty("INTERFACE_COMPILE_FEATURES",
|
2015-10-17 15:33:51 +03:00
|
|
|
gt,
|
2013-12-17 22:23:40 +04:00
|
|
|
cmGeneratorExpression::InstallInterface,
|
|
|
|
properties, missingTargets);
|
2013-06-04 18:47:57 +04:00
|
|
|
|
|
|
|
const bool newCMP0022Behavior =
|
2015-10-20 02:12:37 +03:00
|
|
|
gt->GetPolicyStatusCMP0022() != cmPolicies::WARN
|
|
|
|
&& gt->GetPolicyStatusCMP0022() != cmPolicies::OLD;
|
2013-06-04 18:47:57 +04:00
|
|
|
if (newCMP0022Behavior)
|
|
|
|
{
|
2015-10-17 15:33:51 +03:00
|
|
|
if (this->PopulateInterfaceLinkLibrariesProperty(gt,
|
2013-06-04 18:47:57 +04:00
|
|
|
cmGeneratorExpression::InstallInterface,
|
|
|
|
properties, missingTargets)
|
|
|
|
&& !this->ExportOld)
|
|
|
|
{
|
|
|
|
require2_8_12 = true;
|
|
|
|
}
|
|
|
|
}
|
2015-10-17 15:33:51 +03:00
|
|
|
if (gt->GetType() == cmState::INTERFACE_LIBRARY)
|
2012-11-20 14:06:29 +04:00
|
|
|
{
|
2013-12-10 21:59:21 +04:00
|
|
|
require3_0_0 = true;
|
2012-11-20 14:06:29 +04:00
|
|
|
}
|
2015-10-17 15:33:51 +03:00
|
|
|
if(gt->GetProperty("INTERFACE_SOURCES"))
|
2014-11-28 20:58:38 +03:00
|
|
|
{
|
|
|
|
// We can only generate INTERFACE_SOURCES in CMake 3.3, but CMake 3.1
|
|
|
|
// can consume them.
|
|
|
|
require3_1_0 = true;
|
|
|
|
}
|
|
|
|
|
2013-01-12 15:13:19 +04:00
|
|
|
this->PopulateInterfaceProperty("INTERFACE_POSITION_INDEPENDENT_CODE",
|
2015-10-17 15:33:51 +03:00
|
|
|
gt, properties);
|
2015-08-04 20:19:42 +03:00
|
|
|
|
2015-10-17 14:31:33 +03:00
|
|
|
this->PopulateCompatibleInterfaceProperties(gt, properties);
|
2012-09-23 15:45:17 +04:00
|
|
|
|
2015-10-17 15:33:51 +03:00
|
|
|
this->GenerateInterfaceProperties(gt, os, properties);
|
2012-12-31 01:06:12 +04:00
|
|
|
}
|
|
|
|
|
2014-11-28 20:58:38 +03:00
|
|
|
if (require3_1_0)
|
|
|
|
{
|
|
|
|
this->GenerateRequiredCMakeVersion(os, "3.1.0");
|
|
|
|
}
|
|
|
|
else if (require3_0_0)
|
2012-11-20 14:06:29 +04:00
|
|
|
{
|
2014-02-19 18:15:33 +04:00
|
|
|
this->GenerateRequiredCMakeVersion(os, "3.0.0");
|
2012-11-20 14:06:29 +04:00
|
|
|
}
|
|
|
|
else if (require2_8_12)
|
2013-06-04 18:47:57 +04:00
|
|
|
{
|
2013-08-15 18:53:16 +04:00
|
|
|
this->GenerateRequiredCMakeVersion(os, "2.8.12");
|
2013-06-04 18:47:57 +04:00
|
|
|
}
|
2012-09-23 15:45:17 +04:00
|
|
|
|
2008-01-28 16:38:36 +03:00
|
|
|
// Now load per-configuration properties for them.
|
|
|
|
os << "# Load information for each installed configuration.\n"
|
2013-01-20 21:02:13 +04:00
|
|
|
<< "get_filename_component(_DIR \"${CMAKE_CURRENT_LIST_FILE}\" PATH)\n"
|
|
|
|
<< "file(GLOB CONFIG_FILES \"${_DIR}/"
|
2009-01-07 22:16:28 +03:00
|
|
|
<< this->GetConfigImportFileGlob() << "\")\n"
|
2013-01-20 21:02:13 +04:00
|
|
|
<< "foreach(f ${CONFIG_FILES})\n"
|
|
|
|
<< " include(${f})\n"
|
|
|
|
<< "endforeach()\n"
|
2008-01-28 16:38:36 +03:00
|
|
|
<< "\n";
|
|
|
|
|
2013-01-27 12:42:54 +04:00
|
|
|
// Cleanup the import prefix variable.
|
2014-12-15 17:52:48 +03:00
|
|
|
os << "# Cleanup temporary variables.\n"
|
|
|
|
<< "set(_IMPORT_PREFIX)\n"
|
|
|
|
<< "\n";
|
2013-01-13 12:48:45 +04:00
|
|
|
this->GenerateImportedFileCheckLoop(os);
|
|
|
|
|
2008-01-28 16:38:36 +03:00
|
|
|
bool result = true;
|
2013-12-26 11:19:33 +04:00
|
|
|
// Generate an import file for each configuration.
|
|
|
|
// Don't do this if we only export INTERFACE_LIBRARY targets.
|
|
|
|
if (requiresConfigFiles)
|
2008-01-28 16:38:36 +03:00
|
|
|
{
|
2013-12-26 11:19:33 +04:00
|
|
|
for(std::vector<std::string>::const_iterator
|
|
|
|
ci = this->Configurations.begin();
|
|
|
|
ci != this->Configurations.end(); ++ci)
|
2008-01-28 16:38:36 +03:00
|
|
|
{
|
2014-03-11 03:04:11 +04:00
|
|
|
if(!this->GenerateImportFileConfig(*ci, missingTargets))
|
2013-12-26 11:19:33 +04:00
|
|
|
{
|
|
|
|
result = false;
|
|
|
|
}
|
2008-01-28 16:38:36 +03:00
|
|
|
}
|
|
|
|
}
|
2013-01-13 12:44:52 +04:00
|
|
|
|
|
|
|
this->GenerateMissingTargetsCheckCode(os, missingTargets);
|
|
|
|
|
2008-01-28 16:38:36 +03:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2013-01-27 12:43:44 +04:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void
|
|
|
|
cmExportInstallFileGenerator::ReplaceInstallPrefix(std::string &input)
|
|
|
|
{
|
|
|
|
std::string::size_type pos = 0;
|
|
|
|
std::string::size_type lastPos = pos;
|
|
|
|
|
|
|
|
while((pos = input.find("$<INSTALL_PREFIX>", lastPos)) != input.npos)
|
|
|
|
{
|
|
|
|
std::string::size_type endPos = pos + sizeof("$<INSTALL_PREFIX>") - 1;
|
|
|
|
input.replace(pos, endPos - pos, "${_IMPORT_PREFIX}");
|
|
|
|
lastPos = endPos;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-01-28 16:38:36 +03:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
bool
|
2014-02-10 07:48:34 +04:00
|
|
|
cmExportInstallFileGenerator::GenerateImportFileConfig(
|
|
|
|
const std::string& config,
|
2013-01-13 12:44:52 +04:00
|
|
|
std::vector<std::string> &missingTargets)
|
2008-01-28 16:38:36 +03:00
|
|
|
{
|
|
|
|
// Skip configurations not enabled for this export.
|
2012-03-01 14:52:32 +04:00
|
|
|
if(!this->IEGen->InstallsForConfig(config))
|
2008-01-28 16:38:36 +03:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Construct the name of the file to generate.
|
|
|
|
std::string fileName = this->FileDir;
|
|
|
|
fileName += "/";
|
|
|
|
fileName += this->FileBase;
|
|
|
|
fileName += "-";
|
2014-02-10 07:48:34 +04:00
|
|
|
if(!config.empty())
|
2008-01-28 16:38:36 +03:00
|
|
|
{
|
|
|
|
fileName += cmSystemTools::LowerCase(config);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
fileName += "noconfig";
|
|
|
|
}
|
|
|
|
fileName += this->FileExt;
|
|
|
|
|
|
|
|
// Open the output file to generate it.
|
|
|
|
cmGeneratedFileStream exportFileStream(fileName.c_str(), true);
|
|
|
|
if(!exportFileStream)
|
|
|
|
{
|
|
|
|
std::string se = cmSystemTools::GetLastSystemError();
|
2015-01-05 22:31:31 +03:00
|
|
|
std::ostringstream e;
|
2014-03-11 16:35:32 +04:00
|
|
|
e << "cannot write to file \"" << fileName
|
2008-01-28 16:38:36 +03:00
|
|
|
<< "\": " << se;
|
|
|
|
cmSystemTools::Error(e.str().c_str());
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
std::ostream& os = exportFileStream;
|
|
|
|
|
|
|
|
// Start with the import file header.
|
|
|
|
this->GenerateImportHeaderCode(os, config);
|
|
|
|
|
|
|
|
// Generate the per-config target information.
|
2013-01-13 12:44:52 +04:00
|
|
|
this->GenerateImportConfig(os, config, missingTargets);
|
2008-01-28 16:38:36 +03:00
|
|
|
|
|
|
|
// End with the import file footer.
|
|
|
|
this->GenerateImportFooterCode(os);
|
|
|
|
|
|
|
|
// Record this per-config import file.
|
|
|
|
this->ConfigImportFiles[config] = fileName;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void
|
|
|
|
cmExportInstallFileGenerator
|
|
|
|
::GenerateImportTargetsConfig(std::ostream& os,
|
2014-02-10 07:48:34 +04:00
|
|
|
const std::string& config,
|
|
|
|
std::string const& suffix,
|
2013-01-13 12:44:52 +04:00
|
|
|
std::vector<std::string> &missingTargets)
|
2008-01-28 16:38:36 +03:00
|
|
|
{
|
|
|
|
// Add each target in the set to the export.
|
2012-09-25 21:19:27 +04:00
|
|
|
for(std::vector<cmTargetExport*>::const_iterator
|
2012-03-01 14:52:32 +04:00
|
|
|
tei = this->IEGen->GetExportSet()->GetTargetExports()->begin();
|
|
|
|
tei != this->IEGen->GetExportSet()->GetTargetExports()->end(); ++tei)
|
2008-01-28 16:38:36 +03:00
|
|
|
{
|
|
|
|
// Collect import properties for this target.
|
2012-02-27 10:09:40 +04:00
|
|
|
cmTargetExport const* te = *tei;
|
2015-10-08 01:21:51 +03:00
|
|
|
if (te->Target->GetType() == cmState::INTERFACE_LIBRARY)
|
2012-11-20 14:06:29 +04:00
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
2013-12-19 17:24:46 +04:00
|
|
|
|
|
|
|
ImportPropertyMap properties;
|
|
|
|
std::set<std::string> importedLocations;
|
|
|
|
|
2011-11-12 21:12:07 +04:00
|
|
|
this->SetImportLocationProperty(config, suffix, te->ArchiveGenerator,
|
|
|
|
properties, importedLocations);
|
|
|
|
this->SetImportLocationProperty(config, suffix, te->LibraryGenerator,
|
|
|
|
properties, importedLocations);
|
2008-01-28 16:38:36 +03:00
|
|
|
this->SetImportLocationProperty(config, suffix,
|
2011-11-12 21:12:07 +04:00
|
|
|
te->RuntimeGenerator, properties,
|
|
|
|
importedLocations);
|
|
|
|
this->SetImportLocationProperty(config, suffix, te->FrameworkGenerator,
|
|
|
|
properties, importedLocations);
|
|
|
|
this->SetImportLocationProperty(config, suffix, te->BundleGenerator,
|
|
|
|
properties, importedLocations);
|
2008-01-28 16:38:36 +03:00
|
|
|
|
|
|
|
// If any file location was set for the target add it to the
|
|
|
|
// import file.
|
|
|
|
if(!properties.empty())
|
|
|
|
{
|
|
|
|
// Get the rest of the target details.
|
2015-10-17 14:31:33 +03:00
|
|
|
cmGeneratorTarget *gtgt = te->Target;
|
2008-01-28 16:38:36 +03:00
|
|
|
this->SetImportDetailProperties(config, suffix,
|
2012-10-06 19:51:07 +04:00
|
|
|
gtgt, properties, missingTargets);
|
2008-01-28 16:38:36 +03:00
|
|
|
|
2013-01-04 18:58:16 +04:00
|
|
|
this->SetImportLinkInterface(config, suffix,
|
|
|
|
cmGeneratorExpression::InstallInterface,
|
2012-10-06 19:51:07 +04:00
|
|
|
gtgt, properties, missingTargets);
|
2013-01-04 18:58:16 +04:00
|
|
|
|
2008-01-28 16:38:36 +03:00
|
|
|
// TOOD: PUBLIC_HEADER_LOCATION
|
2008-01-28 23:22:07 +03:00
|
|
|
// This should wait until the build feature propagation stuff
|
|
|
|
// is done. Then this can be a propagated include directory.
|
2008-01-28 16:38:36 +03:00
|
|
|
// this->GenerateImportProperty(config, te->HeaderGenerator,
|
|
|
|
// properties);
|
|
|
|
|
|
|
|
// Generate code in the export file.
|
2015-10-17 16:10:32 +03:00
|
|
|
this->GenerateImportPropertyCode(os, config, gtgt, properties);
|
|
|
|
this->GenerateImportedFileChecksCode(os, gtgt, properties,
|
2011-11-12 21:12:07 +04:00
|
|
|
importedLocations);
|
2008-01-28 16:38:36 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void
|
|
|
|
cmExportInstallFileGenerator
|
2014-02-10 07:48:34 +04:00
|
|
|
::SetImportLocationProperty(const std::string& config,
|
|
|
|
std::string const& suffix,
|
2008-01-28 16:38:36 +03:00
|
|
|
cmInstallTargetGenerator* itgen,
|
2011-11-12 21:12:07 +04:00
|
|
|
ImportPropertyMap& properties,
|
|
|
|
std::set<std::string>& importedLocations
|
|
|
|
)
|
2008-01-28 16:38:36 +03:00
|
|
|
{
|
|
|
|
// Skip rules that do not match this configuration.
|
|
|
|
if(!(itgen && itgen->InstallsForConfig(config)))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-02-06 22:20:36 +03:00
|
|
|
// Get the target to be installed.
|
2015-10-17 15:54:15 +03:00
|
|
|
cmGeneratorTarget* target = itgen->GetTarget();
|
2008-01-28 16:38:36 +03:00
|
|
|
|
|
|
|
// Construct the installed location of the target.
|
2015-02-11 22:02:45 +03:00
|
|
|
std::string dest = itgen->GetDestination(config);
|
2008-01-28 16:38:36 +03:00
|
|
|
std::string value;
|
|
|
|
if(!cmSystemTools::FileIsFullPath(dest.c_str()))
|
|
|
|
{
|
|
|
|
// The target is installed relative to the installation prefix.
|
2014-12-15 17:52:48 +03:00
|
|
|
value = "${_IMPORT_PREFIX}/";
|
2008-01-28 16:38:36 +03:00
|
|
|
}
|
|
|
|
value += dest;
|
|
|
|
value += "/";
|
|
|
|
|
2008-02-06 22:20:36 +03:00
|
|
|
if(itgen->IsImportLibrary())
|
2008-01-28 21:05:58 +03:00
|
|
|
{
|
2008-02-06 22:20:36 +03:00
|
|
|
// Construct the property name.
|
|
|
|
std::string prop = "IMPORTED_IMPLIB";
|
|
|
|
prop += suffix;
|
|
|
|
|
|
|
|
// Append the installed file name.
|
|
|
|
value += itgen->GetInstallFilename(target, config,
|
|
|
|
cmInstallTargetGenerator::NameImplib);
|
|
|
|
|
|
|
|
// Store the property.
|
|
|
|
properties[prop] = value;
|
2011-11-12 21:12:07 +04:00
|
|
|
importedLocations.insert(prop);
|
2008-01-28 21:05:58 +03:00
|
|
|
}
|
2008-02-06 22:20:36 +03:00
|
|
|
else
|
2008-01-28 22:46:16 +03:00
|
|
|
{
|
2008-02-06 22:20:36 +03:00
|
|
|
// Construct the property name.
|
|
|
|
std::string prop = "IMPORTED_LOCATION";
|
|
|
|
prop += suffix;
|
2008-01-28 16:38:36 +03:00
|
|
|
|
2008-02-06 22:20:36 +03:00
|
|
|
// Append the installed file name.
|
2015-10-10 00:58:19 +03:00
|
|
|
if(target->IsAppBundleOnApple())
|
2008-02-06 22:20:36 +03:00
|
|
|
{
|
|
|
|
value += itgen->GetInstallFilename(target, config);
|
|
|
|
value += ".app/Contents/MacOS/";
|
|
|
|
value += itgen->GetInstallFilename(target, config);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
value += itgen->GetInstallFilename(target, config,
|
|
|
|
cmInstallTargetGenerator::NameReal);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Store the property.
|
|
|
|
properties[prop] = value;
|
2011-11-12 21:12:07 +04:00
|
|
|
importedLocations.insert(prop);
|
2008-02-06 22:20:36 +03:00
|
|
|
}
|
2008-01-28 16:38:36 +03:00
|
|
|
}
|
|
|
|
|
2012-09-28 23:47:37 +04:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void
|
2015-10-17 16:05:46 +03:00
|
|
|
cmExportInstallFileGenerator::HandleMissingTarget(std::string& link_libs,
|
|
|
|
std::vector<std::string>& missingTargets,
|
|
|
|
cmGeneratorTarget* depender, cmGeneratorTarget* dependee)
|
2012-09-28 23:47:37 +04:00
|
|
|
{
|
2013-05-17 12:12:02 +04:00
|
|
|
const std::string name = dependee->GetName();
|
2015-10-17 16:05:46 +03:00
|
|
|
cmGlobalGenerator* gg = dependee->GetLocalGenerator()->GetGlobalGenerator();
|
2015-10-17 16:01:25 +03:00
|
|
|
std::vector<std::string> namespaces = this->FindNamespaces(gg, name);
|
2012-09-28 23:47:37 +04:00
|
|
|
int targetOccurrences = (int)namespaces.size();
|
|
|
|
if (targetOccurrences == 1)
|
|
|
|
{
|
|
|
|
std::string missingTarget = namespaces[0];
|
2013-05-17 12:12:02 +04:00
|
|
|
|
2015-10-17 16:08:13 +03:00
|
|
|
missingTarget += dependee->GetExportName();
|
2012-09-28 23:47:37 +04:00
|
|
|
link_libs += missingTarget;
|
|
|
|
missingTargets.push_back(missingTarget);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-10-10 13:14:11 +04:00
|
|
|
// All exported targets should be known here and should be unique.
|
|
|
|
// This is probably user-error.
|
2012-09-28 23:47:37 +04:00
|
|
|
this->ComplainAboutMissingTarget(depender, dependee, targetOccurrences);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
std::vector<std::string>
|
|
|
|
cmExportInstallFileGenerator
|
2015-10-17 16:01:25 +03:00
|
|
|
::FindNamespaces(cmGlobalGenerator* gg, const std::string& name)
|
2012-09-28 23:47:37 +04:00
|
|
|
{
|
|
|
|
std::vector<std::string> namespaces;
|
|
|
|
const cmExportSetMap& exportSets = gg->GetExportSets();
|
|
|
|
|
|
|
|
for(cmExportSetMap::const_iterator expIt = exportSets.begin();
|
|
|
|
expIt != exportSets.end();
|
|
|
|
++expIt)
|
|
|
|
{
|
|
|
|
const cmExportSet* exportSet = expIt->second;
|
|
|
|
std::vector<cmTargetExport*> const* targets =
|
|
|
|
exportSet->GetTargetExports();
|
|
|
|
|
|
|
|
bool containsTarget = false;
|
|
|
|
for(unsigned int i=0; i<targets->size(); i++)
|
|
|
|
{
|
2016-01-21 05:29:58 +03:00
|
|
|
if (name == (*targets)[i]->TargetName)
|
2012-09-28 23:47:37 +04:00
|
|
|
{
|
|
|
|
containsTarget = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (containsTarget)
|
|
|
|
{
|
|
|
|
std::vector<cmInstallExportGenerator const*> const* installs =
|
|
|
|
exportSet->GetInstallations();
|
|
|
|
for(unsigned int i=0; i<installs->size(); i++)
|
|
|
|
{
|
|
|
|
namespaces.push_back((*installs)[i]->GetNamespace());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return namespaces;
|
|
|
|
}
|
|
|
|
|
2008-01-28 16:38:36 +03:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void
|
|
|
|
cmExportInstallFileGenerator
|
2015-10-17 16:05:46 +03:00
|
|
|
::ComplainAboutMissingTarget(cmGeneratorTarget* depender,
|
|
|
|
cmGeneratorTarget* dependee,
|
2012-09-15 23:55:24 +04:00
|
|
|
int occurrences)
|
2008-01-28 16:38:36 +03:00
|
|
|
{
|
2015-01-05 22:31:31 +03:00
|
|
|
std::ostringstream e;
|
2013-01-20 21:02:13 +04:00
|
|
|
e << "install(EXPORT \""
|
2012-03-01 14:52:32 +04:00
|
|
|
<< this->IEGen->GetExportSet()->GetName()
|
|
|
|
<< "\" ...) "
|
2008-02-01 16:56:00 +03:00
|
|
|
<< "includes target \"" << depender->GetName()
|
2012-09-15 23:55:24 +04:00
|
|
|
<< "\" which requires target \"" << dependee->GetName() << "\" ";
|
|
|
|
if (occurrences == 0)
|
|
|
|
{
|
|
|
|
e << "that is not in the export set.";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
e << "that is not in this export set, but " << occurrences
|
|
|
|
<< " times in others.";
|
|
|
|
}
|
2008-01-31 01:25:52 +03:00
|
|
|
cmSystemTools::Error(e.str().c_str());
|
2008-01-28 16:38:36 +03:00
|
|
|
}
|
2013-05-21 02:57:58 +04:00
|
|
|
|
|
|
|
std::string
|
2015-08-04 20:19:47 +03:00
|
|
|
cmExportInstallFileGenerator::InstallNameDir(cmGeneratorTarget* target,
|
2013-05-21 02:57:58 +04:00
|
|
|
const std::string&)
|
|
|
|
{
|
|
|
|
std::string install_name_dir;
|
|
|
|
|
2015-08-04 20:19:47 +03:00
|
|
|
cmMakefile* mf = target->Target->GetMakefile();
|
2013-05-21 02:57:58 +04:00
|
|
|
if(mf->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME"))
|
|
|
|
{
|
|
|
|
install_name_dir =
|
|
|
|
target->GetInstallNameDirForInstallTree();
|
|
|
|
}
|
|
|
|
|
|
|
|
return install_name_dir;
|
|
|
|
}
|