STYLE: Fix line-too-long
[cmake.git] / Source / cmExportBuildFileGenerator.cxx
blobbeb452cadaea8ca9599232ee3af537ef5818e3f6
1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmExportBuildFileGenerator.cxx,v $
5 Language: C++
6 Date: $Date: 2008-02-06 19:20:35 $
7 Version: $Revision: 1.6 $
9 Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
10 See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
12 This software is distributed WITHOUT ANY WARRANTY; without even
13 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 PURPOSE. See the above copyright notices for more information.
16 =========================================================================*/
17 #include "cmExportBuildFileGenerator.h"
19 #include "cmExportCommand.h"
21 //----------------------------------------------------------------------------
22 cmExportBuildFileGenerator::cmExportBuildFileGenerator()
24 this->ExportCommand = 0;
27 //----------------------------------------------------------------------------
28 bool cmExportBuildFileGenerator::GenerateMainFile(std::ostream& os)
30 // Create all the imported targets.
31 for(std::vector<cmTarget*>::const_iterator
32 tei = this->Exports->begin();
33 tei != this->Exports->end(); ++tei)
35 cmTarget* te = *tei;
36 if(this->ExportedTargets.insert(te).second)
38 this->GenerateImportTargetCode(os, te);
40 else
42 if(this->ExportCommand && this->ExportCommand->ErrorMessage.empty())
44 cmOStringStream e;
45 e << "given target \"" << te->GetName() << "\" more than once.";
46 this->ExportCommand->ErrorMessage = e.str();
48 return false;
52 // Generate import file content for each configuration.
53 for(std::vector<std::string>::const_iterator
54 ci = this->Configurations.begin();
55 ci != this->Configurations.end(); ++ci)
57 this->GenerateImportConfig(os, ci->c_str());
60 return true;
63 //----------------------------------------------------------------------------
64 void
65 cmExportBuildFileGenerator
66 ::GenerateImportTargetsConfig(std::ostream& os,
67 const char* config, std::string const& suffix)
69 for(std::vector<cmTarget*>::const_iterator
70 tei = this->Exports->begin();
71 tei != this->Exports->end(); ++tei)
73 // Collect import properties for this target.
74 cmTarget* target = *tei;
75 ImportPropertyMap properties;
76 this->SetImportLocationProperty(config, suffix, target, properties);
77 if(!properties.empty())
79 // Get the rest of the target details.
80 this->SetImportDetailProperties(config, suffix,
81 target, properties);
83 // TOOD: PUBLIC_HEADER_LOCATION
84 // This should wait until the build feature propagation stuff
85 // is done. Then this can be a propagated include directory.
86 // this->GenerateImportProperty(config, te->HeaderGenerator,
87 // properties);
89 // Generate code in the export file.
90 this->GenerateImportPropertyCode(os, config, target, properties);
95 //----------------------------------------------------------------------------
96 void
97 cmExportBuildFileGenerator
98 ::SetImportLocationProperty(const char* config, std::string const& suffix,
99 cmTarget* target, ImportPropertyMap& properties)
101 // Get the makefile in which to lookup target information.
102 cmMakefile* mf = target->GetMakefile();
104 // Add the main target file.
106 std::string prop = "IMPORTED_LOCATION";
107 prop += suffix;
108 std::string value;
109 if(target->IsFrameworkOnApple())
111 value = target->GetFullPath(config, false);
113 else if(target->IsAppBundleOnApple())
115 value = target->GetFullPath(config, false);
116 value += ".app/Contents/MacOS/";
117 value += target->GetFullName(config, false);
119 else
121 value = target->GetFullPath(config, false, true);
123 properties[prop] = value;
126 // Check whether this is a DLL platform.
127 bool dll_platform =
128 (mf->IsOn("WIN32") || mf->IsOn("CYGWIN") || mf->IsOn("MINGW"));
130 // Add the import library for windows DLLs.
131 if(dll_platform &&
132 (target->GetType() == cmTarget::SHARED_LIBRARY ||
133 target->IsExecutableWithExports()) &&
134 mf->GetDefinition("CMAKE_IMPORT_LIBRARY_SUFFIX"))
136 std::string prop = "IMPORTED_IMPLIB";
137 prop += suffix;
138 std::string value = target->GetFullPath(config, true);
139 properties[prop] = value;
143 //----------------------------------------------------------------------------
144 void
145 cmExportBuildFileGenerator
146 ::ComplainAboutMissingTarget(cmTarget* depender,
147 cmTarget* dependee)
149 if(!this->ExportCommand || !this->ExportCommand->ErrorMessage.empty())
151 return;
154 cmOStringStream e;
155 e << "called with target \"" << depender->GetName()
156 << "\" which requires target \"" << dependee->GetName()
157 << "\" that is not in the export list.\n"
158 << "If the required target is not easy to reference in this call, "
159 << "consider using the APPEND option with multiple separate calls.";
160 this->ExportCommand->ErrorMessage = e.str();