Resync
[CMakeLuaTailorHgBridge.git] / CMakeLua / Source / cmExportBuildFileGenerator.cxx
blobf6b3b2de61735e3f9ed92c16aca04f0b52c752e9
1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmExportBuildFileGenerator.cxx,v $
5 Language: C++
6 <<<<<<< cmExportBuildFileGenerator.cxx
7 Date: $Date: 2008/02/06 19:20:35 $
8 Version: $Revision: 1.6 $
9 =======
10 Date: $Date: 2009-01-20 20:49:37 $
11 Version: $Revision: 1.7 $
12 >>>>>>> 1.7
14 Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
15 See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
17 This software is distributed WITHOUT ANY WARRANTY; without even
18 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
19 PURPOSE. See the above copyright notices for more information.
21 =========================================================================*/
22 #include "cmExportBuildFileGenerator.h"
24 #include "cmExportCommand.h"
26 //----------------------------------------------------------------------------
27 cmExportBuildFileGenerator::cmExportBuildFileGenerator()
29 this->ExportCommand = 0;
32 //----------------------------------------------------------------------------
33 bool cmExportBuildFileGenerator::GenerateMainFile(std::ostream& os)
35 // Create all the imported targets.
36 for(std::vector<cmTarget*>::const_iterator
37 tei = this->Exports->begin();
38 tei != this->Exports->end(); ++tei)
40 cmTarget* te = *tei;
41 if(this->ExportedTargets.insert(te).second)
43 this->GenerateImportTargetCode(os, te);
45 else
47 if(this->ExportCommand && this->ExportCommand->ErrorMessage.empty())
49 cmOStringStream e;
50 e << "given target \"" << te->GetName() << "\" more than once.";
51 this->ExportCommand->ErrorMessage = e.str();
53 return false;
57 // Generate import file content for each configuration.
58 for(std::vector<std::string>::const_iterator
59 ci = this->Configurations.begin();
60 ci != this->Configurations.end(); ++ci)
62 this->GenerateImportConfig(os, ci->c_str());
65 return true;
68 //----------------------------------------------------------------------------
69 void
70 cmExportBuildFileGenerator
71 ::GenerateImportTargetsConfig(std::ostream& os,
72 const char* config, std::string const& suffix)
74 for(std::vector<cmTarget*>::const_iterator
75 tei = this->Exports->begin();
76 tei != this->Exports->end(); ++tei)
78 // Collect import properties for this target.
79 cmTarget* target = *tei;
80 ImportPropertyMap properties;
81 this->SetImportLocationProperty(config, suffix, target, properties);
82 if(!properties.empty())
84 // Get the rest of the target details.
85 this->SetImportDetailProperties(config, suffix,
86 target, properties);
88 // TOOD: PUBLIC_HEADER_LOCATION
89 // This should wait until the build feature propagation stuff
90 // is done. Then this can be a propagated include directory.
91 // this->GenerateImportProperty(config, te->HeaderGenerator,
92 // properties);
94 // Generate code in the export file.
95 this->GenerateImportPropertyCode(os, config, target, properties);
100 //----------------------------------------------------------------------------
101 void
102 cmExportBuildFileGenerator
103 ::SetImportLocationProperty(const char* config, std::string const& suffix,
104 cmTarget* target, ImportPropertyMap& properties)
106 // Get the makefile in which to lookup target information.
107 cmMakefile* mf = target->GetMakefile();
109 // Add the main target file.
111 std::string prop = "IMPORTED_LOCATION";
112 prop += suffix;
113 std::string value;
114 if(target->IsFrameworkOnApple() || target->IsAppBundleOnApple())
116 value = target->GetFullPath(config, false);
118 else
120 value = target->GetFullPath(config, false, true);
122 properties[prop] = value;
125 // Check whether this is a DLL platform.
126 bool dll_platform =
127 (mf->IsOn("WIN32") || mf->IsOn("CYGWIN") || mf->IsOn("MINGW"));
129 // Add the import library for windows DLLs.
130 if(dll_platform &&
131 (target->GetType() == cmTarget::SHARED_LIBRARY ||
132 target->IsExecutableWithExports()) &&
133 mf->GetDefinition("CMAKE_IMPORT_LIBRARY_SUFFIX"))
135 std::string prop = "IMPORTED_IMPLIB";
136 prop += suffix;
137 std::string value = target->GetFullPath(config, true);
138 properties[prop] = value;
142 //----------------------------------------------------------------------------
143 void
144 cmExportBuildFileGenerator
145 ::ComplainAboutMissingTarget(cmTarget* depender,
146 cmTarget* dependee)
148 if(!this->ExportCommand || !this->ExportCommand->ErrorMessage.empty())
150 return;
153 cmOStringStream e;
154 e << "called with target \"" << depender->GetName()
155 << "\" which requires target \"" << dependee->GetName()
156 << "\" that is not in the export list.\n"
157 << "If the required target is not easy to reference in this call, "
158 << "consider using the APPEND option with multiple separate calls.";
159 this->ExportCommand->ErrorMessage = e.str();