cmExportBuildFileGenerator.cxx 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. /*=========================================================================
  2. Program: CMake - Cross-Platform Makefile Generator
  3. Module: $RCSfile$
  4. Language: C++
  5. Date: $Date$
  6. Version: $Revision$
  7. Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
  8. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
  9. This software is distributed WITHOUT ANY WARRANTY; without even
  10. the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  11. PURPOSE. See the above copyright notices for more information.
  12. =========================================================================*/
  13. #include "cmExportBuildFileGenerator.h"
  14. //----------------------------------------------------------------------------
  15. bool cmExportBuildFileGenerator::GenerateMainFile(std::ostream& os)
  16. {
  17. // Create all the imported targets.
  18. for(std::vector<cmTarget*>::const_iterator
  19. tei = this->Exports->begin();
  20. tei != this->Exports->end(); ++tei)
  21. {
  22. cmTarget* te = *tei;
  23. this->ExportedTargets.insert(te);
  24. this->GenerateImportTargetCode(os, te);
  25. }
  26. // Generate import file content for each configuration.
  27. for(std::vector<std::string>::const_iterator
  28. ci = this->Configurations.begin();
  29. ci != this->Configurations.end(); ++ci)
  30. {
  31. this->GenerateImportConfig(os, ci->c_str());
  32. }
  33. return true;
  34. }
  35. //----------------------------------------------------------------------------
  36. void
  37. cmExportBuildFileGenerator
  38. ::GenerateImportTargetsConfig(std::ostream& os,
  39. const char* config, std::string const& suffix)
  40. {
  41. for(std::vector<cmTarget*>::const_iterator
  42. tei = this->Exports->begin();
  43. tei != this->Exports->end(); ++tei)
  44. {
  45. // Collect import properties for this target.
  46. cmTarget* target = *tei;
  47. ImportPropertyMap properties;
  48. this->SetImportLocationProperty(config, suffix, target, properties);
  49. if(!properties.empty())
  50. {
  51. // Get the rest of the target details.
  52. this->SetImportDetailProperties(config, suffix,
  53. target, properties);
  54. // TOOD: PUBLIC_HEADER_LOCATION
  55. // This should wait until the build feature propagation stuff
  56. // is done. Then this can be a propagated include directory.
  57. // this->GenerateImportProperty(config, te->HeaderGenerator,
  58. // properties);
  59. // Generate code in the export file.
  60. this->GenerateImportPropertyCode(os, config, target, properties);
  61. }
  62. }
  63. }
  64. //----------------------------------------------------------------------------
  65. void
  66. cmExportBuildFileGenerator
  67. ::SetImportLocationProperty(const char* config, std::string const& suffix,
  68. cmTarget* target, ImportPropertyMap& properties)
  69. {
  70. // Get the makefile in which to lookup target information.
  71. cmMakefile* mf = target->GetMakefile();
  72. // Add the main target file.
  73. {
  74. std::string prop = "IMPORTED_LOCATION";
  75. prop += suffix;
  76. std::string value = target->GetFullPath(config, false);
  77. if(target->IsAppBundleOnApple())
  78. {
  79. value += ".app/Contents/MacOS/";
  80. value += target->GetFullName(config, false);
  81. }
  82. properties[prop] = value;
  83. }
  84. // Check whether this is a DLL platform.
  85. bool dll_platform =
  86. (mf->IsOn("WIN32") || mf->IsOn("CYGWIN") || mf->IsOn("MINGW"));
  87. // Add the import library for windows DLLs.
  88. if(dll_platform &&
  89. (target->GetType() == cmTarget::SHARED_LIBRARY ||
  90. target->IsExecutableWithExports()) &&
  91. mf->GetDefinition("CMAKE_IMPORT_LIBRARY_SUFFIX"))
  92. {
  93. std::string prop = "IMPORTED_IMPLIB";
  94. prop += suffix;
  95. std::string value = target->GetFullPath(config, true);
  96. properties[prop] = value;
  97. }
  98. }
  99. //----------------------------------------------------------------------------
  100. void
  101. cmExportBuildFileGenerator
  102. ::ComplainAboutMissingTarget(cmTarget* target, const char* dep)
  103. {
  104. cmOStringStream e;
  105. e << "WARNING: EXPORT(...) includes target " << target->GetName()
  106. << " which links to target \"" << dep
  107. << "\" that is not in the export set.";
  108. cmSystemTools::Message(e.str().c_str());
  109. }