2009-09-28 15:43:28 +00:00
|
|
|
/*============================================================================
|
|
|
|
CMake - Cross Platform Makefile Generator
|
|
|
|
Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
|
2008-01-28 13:38:36 +00:00
|
|
|
|
2009-09-28 15:43:28 +00:00
|
|
|
Distributed under the OSI-approved BSD License (the "License");
|
|
|
|
see accompanying file Copyright.txt for details.
|
2008-01-28 13:38:36 +00:00
|
|
|
|
2009-09-28 15:43:28 +00: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 13:38:36 +00:00
|
|
|
#include "cmExportInstallFileGenerator.h"
|
|
|
|
|
2012-09-28 19:47:37 +00:00
|
|
|
#include "cmExportSet.h"
|
|
|
|
#include "cmExportSetMap.h"
|
2008-01-28 13:38:36 +00:00
|
|
|
#include "cmGeneratedFileStream.h"
|
2012-09-28 19:47:37 +00:00
|
|
|
#include "cmGlobalGenerator.h"
|
|
|
|
#include "cmLocalGenerator.h"
|
2008-01-28 13:38:36 +00:00
|
|
|
#include "cmInstallExportGenerator.h"
|
|
|
|
#include "cmInstallTargetGenerator.h"
|
2012-02-26 20:05:17 +00:00
|
|
|
#include "cmTargetExport.h"
|
2008-01-28 13:38:36 +00:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
cmExportInstallFileGenerator
|
|
|
|
::cmExportInstallFileGenerator(cmInstallExportGenerator* iegen):
|
2012-03-01 10:52:32 +00:00
|
|
|
IEGen(iegen)
|
2008-01-28 13:38:36 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2009-01-07 19:16:28 +00:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
std::string cmExportInstallFileGenerator::GetConfigImportFileGlob()
|
|
|
|
{
|
|
|
|
std::string glob = this->FileBase;
|
|
|
|
glob += "-*";
|
|
|
|
glob += this->FileExt;
|
|
|
|
return glob;
|
|
|
|
}
|
|
|
|
|
2008-01-28 13:38:36 +00:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os)
|
|
|
|
{
|
2012-12-30 21:06:12 +00:00
|
|
|
std::vector<cmTarget*> allTargets;
|
2012-11-30 08:26:09 +00: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 08:12:02 +00:00
|
|
|
expectedTargets += sep + this->Namespace + (*tei)->Target->GetExportName();
|
2012-11-30 08:26:09 +00:00
|
|
|
sep = " ";
|
2012-02-27 06:09:40 +00:00
|
|
|
cmTargetExport const* te = *tei;
|
2008-02-06 19:20:36 +00:00
|
|
|
if(this->ExportedTargets.insert(te->Target).second)
|
|
|
|
{
|
2012-12-30 21:06:12 +00:00
|
|
|
allTargets.push_back(te->Target);
|
2008-02-06 19:20:36 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
cmOStringStream e;
|
2013-01-20 17:02:13 +00:00
|
|
|
e << "install(EXPORT \""
|
2012-03-01 10:52:32 +00:00
|
|
|
<< this->IEGen->GetExportSet()->GetName()
|
|
|
|
<< "\" ...) " << "includes target \"" << te->Target->GetName()
|
2008-02-06 19:20:36 +00:00
|
|
|
<< "\" more than once in the export set.";
|
|
|
|
cmSystemTools::Error(e.str().c_str());
|
|
|
|
return false;
|
|
|
|
}
|
2008-01-28 13:38:36 +00:00
|
|
|
}
|
|
|
|
|
2012-12-30 21:06:12 +00:00
|
|
|
this->GenerateExpectedTargetsCode(os, expectedTargets);
|
|
|
|
}
|
|
|
|
|
2013-01-27 08:42:54 +00: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 14:23:44 +00:00
|
|
|
std::string installPrefix =
|
|
|
|
this->IEGen->GetMakefile()->GetSafeDefinition("CMAKE_INSTALL_PREFIX");
|
2013-04-03 14:54:08 +00: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 08:42:54 +00:00
|
|
|
{
|
2013-04-03 14:54:08 +00: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 14:23:44 +00:00
|
|
|
}
|
2013-04-03 14:54:08 +00:00
|
|
|
std::string dest = installDest;
|
|
|
|
while(!dest.empty())
|
2013-03-08 14:23:44 +00:00
|
|
|
{
|
2013-04-03 14:54:08 +00:00
|
|
|
os <<
|
|
|
|
"get_filename_component(_IMPORT_PREFIX \"${_IMPORT_PREFIX}\" PATH)\n";
|
|
|
|
dest = cmSystemTools::GetFilenamePath(dest);
|
2013-01-27 08:42:54 +00:00
|
|
|
}
|
2013-04-03 14:54:08 +00:00
|
|
|
os << "\n";
|
2013-01-27 08:42:54 +00:00
|
|
|
|
|
|
|
// Import location properties may reference this variable.
|
|
|
|
this->ImportPrefix = "${_IMPORT_PREFIX}/";
|
|
|
|
}
|
|
|
|
|
2012-09-23 11:45:17 +00:00
|
|
|
std::vector<std::string> missingTargets;
|
|
|
|
|
2012-12-30 21:06:12 +00: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 11:45:17 +00:00
|
|
|
|
|
|
|
ImportPropertyMap properties;
|
|
|
|
|
2013-03-24 20:18:17 +00:00
|
|
|
this->PopulateIncludeDirectoriesInterface(te,
|
2012-09-23 11:45:17 +00:00
|
|
|
cmGeneratorExpression::InstallInterface,
|
|
|
|
properties, missingTargets);
|
|
|
|
this->PopulateInterfaceProperty("INTERFACE_COMPILE_DEFINITIONS",
|
|
|
|
te,
|
|
|
|
cmGeneratorExpression::InstallInterface,
|
|
|
|
properties, missingTargets);
|
2013-06-10 14:20:22 +00:00
|
|
|
this->PopulateInterfaceProperty("INTERFACE_COMPILE_OPTIONS",
|
|
|
|
te,
|
|
|
|
cmGeneratorExpression::InstallInterface,
|
|
|
|
properties, missingTargets);
|
2013-01-12 11:13:19 +00:00
|
|
|
this->PopulateInterfaceProperty("INTERFACE_POSITION_INDEPENDENT_CODE",
|
|
|
|
te, properties);
|
2013-01-20 16:09:29 +00:00
|
|
|
this->PopulateCompatibleInterfaceProperties(te, properties);
|
2012-09-23 11:45:17 +00:00
|
|
|
|
|
|
|
this->GenerateInterfaceProperties(te, os, properties);
|
2012-12-30 21:06:12 +00:00
|
|
|
}
|
|
|
|
|
2012-09-23 11:45:17 +00:00
|
|
|
|
2008-01-28 13:38:36 +00:00
|
|
|
// Now load per-configuration properties for them.
|
|
|
|
os << "# Load information for each installed configuration.\n"
|
2013-01-20 17:02:13 +00:00
|
|
|
<< "get_filename_component(_DIR \"${CMAKE_CURRENT_LIST_FILE}\" PATH)\n"
|
|
|
|
<< "file(GLOB CONFIG_FILES \"${_DIR}/"
|
2009-01-07 19:16:28 +00:00
|
|
|
<< this->GetConfigImportFileGlob() << "\")\n"
|
2013-01-20 17:02:13 +00:00
|
|
|
<< "foreach(f ${CONFIG_FILES})\n"
|
|
|
|
<< " include(${f})\n"
|
|
|
|
<< "endforeach()\n"
|
2008-01-28 13:38:36 +00:00
|
|
|
<< "\n";
|
|
|
|
|
2013-01-27 08:42:54 +00:00
|
|
|
// Cleanup the import prefix variable.
|
|
|
|
if(!this->ImportPrefix.empty())
|
|
|
|
{
|
|
|
|
os << "# Cleanup temporary variables.\n"
|
|
|
|
<< "set(_IMPORT_PREFIX)\n"
|
|
|
|
<< "\n";
|
|
|
|
}
|
2013-01-13 08:48:45 +00:00
|
|
|
this->GenerateImportedFileCheckLoop(os);
|
|
|
|
|
2008-01-28 13:38:36 +00: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 08:44:52 +00:00
|
|
|
if(!this->GenerateImportFileConfig(ci->c_str(), missingTargets))
|
2008-01-28 13:38:36 +00:00
|
|
|
{
|
|
|
|
result = false;
|
|
|
|
}
|
|
|
|
}
|
2013-01-13 08:44:52 +00:00
|
|
|
|
|
|
|
this->GenerateMissingTargetsCheckCode(os, missingTargets);
|
|
|
|
|
2008-01-28 13:38:36 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2013-01-27 08:43:44 +00: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 13:38:36 +00:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
bool
|
2013-01-13 08:44:52 +00:00
|
|
|
cmExportInstallFileGenerator::GenerateImportFileConfig(const char* config,
|
|
|
|
std::vector<std::string> &missingTargets)
|
2008-01-28 13:38:36 +00:00
|
|
|
{
|
|
|
|
// Skip configurations not enabled for this export.
|
2012-03-01 10:52:32 +00:00
|
|
|
if(!this->IEGen->InstallsForConfig(config))
|
2008-01-28 13:38:36 +00: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 08:44:52 +00:00
|
|
|
this->GenerateImportConfig(os, config, missingTargets);
|
2008-01-28 13:38:36 +00: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 08:44:52 +00:00
|
|
|
const char* config, std::string const& suffix,
|
|
|
|
std::vector<std::string> &missingTargets)
|
2008-01-28 13:38:36 +00:00
|
|
|
{
|
|
|
|
// Add each target in the set to the export.
|
2012-09-25 17:19:27 +00:00
|
|
|
for(std::vector<cmTargetExport*>::const_iterator
|
2012-03-01 10:52:32 +00:00
|
|
|
tei = this->IEGen->GetExportSet()->GetTargetExports()->begin();
|
|
|
|
tei != this->IEGen->GetExportSet()->GetTargetExports()->end(); ++tei)
|
2008-01-28 13:38:36 +00:00
|
|
|
{
|
|
|
|
// Collect import properties for this target.
|
2012-02-27 06:09:40 +00:00
|
|
|
cmTargetExport const* te = *tei;
|
2008-01-28 13:38:36 +00:00
|
|
|
ImportPropertyMap properties;
|
2011-11-12 17:12:07 +00: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 13:38:36 +00:00
|
|
|
this->SetImportLocationProperty(config, suffix,
|
2011-11-12 17:12:07 +00:00
|
|
|
te->RuntimeGenerator, properties,
|
|
|
|
importedLocations);
|
|
|
|
this->SetImportLocationProperty(config, suffix, te->FrameworkGenerator,
|
|
|
|
properties, importedLocations);
|
|
|
|
this->SetImportLocationProperty(config, suffix, te->BundleGenerator,
|
|
|
|
properties, importedLocations);
|
2008-01-28 13:38:36 +00: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-15 20:38:30 +00:00
|
|
|
te->Target, properties, missingTargets);
|
2008-01-28 13:38:36 +00:00
|
|
|
|
2013-01-04 14:58:16 +00:00
|
|
|
this->SetImportLinkInterface(config, suffix,
|
|
|
|
cmGeneratorExpression::InstallInterface,
|
|
|
|
te->Target, properties, missingTargets);
|
|
|
|
|
2008-01-28 13:38:36 +00:00
|
|
|
// TOOD: PUBLIC_HEADER_LOCATION
|
2008-01-28 20:22:07 +00:00
|
|
|
// This should wait until the build feature propagation stuff
|
|
|
|
// is done. Then this can be a propagated include directory.
|
2008-01-28 13:38:36 +00:00
|
|
|
// this->GenerateImportProperty(config, te->HeaderGenerator,
|
|
|
|
// properties);
|
|
|
|
|
|
|
|
// Generate code in the export file.
|
|
|
|
this->GenerateImportPropertyCode(os, config, te->Target, properties);
|
2011-11-12 17:12:07 +00:00
|
|
|
this->GenerateImportedFileChecksCode(os, te->Target, properties,
|
|
|
|
importedLocations);
|
2008-01-28 13:38:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void
|
|
|
|
cmExportInstallFileGenerator
|
|
|
|
::SetImportLocationProperty(const char* config, std::string const& suffix,
|
|
|
|
cmInstallTargetGenerator* itgen,
|
2011-11-12 17:12:07 +00:00
|
|
|
ImportPropertyMap& properties,
|
|
|
|
std::set<std::string>& importedLocations
|
|
|
|
)
|
2008-01-28 13:38:36 +00:00
|
|
|
{
|
|
|
|
// Skip rules that do not match this configuration.
|
|
|
|
if(!(itgen && itgen->InstallsForConfig(config)))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-02-06 19:20:36 +00:00
|
|
|
// Get the target to be installed.
|
|
|
|
cmTarget* target = itgen->GetTarget();
|
2008-01-28 13:38:36 +00: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 19:20:36 +00:00
|
|
|
if(itgen->IsImportLibrary())
|
2008-01-28 18:05:58 +00:00
|
|
|
{
|
2008-02-06 19:20:36 +00: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 17:12:07 +00:00
|
|
|
importedLocations.insert(prop);
|
2008-01-28 18:05:58 +00:00
|
|
|
}
|
2008-02-06 19:20:36 +00:00
|
|
|
else
|
2008-01-28 19:46:16 +00:00
|
|
|
{
|
2008-02-06 19:20:36 +00:00
|
|
|
// Construct the property name.
|
|
|
|
std::string prop = "IMPORTED_LOCATION";
|
|
|
|
prop += suffix;
|
2008-01-28 13:38:36 +00:00
|
|
|
|
2008-02-06 19:20:36 +00:00
|
|
|
// Append the installed file name.
|
2013-06-02 04:47:18 +00:00
|
|
|
if(target->IsAppBundleOnApple())
|
2008-02-06 19:20:36 +00: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 17:12:07 +00:00
|
|
|
importedLocations.insert(prop);
|
2008-02-06 19:20:36 +00:00
|
|
|
}
|
2008-01-28 13:38:36 +00:00
|
|
|
}
|
|
|
|
|
2012-09-28 19:47:37 +00:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void
|
|
|
|
cmExportInstallFileGenerator::HandleMissingTarget(
|
|
|
|
std::string& link_libs, std::vector<std::string>& missingTargets,
|
|
|
|
cmMakefile* mf, cmTarget* depender, cmTarget* dependee)
|
|
|
|
{
|
2013-05-17 08:12:02 +00:00
|
|
|
const std::string name = dependee->GetName();
|
2012-09-28 19:47:37 +00: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 08:12:02 +00:00
|
|
|
|
|
|
|
missingTarget += dependee->GetExportName();
|
2012-09-28 19:47:37 +00: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 13:38:36 +00:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void
|
|
|
|
cmExportInstallFileGenerator
|
|
|
|
::ComplainAboutImportPrefix(cmInstallTargetGenerator* itgen)
|
|
|
|
{
|
2012-03-01 10:52:32 +00:00
|
|
|
const char* installDest = this->IEGen->GetDestination();
|
2008-01-28 13:38:36 +00:00
|
|
|
cmOStringStream e;
|
2013-01-20 17:02:13 +00:00
|
|
|
e << "install(EXPORT \""
|
2012-03-01 10:52:32 +00:00
|
|
|
<< this->IEGen->GetExportSet()->GetName()
|
|
|
|
<< "\") given absolute "
|
2008-01-28 13:38:36 +00: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 19:55:24 +00:00
|
|
|
::ComplainAboutMissingTarget(cmTarget* depender,
|
|
|
|
cmTarget* dependee,
|
|
|
|
int occurrences)
|
2008-01-28 13:38:36 +00:00
|
|
|
{
|
|
|
|
cmOStringStream e;
|
2013-01-20 17:02:13 +00:00
|
|
|
e << "install(EXPORT \""
|
2012-03-01 10:52:32 +00:00
|
|
|
<< this->IEGen->GetExportSet()->GetName()
|
|
|
|
<< "\" ...) "
|
2008-02-01 13:56:00 +00:00
|
|
|
<< "includes target \"" << depender->GetName()
|
2012-09-15 19:55:24 +00: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-30 22:25:52 +00:00
|
|
|
cmSystemTools::Error(e.str().c_str());
|
2008-01-28 13:38:36 +00:00
|
|
|
}
|
2013-05-20 22:57:58 +00: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;
|
|
|
|
}
|