172
void cmExportFileGenerator::GenerateRequiredCMakeVersion(std::ostream& os,
173
const char *versionString)
175
os << "if(CMAKE_VERSION VERSION_LESS " << versionString << ")\n"
176
" message(FATAL_ERROR \"This file relies on consumers using "
177
"CMake " << versionString << " or greater.\")\n"
181
//----------------------------------------------------------------------------
182
bool cmExportFileGenerator::PopulateInterfaceLinkLibrariesProperty(
184
cmGeneratorExpression::PreprocessContext preprocessRule,
185
ImportPropertyMap &properties,
186
std::vector<std::string> &missingTargets)
188
const char *input = target->GetProperty("INTERFACE_LINK_LIBRARIES");
191
std::string prepro = cmGeneratorExpression::Preprocess(input,
195
this->ResolveTargetsInGeneratorExpressions(prepro, target,
198
properties["INTERFACE_LINK_LIBRARIES"] = prepro;
171
205
//----------------------------------------------------------------------------
172
206
static bool isSubDirectory(const char* a, const char* b)
244
278
//----------------------------------------------------------------------------
245
279
void cmExportFileGenerator::PopulateIncludeDirectoriesInterface(
247
281
cmGeneratorExpression::PreprocessContext preprocessRule,
248
282
ImportPropertyMap &properties,
249
283
std::vector<std::string> &missingTargets)
285
cmTarget *target = tei->Target;
251
286
assert(preprocessRule == cmGeneratorExpression::InstallInterface);
253
288
const char *propName = "INTERFACE_INCLUDE_DIRECTORIES";
254
289
const char *input = target->GetProperty(propName);
291
cmListFileBacktrace lfbt;
292
cmGeneratorExpression ge(lfbt);
294
std::string dirs = tei->InterfaceIncludeDirectories;
295
this->ReplaceInstallPrefix(dirs);
296
cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(dirs);
297
std::string exportDirs = cge->Evaluate(target->GetMakefile(), 0,
300
if (cge->GetHadContextSensitiveCondition())
302
cmMakefile* mf = target->GetMakefile();
304
e << "Target \"" << target->GetName() << "\" is installed with "
305
"INCLUDES DESTINATION set to a context sensitive path. Paths which "
306
"depend on the configuration, policy values or the link interface are "
307
"not supported. Consider using target_include_directories instead.";
308
mf->IssueMessage(cmake::FATAL_ERROR, e.str());
312
if (!input && exportDirs.empty())
316
if ((input && !*input) && exportDirs.empty())
262
319
properties[propName] = "";
266
std::string prepro = cmGeneratorExpression::Preprocess(input,
323
std::string includes = (input?input:"");
324
const char* sep = input ? ";" : "";
325
includes += sep + exportDirs;
326
std::string prepro = cmGeneratorExpression::Preprocess(includes,
268
329
if (!prepro.empty())
270
331
this->ResolveTargetsInGeneratorExpressions(prepro, target,
316
377
cmComputeLinkInformation *info = target->GetLinkInformation(config);
381
cmMakefile* mf = target->GetMakefile();
383
e << "Exporting the target \"" << target->GetName() << "\" is not "
384
"allowed since its linker language cannot be determined";
385
mf->IssueMessage(cmake::FATAL_ERROR, e.str());
318
389
const cmComputeLinkInformation::ItemVector &deps = info->GetItems();
320
391
for(cmComputeLinkInformation::ItemVector::const_iterator li =
376
447
if (!properties.empty())
378
449
std::string targetName = this->Namespace;
379
targetName += target->GetName();
450
targetName += target->GetExportName();
380
451
os << "set_target_properties(" << targetName << " PROPERTIES\n";
381
452
for(ImportPropertyMap::const_iterator pi = properties.begin();
382
453
pi != properties.end(); ++pi)
657
const bool newCMP0022Behavior =
658
target->GetPolicyStatusCMP0022() != cmPolicies::WARN
659
&& target->GetPolicyStatusCMP0022() != cmPolicies::OLD;
661
if(newCMP0022Behavior && !this->ExportOld)
663
cmMakefile *mf = target->GetMakefile();
665
e << "Target \"" << target->GetName() << "\" has policy CMP0022 enabled, "
666
"but also has old-style LINK_INTERFACE_LIBRARIES properties "
667
"populated, but it was exported without the "
668
"EXPORT_LINK_INTERFACE_LIBRARIES to export the old-style properties";
669
mf->IssueMessage(cmake::FATAL_ERROR, e.str());
586
673
if (!*propContent)
588
675
properties["IMPORTED_LINK_INTERFACE_LIBRARIES" + suffix] = "";
624
711
std::string value;
625
712
if(target->HasSOName(config))
714
if(mf->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME"))
716
value = this->InstallNameDir(target, config);
627
718
prop = "IMPORTED_SONAME";
628
value = target->GetSOName(config);
719
value += target->GetSOName(config);
738
829
void cmExportFileGenerator::GenerateExpectedTargetsCode(std::ostream& os,
739
830
const std::string &expectedTargets)
741
os << "set(_targetsDefined)\n"
832
os << "# Protect against multiple inclusion, which would fail when already "
833
"imported targets are added once more.\n"
834
"set(_targetsDefined)\n"
742
835
"set(_targetsNotDefined)\n"
743
836
"set(_expectedTargets)\n"
744
837
"foreach(_expectedTarget " << expectedTargets << ")\n"
773
866
// Construct the imported target name.
774
867
std::string targetName = this->Namespace;
775
targetName += target->GetName();
869
targetName += target->GetExportName();
777
871
// Create the imported target.
778
872
os << "# Create imported target " << targetName << "\n";
836
930
// Construct the imported target name.
837
931
std::string targetName = this->Namespace;
838
targetName += target->GetName();
933
targetName += target->GetExportName();
840
935
// Set the import properties.
841
936
os << "# Import target \"" << targetName << "\" for configuration \""
955
1050
// Construct the imported target name.
956
1051
std::string targetName = this->Namespace;
957
targetName += target->GetName();
1052
targetName += target->GetExportName();
959
1054
os << "list(APPEND _IMPORT_CHECK_TARGETS " << targetName << " )\n"
960
1055
"list(APPEND _IMPORT_CHECK_FILES_FOR_" << targetName << " ";