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 "cmExportFileGenerator.h"
|
|
|
|
|
2012-09-15 23:55:24 +04:00
|
|
|
#include "cmExportSet.h"
|
2008-01-28 16:38:36 +03:00
|
|
|
#include "cmGeneratedFileStream.h"
|
2012-09-15 23:55:24 +04:00
|
|
|
#include "cmGlobalGenerator.h"
|
|
|
|
#include "cmInstallExportGenerator.h"
|
|
|
|
#include "cmLocalGenerator.h"
|
2008-01-28 16:38:36 +03:00
|
|
|
#include "cmMakefile.h"
|
|
|
|
#include "cmSystemTools.h"
|
|
|
|
#include "cmTarget.h"
|
2012-09-15 23:55:24 +04:00
|
|
|
#include "cmTargetExport.h"
|
2008-03-14 00:04:32 +03:00
|
|
|
#include "cmVersion.h"
|
2008-01-28 16:38:36 +03:00
|
|
|
|
2008-01-28 21:21:42 +03:00
|
|
|
#include <cmsys/auto_ptr.hxx>
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
cmExportFileGenerator::cmExportFileGenerator()
|
|
|
|
{
|
|
|
|
this->AppendMode = false;
|
|
|
|
}
|
|
|
|
|
2008-01-28 16:38:36 +03:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmExportFileGenerator::AddConfiguration(const char* config)
|
|
|
|
{
|
|
|
|
this->Configurations.push_back(config);
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmExportFileGenerator::SetExportFile(const char* mainFile)
|
|
|
|
{
|
|
|
|
this->MainImportFile = mainFile;
|
|
|
|
this->FileDir =
|
|
|
|
cmSystemTools::GetFilenamePath(this->MainImportFile);
|
|
|
|
this->FileBase =
|
|
|
|
cmSystemTools::GetFilenameWithoutLastExtension(this->MainImportFile);
|
|
|
|
this->FileExt =
|
|
|
|
cmSystemTools::GetFilenameLastExtension(this->MainImportFile);
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
bool cmExportFileGenerator::GenerateImportFile()
|
|
|
|
{
|
|
|
|
// Open the output file to generate it.
|
2008-01-28 21:21:42 +03:00
|
|
|
cmsys::auto_ptr<std::ofstream> foutPtr;
|
|
|
|
if(this->AppendMode)
|
|
|
|
{
|
|
|
|
// Open for append.
|
|
|
|
cmsys::auto_ptr<std::ofstream>
|
|
|
|
ap(new std::ofstream(this->MainImportFile.c_str(), std::ios::app));
|
|
|
|
foutPtr = ap;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Generate atomically and with copy-if-different.
|
|
|
|
cmsys::auto_ptr<cmGeneratedFileStream>
|
|
|
|
ap(new cmGeneratedFileStream(this->MainImportFile.c_str(), true));
|
|
|
|
ap->SetCopyIfDifferent(true);
|
|
|
|
foutPtr = ap;
|
|
|
|
}
|
|
|
|
if(!foutPtr.get() || !*foutPtr)
|
2008-01-28 16:38:36 +03:00
|
|
|
{
|
|
|
|
std::string se = cmSystemTools::GetLastSystemError();
|
|
|
|
cmOStringStream e;
|
|
|
|
e << "cannot write to file \"" << this->MainImportFile
|
|
|
|
<< "\": " << se;
|
|
|
|
cmSystemTools::Error(e.str().c_str());
|
|
|
|
return false;
|
|
|
|
}
|
2008-01-28 21:21:42 +03:00
|
|
|
std::ostream& os = *foutPtr;
|
2008-01-28 16:38:36 +03:00
|
|
|
|
2008-04-27 15:30:46 +04:00
|
|
|
// Protect that file against use with older CMake versions.
|
|
|
|
os << "# Generated by CMake " << cmVersion::GetCMakeVersion() << "\n\n";
|
|
|
|
os << "IF(\"${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}\" LESS 2.5)\n"
|
|
|
|
<< " MESSAGE(FATAL_ERROR \"CMake >= 2.6.0 required\")\n"
|
|
|
|
<< "ENDIF(\"${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}\" LESS 2.5)\n";
|
|
|
|
|
2008-03-31 21:48:50 +04:00
|
|
|
// Isolate the file policy level.
|
|
|
|
// We use 2.6 here instead of the current version because newer
|
|
|
|
// versions of CMake should be able to export files imported by 2.6
|
|
|
|
// until the import format changes.
|
2008-03-14 00:04:32 +03:00
|
|
|
os << "CMAKE_POLICY(PUSH)\n"
|
2008-03-31 21:48:50 +04:00
|
|
|
<< "CMAKE_POLICY(VERSION 2.6)\n";
|
|
|
|
|
|
|
|
// Start with the import file header.
|
2008-01-28 16:38:36 +03:00
|
|
|
this->GenerateImportHeaderCode(os);
|
|
|
|
|
|
|
|
// Create all the imported targets.
|
|
|
|
bool result = this->GenerateMainFile(os);
|
|
|
|
|
|
|
|
// End with the import file footer.
|
|
|
|
this->GenerateImportFooterCode(os);
|
2008-03-14 00:04:32 +03:00
|
|
|
os << "CMAKE_POLICY(POP)\n";
|
2008-01-28 16:38:36 +03:00
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmExportFileGenerator::GenerateImportConfig(std::ostream& os,
|
|
|
|
const char* config)
|
|
|
|
{
|
|
|
|
// Construct the property configuration suffix.
|
|
|
|
std::string suffix = "_";
|
|
|
|
if(config && *config)
|
|
|
|
{
|
|
|
|
suffix += cmSystemTools::UpperCase(config);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
suffix += "NOCONFIG";
|
|
|
|
}
|
|
|
|
|
|
|
|
// Generate the per-config target information.
|
|
|
|
this->GenerateImportTargetsConfig(os, config, suffix);
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void
|
|
|
|
cmExportFileGenerator
|
|
|
|
::SetImportDetailProperties(const char* config, std::string const& suffix,
|
2012-09-16 00:38:30 +04:00
|
|
|
cmTarget* target, ImportPropertyMap& properties,
|
|
|
|
std::vector<std::string>& missingTargets
|
|
|
|
)
|
2008-01-28 16:38:36 +03:00
|
|
|
{
|
|
|
|
// Get the makefile in which to lookup target information.
|
|
|
|
cmMakefile* mf = target->GetMakefile();
|
|
|
|
|
|
|
|
// Add the soname for unix shared libraries.
|
|
|
|
if(target->GetType() == cmTarget::SHARED_LIBRARY ||
|
|
|
|
target->GetType() == cmTarget::MODULE_LIBRARY)
|
|
|
|
{
|
|
|
|
// Check whether this is a DLL platform.
|
|
|
|
bool dll_platform =
|
|
|
|
(mf->IsOn("WIN32") || mf->IsOn("CYGWIN") || mf->IsOn("MINGW"));
|
|
|
|
if(!dll_platform)
|
|
|
|
{
|
2012-04-22 17:42:55 +04:00
|
|
|
std::string prop;
|
|
|
|
std::string value;
|
|
|
|
if(target->HasSOName(config))
|
|
|
|
{
|
|
|
|
prop = "IMPORTED_SONAME";
|
|
|
|
value = target->GetSOName(config);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
prop = "IMPORTED_NO_SONAME";
|
|
|
|
value = "TRUE";
|
|
|
|
}
|
2008-01-28 16:38:36 +03:00
|
|
|
prop += suffix;
|
2012-04-22 17:42:55 +04:00
|
|
|
properties[prop] = value;
|
2008-01-28 16:38:36 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Add the transitive link dependencies for this configuration.
|
2009-07-07 17:45:29 +04:00
|
|
|
if(cmTarget::LinkInterface const* iface = target->GetLinkInterface(config))
|
2008-01-28 21:37:59 +03:00
|
|
|
{
|
2009-07-11 18:12:05 +04:00
|
|
|
this->SetImportLinkProperty(suffix, target,
|
|
|
|
"IMPORTED_LINK_INTERFACE_LANGUAGES",
|
2012-09-16 00:38:30 +04:00
|
|
|
iface->Languages, properties, missingTargets);
|
2008-01-31 23:45:31 +03:00
|
|
|
this->SetImportLinkProperty(suffix, target,
|
|
|
|
"IMPORTED_LINK_INTERFACE_LIBRARIES",
|
2012-09-16 00:38:30 +04:00
|
|
|
iface->Libraries, properties, missingTargets);
|
2008-01-31 23:45:31 +03:00
|
|
|
this->SetImportLinkProperty(suffix, target,
|
|
|
|
"IMPORTED_LINK_DEPENDENT_LIBRARIES",
|
2012-09-16 00:38:30 +04:00
|
|
|
iface->SharedDeps, properties, missingTargets);
|
2009-09-01 18:37:37 +04:00
|
|
|
if(iface->Multiplicity > 0)
|
|
|
|
{
|
|
|
|
std::string prop = "IMPORTED_LINK_INTERFACE_MULTIPLICITY";
|
|
|
|
prop += suffix;
|
|
|
|
cmOStringStream m;
|
|
|
|
m << iface->Multiplicity;
|
|
|
|
properties[prop] = m.str();
|
|
|
|
}
|
2008-01-31 01:25:52 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void
|
|
|
|
cmExportFileGenerator
|
2008-01-31 23:45:31 +03:00
|
|
|
::SetImportLinkProperty(std::string const& suffix,
|
|
|
|
cmTarget* target,
|
|
|
|
const char* propName,
|
|
|
|
std::vector<std::string> const& libs,
|
2012-09-16 00:38:30 +04:00
|
|
|
ImportPropertyMap& properties,
|
|
|
|
std::vector<std::string>& missingTargets
|
|
|
|
)
|
2008-01-31 01:25:52 +03:00
|
|
|
{
|
2008-01-31 23:45:31 +03:00
|
|
|
// Skip the property if there are no libraries.
|
|
|
|
if(libs.empty())
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-01-31 01:25:52 +03:00
|
|
|
// Get the makefile in which to lookup target information.
|
|
|
|
cmMakefile* mf = target->GetMakefile();
|
2008-01-28 16:38:36 +03:00
|
|
|
|
2008-01-31 01:25:52 +03:00
|
|
|
// Construct the property value.
|
|
|
|
std::string link_libs;
|
|
|
|
const char* sep = "";
|
|
|
|
for(std::vector<std::string>::const_iterator li = libs.begin();
|
|
|
|
li != libs.end(); ++li)
|
|
|
|
{
|
2008-01-31 01:57:54 +03:00
|
|
|
// Separate this from the previous entry.
|
|
|
|
link_libs += sep;
|
|
|
|
sep = ";";
|
|
|
|
|
2008-01-28 16:38:36 +03:00
|
|
|
// Append this entry.
|
2008-01-31 01:25:52 +03:00
|
|
|
if(cmTarget* tgt = mf->FindTargetToUse(li->c_str()))
|
2008-01-28 16:38:36 +03:00
|
|
|
{
|
2008-01-31 01:25:52 +03:00
|
|
|
// This is a target.
|
|
|
|
if(tgt->IsImported())
|
|
|
|
{
|
|
|
|
// The target is imported (and therefore is not in the
|
|
|
|
// export). Append the raw name.
|
|
|
|
link_libs += *li;
|
|
|
|
}
|
|
|
|
else if(this->ExportedTargets.find(tgt) != this->ExportedTargets.end())
|
2008-01-28 16:38:36 +03:00
|
|
|
{
|
|
|
|
// The target is in the export. Append it with the export
|
|
|
|
// namespace.
|
|
|
|
link_libs += this->Namespace;
|
2008-01-31 01:25:52 +03:00
|
|
|
link_libs += *li;
|
2008-01-28 16:38:36 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-09-28 23:47:37 +04:00
|
|
|
this->HandleMissingTarget(link_libs, missingTargets, mf, target, tgt);
|
2008-01-28 16:38:36 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Append the raw name.
|
2008-01-31 01:25:52 +03:00
|
|
|
link_libs += *li;
|
2008-01-28 16:38:36 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Store the property.
|
2008-01-31 23:45:31 +03:00
|
|
|
std::string prop = propName;
|
2008-01-28 16:38:36 +03:00
|
|
|
prop += suffix;
|
|
|
|
properties[prop] = link_libs;
|
|
|
|
}
|
|
|
|
|
2012-09-15 23:55:24 +04:00
|
|
|
|
2008-01-28 16:38:36 +03:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmExportFileGenerator::GenerateImportHeaderCode(std::ostream& os,
|
|
|
|
const char* config)
|
|
|
|
{
|
|
|
|
os << "#----------------------------------------------------------------\n"
|
|
|
|
<< "# Generated CMake target import file";
|
|
|
|
if(config)
|
|
|
|
{
|
|
|
|
os << " for configuration \"" << config << "\".\n";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
os << ".\n";
|
|
|
|
}
|
|
|
|
os << "#----------------------------------------------------------------\n"
|
|
|
|
<< "\n";
|
|
|
|
this->GenerateImportVersionCode(os);
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmExportFileGenerator::GenerateImportFooterCode(std::ostream& os)
|
|
|
|
{
|
|
|
|
os << "# Commands beyond this point should not need to know the version.\n"
|
|
|
|
<< "SET(CMAKE_IMPORT_FILE_VERSION)\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmExportFileGenerator::GenerateImportVersionCode(std::ostream& os)
|
|
|
|
{
|
|
|
|
// Store an import file format version. This will let us change the
|
|
|
|
// format later while still allowing old import files to work.
|
|
|
|
os << "# Commands may need to know the format version.\n"
|
|
|
|
<< "SET(CMAKE_IMPORT_FILE_VERSION 1)\n"
|
|
|
|
<< "\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
2012-11-30 12:26:09 +04:00
|
|
|
void cmExportFileGenerator::GenerateExpectedTargetsCode(std::ostream& os,
|
|
|
|
const std::string &expectedTargets)
|
|
|
|
{
|
|
|
|
os << "SET(_targetsDefined)\n"
|
|
|
|
"SET(_targetsNotDefined)\n"
|
|
|
|
"SET(_expectedTargets)\n"
|
|
|
|
"FOREACH(_expectedTarget " << expectedTargets << ")\n"
|
|
|
|
" LIST(APPEND _expectedTargets ${_expectedTarget})\n"
|
|
|
|
" IF(NOT TARGET ${_expectedTarget})\n"
|
|
|
|
" LIST(APPEND _targetsNotDefined ${_expectedTarget})\n"
|
|
|
|
" ENDIF(NOT TARGET ${_expectedTarget})\n"
|
|
|
|
" IF(TARGET ${_expectedTarget})\n"
|
|
|
|
" LIST(APPEND _targetsDefined ${_expectedTarget})\n"
|
|
|
|
" ENDIF(TARGET ${_expectedTarget})\n"
|
|
|
|
"ENDFOREACH(_expectedTarget)\n"
|
|
|
|
"IF(\"${_targetsDefined}\" STREQUAL \"${_expectedTargets}\")\n"
|
|
|
|
" SET(CMAKE_IMPORT_FILE_VERSION)\n"
|
|
|
|
" CMAKE_POLICY(POP)\n"
|
|
|
|
" RETURN()\n"
|
|
|
|
"ENDIF(\"${_targetsDefined}\" STREQUAL \"${_expectedTargets}\")\n"
|
|
|
|
"IF(NOT \"${_targetsDefined}\" STREQUAL \"\")\n"
|
|
|
|
" MESSAGE(FATAL_ERROR \"Some (but not all) targets in this export "
|
|
|
|
"set were already defined.\\nTargets Defined: ${_targetsDefined}\\n"
|
|
|
|
"Targets not yet defined: ${_targetsNotDefined}\\n\")\n"
|
|
|
|
"ENDIF(NOT \"${_targetsDefined}\" STREQUAL \"\")\n"
|
|
|
|
"UNSET(_targetsDefined)\n"
|
|
|
|
"UNSET(_targetsNotDefined)\n"
|
|
|
|
"UNSET(_expectedTargets)\n"
|
|
|
|
"\n\n";
|
|
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
2008-01-28 16:38:36 +03:00
|
|
|
void
|
|
|
|
cmExportFileGenerator
|
|
|
|
::GenerateImportTargetCode(std::ostream& os, cmTarget* target)
|
|
|
|
{
|
|
|
|
// Construct the imported target name.
|
|
|
|
std::string targetName = this->Namespace;
|
|
|
|
targetName += target->GetName();
|
|
|
|
|
|
|
|
// Create the imported target.
|
|
|
|
os << "# Create imported target " << targetName << "\n";
|
|
|
|
switch(target->GetType())
|
|
|
|
{
|
|
|
|
case cmTarget::EXECUTABLE:
|
|
|
|
os << "ADD_EXECUTABLE(" << targetName << " IMPORTED)\n";
|
|
|
|
break;
|
|
|
|
case cmTarget::STATIC_LIBRARY:
|
|
|
|
os << "ADD_LIBRARY(" << targetName << " STATIC IMPORTED)\n";
|
|
|
|
break;
|
|
|
|
case cmTarget::SHARED_LIBRARY:
|
|
|
|
os << "ADD_LIBRARY(" << targetName << " SHARED IMPORTED)\n";
|
|
|
|
break;
|
|
|
|
case cmTarget::MODULE_LIBRARY:
|
|
|
|
os << "ADD_LIBRARY(" << targetName << " MODULE IMPORTED)\n";
|
|
|
|
break;
|
|
|
|
default: // should never happen
|
|
|
|
break;
|
|
|
|
}
|
2008-01-28 21:05:58 +03:00
|
|
|
|
|
|
|
// Mark the imported executable if it has exports.
|
2008-01-28 16:38:36 +03:00
|
|
|
if(target->IsExecutableWithExports())
|
|
|
|
{
|
|
|
|
os << "SET_PROPERTY(TARGET " << targetName
|
2008-01-28 21:05:58 +03:00
|
|
|
<< " PROPERTY ENABLE_EXPORTS 1)\n";
|
|
|
|
}
|
|
|
|
|
2008-01-28 22:46:16 +03:00
|
|
|
// Mark the imported library if it is a framework.
|
|
|
|
if(target->IsFrameworkOnApple())
|
2008-01-28 21:05:58 +03:00
|
|
|
{
|
|
|
|
os << "SET_PROPERTY(TARGET " << targetName
|
|
|
|
<< " PROPERTY FRAMEWORK 1)\n";
|
2008-01-28 16:38:36 +03:00
|
|
|
}
|
2008-01-28 22:46:16 +03:00
|
|
|
|
|
|
|
// Mark the imported executable if it is an application bundle.
|
|
|
|
if(target->IsAppBundleOnApple())
|
|
|
|
{
|
|
|
|
os << "SET_PROPERTY(TARGET " << targetName
|
|
|
|
<< " PROPERTY MACOSX_BUNDLE 1)\n";
|
|
|
|
}
|
2010-10-07 06:43:04 +04:00
|
|
|
|
|
|
|
if (target->IsCFBundleOnApple())
|
|
|
|
{
|
|
|
|
os << "SET_PROPERTY(TARGET " << targetName
|
|
|
|
<< " PROPERTY BUNDLE 1)\n";
|
|
|
|
}
|
2008-01-28 16:38:36 +03:00
|
|
|
os << "\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void
|
|
|
|
cmExportFileGenerator
|
|
|
|
::GenerateImportPropertyCode(std::ostream& os, const char* config,
|
|
|
|
cmTarget* target,
|
|
|
|
ImportPropertyMap const& properties)
|
|
|
|
{
|
|
|
|
// Construct the imported target name.
|
|
|
|
std::string targetName = this->Namespace;
|
|
|
|
targetName += target->GetName();
|
|
|
|
|
|
|
|
// Set the import properties.
|
|
|
|
os << "# Import target \"" << targetName << "\" for configuration \""
|
|
|
|
<< config << "\"\n";
|
|
|
|
os << "SET_PROPERTY(TARGET " << targetName
|
|
|
|
<< " APPEND PROPERTY IMPORTED_CONFIGURATIONS ";
|
|
|
|
if(config && *config)
|
|
|
|
{
|
|
|
|
os << cmSystemTools::UpperCase(config);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
os << "NOCONFIG";
|
|
|
|
}
|
|
|
|
os << ")\n";
|
|
|
|
os << "SET_TARGET_PROPERTIES(" << targetName << " PROPERTIES\n";
|
|
|
|
for(ImportPropertyMap::const_iterator pi = properties.begin();
|
|
|
|
pi != properties.end(); ++pi)
|
|
|
|
{
|
|
|
|
os << " " << pi->first << " \"" << pi->second << "\"\n";
|
|
|
|
}
|
|
|
|
os << " )\n"
|
|
|
|
<< "\n";
|
|
|
|
}
|
2011-11-12 21:12:07 +04:00
|
|
|
|
|
|
|
|
2012-09-16 00:38:30 +04:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmExportFileGenerator::GenerateMissingTargetsCheckCode(std::ostream& os,
|
|
|
|
const std::vector<std::string>& missingTargets)
|
|
|
|
{
|
|
|
|
os << "# Make sure the targets which have been exported in some other \n"
|
|
|
|
"# export set exist.\n";
|
|
|
|
for(unsigned int i=0; i<missingTargets.size(); ++i)
|
|
|
|
{
|
|
|
|
os << "IF(NOT TARGET \"" << missingTargets[i] << "\" )\n"
|
2012-09-23 20:40:40 +04:00
|
|
|
<< " IF(CMAKE_FIND_PACKAGE_NAME)\n"
|
|
|
|
<< " SET( ${CMAKE_FIND_PACKAGE_NAME}_FOUND FALSE)\n"
|
|
|
|
<< " SET( ${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE "
|
|
|
|
<< "\"Required imported target \\\"" << missingTargets[i]
|
|
|
|
<< "\\\" not found ! \")\n"
|
|
|
|
<< " ELSE()\n"
|
|
|
|
<< " MESSAGE(FATAL_ERROR \"Required imported target \\\""
|
2012-09-16 00:38:30 +04:00
|
|
|
<< missingTargets[i] << "\\\" not found ! \")\n"
|
2012-09-23 20:40:40 +04:00
|
|
|
<< " ENDIF()\n"
|
2012-09-16 00:38:30 +04:00
|
|
|
<< "ENDIF()\n";
|
|
|
|
}
|
|
|
|
os << "\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-11-12 21:12:07 +04:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void
|
|
|
|
cmExportFileGenerator::GenerateImportedFileCheckLoop(std::ostream& os)
|
|
|
|
{
|
|
|
|
// Add code which verifies at cmake time that the file which is being
|
|
|
|
// imported actually exists on disk. This should in theory always be theory
|
|
|
|
// case, but still when packages are split into normal and development
|
|
|
|
// packages this might get broken (e.g. the Config.cmake could be part of
|
|
|
|
// the non-development package, something similar happened to me without
|
|
|
|
// on SUSE with a mysql pkg-config file, which claimed everything is fine,
|
|
|
|
// but the development package was not installed.).
|
|
|
|
os << "# Loop over all imported files and verify that they actually exist\n"
|
|
|
|
"FOREACH(target ${_IMPORT_CHECK_TARGETS} )\n"
|
|
|
|
" FOREACH(file ${_IMPORT_CHECK_FILES_FOR_${target}} )\n"
|
|
|
|
" IF(NOT EXISTS \"${file}\" )\n"
|
2011-11-18 01:39:24 +04:00
|
|
|
" MESSAGE(FATAL_ERROR \"The imported target \\\"${target}\\\""
|
|
|
|
" references the file\n"
|
|
|
|
" \\\"${file}\\\"\n"
|
|
|
|
"but this file does not exist. Possible reasons include:\n"
|
|
|
|
"* The file was deleted, renamed, or moved to another location.\n"
|
|
|
|
"* An install or uninstall procedure did not complete successfully.\n"
|
|
|
|
"* The installation package was faulty and contained\n"
|
|
|
|
" \\\"${CMAKE_CURRENT_LIST_FILE}\\\"\n"
|
|
|
|
"but not all the files it references.\n"
|
|
|
|
"\")\n"
|
2011-11-12 21:12:07 +04:00
|
|
|
" ENDIF()\n"
|
|
|
|
" ENDFOREACH()\n"
|
|
|
|
" UNSET(_IMPORT_CHECK_FILES_FOR_${target})\n"
|
|
|
|
"ENDFOREACH()\n"
|
|
|
|
"UNSET(_IMPORT_CHECK_TARGETS)\n"
|
|
|
|
"\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void
|
|
|
|
cmExportFileGenerator
|
|
|
|
::GenerateImportedFileChecksCode(std::ostream& os, cmTarget* target,
|
|
|
|
ImportPropertyMap const& properties,
|
|
|
|
const std::set<std::string>& importedLocations)
|
|
|
|
{
|
|
|
|
// Construct the imported target name.
|
|
|
|
std::string targetName = this->Namespace;
|
|
|
|
targetName += target->GetName();
|
|
|
|
|
|
|
|
os << "LIST(APPEND _IMPORT_CHECK_TARGETS " << targetName << " )\n"
|
|
|
|
"LIST(APPEND _IMPORT_CHECK_FILES_FOR_" << targetName << " ";
|
|
|
|
|
|
|
|
for(std::set<std::string>::const_iterator li = importedLocations.begin();
|
|
|
|
li != importedLocations.end();
|
|
|
|
++li)
|
|
|
|
{
|
|
|
|
ImportPropertyMap::const_iterator pi = properties.find(*li);
|
|
|
|
if (pi != properties.end())
|
|
|
|
{
|
|
|
|
os << "\"" << pi->second << "\" ";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
os << ")\n\n";
|
|
|
|
}
|