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"
|
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)
|
|
|
|
{
|
2012-12-31 01:06:12 +04:00
|
|
|
std::vector<cmTarget*> 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)
|
|
|
|
{
|
2013-05-17 12:12:02 +04:00
|
|
|
expectedTargets += sep + this->Namespace + (*tei)->Target->GetExportName();
|
2012-11-30 12:26:09 +04:00
|
|
|
sep = " ";
|
2012-02-27 10:09:40 +04:00
|
|
|
cmTargetExport const* te = *tei;
|
2008-02-06 22:20:36 +03:00
|
|
|
if(this->ExportedTargets.insert(te->Target).second)
|
|
|
|
{
|
2012-12-31 01:06:12 +04:00
|
|
|
allTargets.push_back(te->Target);
|
2008-02-06 22:20:36 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
cmOStringStream 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);
|
|
|
|
}
|
|
|
|
|
2013-01-27 12:42:54 +04:00
|
|
|
// Add code to compute the installation prefix relative to the
|
|
|
|
// import file location.
|
|
|
|
const char* installDest = this->IEGen->GetDestination();
|
|
|
|
if(!cmSystemTools::FileIsFullPath(installDest))
|
|
|
|
{
|
2013-03-08 18:23:44 +04:00
|
|
|
std::string installPrefix =
|
|
|
|
this->IEGen->GetMakefile()->GetSafeDefinition("CMAKE_INSTALL_PREFIX");
|
2013-04-03 18:54:08 +04:00
|
|
|
std::string absDest = installPrefix + "/" + installDest;
|
|
|
|
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";
|
|
|
|
if(strncmp(absDestS.c_str(), "/lib/", 5) == 0 ||
|
|
|
|
strncmp(absDestS.c_str(), "/lib64/", 7) == 0 ||
|
|
|
|
strncmp(absDestS.c_str(), "/usr/lib/", 9) == 0 ||
|
|
|
|
strncmp(absDestS.c_str(), "/usr/lib64/", 11) == 0)
|
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
|
|
|
}
|
2013-04-03 18:54:08 +04:00
|
|
|
std::string dest = installDest;
|
|
|
|
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
|
|
|
|
|
|
|
// Import location properties may reference this variable.
|
|
|
|
this->ImportPrefix = "${_IMPORT_PREFIX}/";
|
|
|
|
}
|
|
|
|
|
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;
|
2012-12-31 01:06:12 +04:00
|
|
|
// Create all the imported targets.
|
|
|
|
for(std::vector<cmTarget*>::const_iterator
|
|
|
|
tei = allTargets.begin();
|
|
|
|
tei != allTargets.end(); ++tei)
|
|
|
|
{
|
|
|
|
cmTarget* te = *tei;
|
|
|
|
this->GenerateImportTargetCode(os, te);
|
2012-09-23 15:45:17 +04:00
|
|
|
|
|
|
|
ImportPropertyMap properties;
|
|
|
|
|
2013-03-25 00:18:17 +04:00
|
|
|
this->PopulateIncludeDirectoriesInterface(te,
|
2012-09-23 15:45:17 +04:00
|
|
|
cmGeneratorExpression::InstallInterface,
|
|
|
|
properties, missingTargets);
|
|
|
|
this->PopulateInterfaceProperty("INTERFACE_COMPILE_DEFINITIONS",
|
|
|
|
te,
|
|
|
|
cmGeneratorExpression::InstallInterface,
|
|
|
|
properties, missingTargets);
|
2013-06-10 18:20:22 +04:00
|
|
|
this->PopulateInterfaceProperty("INTERFACE_COMPILE_OPTIONS",
|
|
|
|
te,
|
|
|
|
cmGeneratorExpression::InstallInterface,
|
|
|
|
properties, missingTargets);
|
2013-06-04 18:47:57 +04:00
|
|
|
|
|
|
|
const bool newCMP0022Behavior =
|
|
|
|
te->GetPolicyStatusCMP0022() != cmPolicies::WARN
|
|
|
|
&& te->GetPolicyStatusCMP0022() != cmPolicies::OLD;
|
|
|
|
if (newCMP0022Behavior)
|
|
|
|
{
|
|
|
|
if (this->PopulateInterfaceLinkLibrariesProperty(te,
|
|
|
|
cmGeneratorExpression::InstallInterface,
|
|
|
|
properties, missingTargets)
|
|
|
|
&& !this->ExportOld)
|
|
|
|
{
|
|
|
|
require2_8_12 = true;
|
|
|
|
}
|
|
|
|
}
|
2013-01-12 15:13:19 +04:00
|
|
|
this->PopulateInterfaceProperty("INTERFACE_POSITION_INDEPENDENT_CODE",
|
|
|
|
te, properties);
|
2013-01-20 20:09:29 +04:00
|
|
|
this->PopulateCompatibleInterfaceProperties(te, properties);
|
2012-09-23 15:45:17 +04:00
|
|
|
|
|
|
|
this->GenerateInterfaceProperties(te, os, properties);
|
2012-12-31 01:06:12 +04:00
|
|
|
}
|
|
|
|
|
2013-06-04 18:47:57 +04:00
|
|
|
if (require2_8_12)
|
|
|
|
{
|
|
|
|
this->GenerateRequiredCMakeVersion(os, "2.8.11.20130626");
|
|
|
|
}
|
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.
|
|
|
|
if(!this->ImportPrefix.empty())
|
|
|
|
{
|
|
|
|
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
|
|
|
// Generate an import file for each configuration.
|
|
|
|
bool result = true;
|
|
|
|
for(std::vector<std::string>::const_iterator
|
|
|
|
ci = this->Configurations.begin();
|
|
|
|
ci != this->Configurations.end(); ++ci)
|
|
|
|
{
|
2013-01-13 12:44:52 +04:00
|
|
|
if(!this->GenerateImportFileConfig(ci->c_str(), missingTargets))
|
2008-01-28 16:38:36 +03:00
|
|
|
{
|
|
|
|
result = false;
|
|
|
|
}
|
|
|
|
}
|
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
|
2013-01-13 12:44:52 +04:00
|
|
|
cmExportInstallFileGenerator::GenerateImportFileConfig(const char* config,
|
|
|
|
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 += "-";
|
|
|
|
if(config && *config)
|
|
|
|
{
|
|
|
|
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();
|
|
|
|
cmOStringStream e;
|
|
|
|
e << "cannot write to file \"" << fileName.c_str()
|
|
|
|
<< "\": " << 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,
|
2013-01-13 12:44:52 +04:00
|
|
|
const char* config, std::string const& suffix,
|
|
|
|
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;
|
2008-01-28 16:38:36 +03:00
|
|
|
ImportPropertyMap properties;
|
2011-11-12 21:12:07 +04:00
|
|
|
std::set<std::string> importedLocations;
|
|
|
|
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.
|
|
|
|
this->SetImportDetailProperties(config, suffix,
|
2012-09-16 00:38:30 +04:00
|
|
|
te->Target, properties, missingTargets);
|
2008-01-28 16:38:36 +03:00
|
|
|
|
2013-01-04 18:58:16 +04:00
|
|
|
this->SetImportLinkInterface(config, suffix,
|
|
|
|
cmGeneratorExpression::InstallInterface,
|
|
|
|
te->Target, properties, missingTargets);
|
|
|
|
|
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.
|
|
|
|
this->GenerateImportPropertyCode(os, config, te->Target, properties);
|
2011-11-12 21:12:07 +04:00
|
|
|
this->GenerateImportedFileChecksCode(os, te->Target, properties,
|
|
|
|
importedLocations);
|
2008-01-28 16:38:36 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void
|
|
|
|
cmExportInstallFileGenerator
|
|
|
|
::SetImportLocationProperty(const char* config, std::string const& suffix,
|
|
|
|
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.
|
|
|
|
cmTarget* target = itgen->GetTarget();
|
2008-01-28 16:38:36 +03:00
|
|
|
|
|
|
|
// Construct the installed location of the target.
|
|
|
|
std::string dest = itgen->GetDestination();
|
|
|
|
std::string value;
|
|
|
|
if(!cmSystemTools::FileIsFullPath(dest.c_str()))
|
|
|
|
{
|
|
|
|
// The target is installed relative to the installation prefix.
|
|
|
|
if(this->ImportPrefix.empty())
|
|
|
|
{
|
|
|
|
this->ComplainAboutImportPrefix(itgen);
|
|
|
|
}
|
|
|
|
value = this->ImportPrefix;
|
|
|
|
}
|
|
|
|
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.
|
2013-06-02 08:47:18 +04: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
|
|
|
|
cmExportInstallFileGenerator::HandleMissingTarget(
|
|
|
|
std::string& link_libs, std::vector<std::string>& missingTargets,
|
|
|
|
cmMakefile* mf, cmTarget* depender, cmTarget* dependee)
|
|
|
|
{
|
2013-05-17 12:12:02 +04:00
|
|
|
const std::string name = dependee->GetName();
|
2012-09-28 23:47:37 +04:00
|
|
|
std::vector<std::string> namespaces = this->FindNamespaces(mf, name);
|
|
|
|
int targetOccurrences = (int)namespaces.size();
|
|
|
|
if (targetOccurrences == 1)
|
|
|
|
{
|
|
|
|
std::string missingTarget = namespaces[0];
|
2013-05-17 12:12:02 +04:00
|
|
|
|
|
|
|
missingTarget += dependee->GetExportName();
|
2012-09-28 23:47:37 +04:00
|
|
|
link_libs += missingTarget;
|
|
|
|
missingTargets.push_back(missingTarget);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// We are not appending, so all exported targets should be
|
|
|
|
// known here. This is probably user-error.
|
|
|
|
this->ComplainAboutMissingTarget(depender, dependee, targetOccurrences);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
std::vector<std::string>
|
|
|
|
cmExportInstallFileGenerator
|
|
|
|
::FindNamespaces(cmMakefile* mf, const std::string& name)
|
|
|
|
{
|
|
|
|
std::vector<std::string> namespaces;
|
|
|
|
cmGlobalGenerator* gg = mf->GetLocalGenerator()->GetGlobalGenerator();
|
|
|
|
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++)
|
|
|
|
{
|
|
|
|
if (name == (*targets)[i]->Target->GetName())
|
|
|
|
{
|
|
|
|
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
|
|
|
|
::ComplainAboutImportPrefix(cmInstallTargetGenerator* itgen)
|
|
|
|
{
|
2012-03-01 14:52:32 +04:00
|
|
|
const char* installDest = this->IEGen->GetDestination();
|
2008-01-28 16:38:36 +03:00
|
|
|
cmOStringStream e;
|
2013-01-20 21:02:13 +04:00
|
|
|
e << "install(EXPORT \""
|
2012-03-01 14:52:32 +04:00
|
|
|
<< this->IEGen->GetExportSet()->GetName()
|
|
|
|
<< "\") given absolute "
|
2008-01-28 16:38:36 +03:00
|
|
|
<< "DESTINATION \"" << installDest << "\" but the export "
|
|
|
|
<< "references an installation of target \""
|
|
|
|
<< itgen->GetTarget()->GetName() << "\" which has relative "
|
|
|
|
<< "DESTINATION \"" << itgen->GetDestination() << "\".";
|
|
|
|
cmSystemTools::Error(e.str().c_str());
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void
|
|
|
|
cmExportInstallFileGenerator
|
2012-09-15 23:55:24 +04:00
|
|
|
::ComplainAboutMissingTarget(cmTarget* depender,
|
|
|
|
cmTarget* dependee,
|
|
|
|
int occurrences)
|
2008-01-28 16:38:36 +03:00
|
|
|
{
|
|
|
|
cmOStringStream 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
|
|
|
|
cmExportInstallFileGenerator::InstallNameDir(cmTarget* target,
|
|
|
|
const std::string&)
|
|
|
|
{
|
|
|
|
std::string install_name_dir;
|
|
|
|
|
|
|
|
cmMakefile* mf = target->GetMakefile();
|
|
|
|
if(mf->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME"))
|
|
|
|
{
|
|
|
|
install_name_dir =
|
|
|
|
target->GetInstallNameDirForInstallTree();
|
|
|
|
}
|
|
|
|
|
|
|
|
return install_name_dir;
|
|
|
|
}
|