~ubuntu-branches/ubuntu/utopic/cmake/utopic

« back to all changes in this revision

Viewing changes to Source/cmExportFileGenerator.cxx

  • Committer: Package Import Robot
  • Author(s): Harald Sitter
  • Date: 2013-10-10 12:54:39 UTC
  • mfrom: (1.14.7)
  • Revision ID: package-import@ubuntu.com-20131010125439-h0ahaj004on6oj92
Tags: 2.8.12-0ubuntu1
New upstream release LP: #1246701

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
cmExportFileGenerator::cmExportFileGenerator()
31
31
{
32
32
  this->AppendMode = false;
 
33
  this->ExportOld = false;
33
34
}
34
35
 
35
36
//----------------------------------------------------------------------------
168
169
    }
169
170
}
170
171
 
 
172
void cmExportFileGenerator::GenerateRequiredCMakeVersion(std::ostream& os,
 
173
                                                    const char *versionString)
 
174
{
 
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"
 
178
        "endif()\n\n";
 
179
}
 
180
 
 
181
//----------------------------------------------------------------------------
 
182
bool cmExportFileGenerator::PopulateInterfaceLinkLibrariesProperty(
 
183
                      cmTarget *target,
 
184
                      cmGeneratorExpression::PreprocessContext preprocessRule,
 
185
                      ImportPropertyMap &properties,
 
186
                      std::vector<std::string> &missingTargets)
 
187
{
 
188
  const char *input = target->GetProperty("INTERFACE_LINK_LIBRARIES");
 
189
  if (input)
 
190
    {
 
191
    std::string prepro = cmGeneratorExpression::Preprocess(input,
 
192
                                                           preprocessRule);
 
193
    if (!prepro.empty())
 
194
      {
 
195
      this->ResolveTargetsInGeneratorExpressions(prepro, target,
 
196
                                                 missingTargets,
 
197
                                                 ReplaceFreeTargets);
 
198
      properties["INTERFACE_LINK_LIBRARIES"] = prepro;
 
199
      return true;
 
200
      }
 
201
    }
 
202
  return false;
 
203
}
 
204
 
171
205
//----------------------------------------------------------------------------
172
206
static bool isSubDirectory(const char* a, const char* b)
173
207
{
243
277
 
244
278
//----------------------------------------------------------------------------
245
279
void cmExportFileGenerator::PopulateIncludeDirectoriesInterface(
246
 
                      cmTarget *target,
 
280
                      cmTargetExport *tei,
247
281
                      cmGeneratorExpression::PreprocessContext preprocessRule,
248
282
                      ImportPropertyMap &properties,
249
283
                      std::vector<std::string> &missingTargets)
250
284
{
 
285
  cmTarget *target = tei->Target;
251
286
  assert(preprocessRule == cmGeneratorExpression::InstallInterface);
252
287
 
253
288
  const char *propName = "INTERFACE_INCLUDE_DIRECTORIES";
254
289
  const char *input = target->GetProperty(propName);
255
 
  if (!input)
256
 
    {
257
 
    return;
258
 
    }
259
 
  if (!*input)
 
290
 
 
291
  cmListFileBacktrace lfbt;
 
292
  cmGeneratorExpression ge(lfbt);
 
293
 
 
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,
 
298
                                         false, target);
 
299
 
 
300
  if (cge->GetHadContextSensitiveCondition())
 
301
    {
 
302
    cmMakefile* mf = target->GetMakefile();
 
303
    cmOStringStream e;
 
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());
 
309
    return;
 
310
    }
 
311
 
 
312
  if (!input && exportDirs.empty())
 
313
    {
 
314
    return;
 
315
    }
 
316
  if ((input && !*input) && exportDirs.empty())
260
317
    {
261
318
    // Set to empty
262
319
    properties[propName] = "";
263
320
    return;
264
321
    }
265
322
 
266
 
  std::string prepro = cmGeneratorExpression::Preprocess(input,
267
 
                                                          preprocessRule);
 
323
  std::string includes = (input?input:"");
 
324
  const char* sep = input ? ";" : "";
 
325
  includes += sep + exportDirs;
 
326
  std::string prepro = cmGeneratorExpression::Preprocess(includes,
 
327
                                                         preprocessRule,
 
328
                                                         true);
268
329
  if (!prepro.empty())
269
330
    {
270
331
    this->ResolveTargetsInGeneratorExpressions(prepro, target,
315
376
{
316
377
  cmComputeLinkInformation *info = target->GetLinkInformation(config);
317
378
 
 
379
  if (!info)
 
380
    {
 
381
    cmMakefile* mf = target->GetMakefile();
 
382
    cmOStringStream e;
 
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());
 
386
    return;
 
387
    }
 
388
 
318
389
  const cmComputeLinkInformation::ItemVector &deps = info->GetItems();
319
390
 
320
391
  for(cmComputeLinkInformation::ItemVector::const_iterator li =
376
447
  if (!properties.empty())
377
448
    {
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)
407
478
    }
408
479
  if(this->ExportedTargets.find(tgt) != this->ExportedTargets.end())
409
480
    {
410
 
    input = this->Namespace + input;
 
481
    input = this->Namespace + tgt->GetExportName();
411
482
    }
412
483
  else
413
484
    {
583
654
    return;
584
655
    }
585
656
 
 
657
  const bool newCMP0022Behavior =
 
658
                        target->GetPolicyStatusCMP0022() != cmPolicies::WARN
 
659
                     && target->GetPolicyStatusCMP0022() != cmPolicies::OLD;
 
660
 
 
661
  if(newCMP0022Behavior && !this->ExportOld)
 
662
    {
 
663
    cmMakefile *mf = target->GetMakefile();
 
664
    cmOStringStream e;
 
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());
 
670
    return;
 
671
    }
 
672
 
586
673
  if (!*propContent)
587
674
    {
588
675
    properties["IMPORTED_LINK_INTERFACE_LIBRARIES" + suffix] = "";
624
711
      std::string value;
625
712
      if(target->HasSOName(config))
626
713
        {
 
714
        if(mf->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME"))
 
715
          {
 
716
          value = this->InstallNameDir(target, config);
 
717
          }
627
718
        prop = "IMPORTED_SONAME";
628
 
        value = target->GetSOName(config);
 
719
        value += target->GetSOName(config);
629
720
        }
630
721
      else
631
722
        {
738
829
void cmExportFileGenerator::GenerateExpectedTargetsCode(std::ostream& os,
739
830
                                            const std::string &expectedTargets)
740
831
{
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"
772
865
{
773
866
  // Construct the imported target name.
774
867
  std::string targetName = this->Namespace;
775
 
  targetName += target->GetName();
 
868
 
 
869
  targetName += target->GetExportName();
776
870
 
777
871
  // Create the imported target.
778
872
  os << "# Create imported target " << targetName << "\n";
835
929
{
836
930
  // Construct the imported target name.
837
931
  std::string targetName = this->Namespace;
838
 
  targetName += target->GetName();
 
932
 
 
933
  targetName += target->GetExportName();
839
934
 
840
935
  // Set the import properties.
841
936
  os << "# Import target \"" << targetName << "\" for configuration \""
954
1049
{
955
1050
  // Construct the imported target name.
956
1051
  std::string targetName = this->Namespace;
957
 
  targetName += target->GetName();
 
1052
  targetName += target->GetExportName();
958
1053
 
959
1054
  os << "list(APPEND _IMPORT_CHECK_TARGETS " << targetName << " )\n"
960
1055
        "list(APPEND _IMPORT_CHECK_FILES_FOR_" << targetName << " ";