1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmExportBuildFileGenerator.cxx,v $
6 <<<<<<< cmExportBuildFileGenerator.cxx
7 Date: $Date: 2008/02/06 19:20:35 $
8 Version: $Revision: 1.6 $
10 Date: $Date: 2009-01-20 20:49:37 $
11 Version: $Revision: 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
)
41 if(this->ExportedTargets
.insert(te
).second
)
43 this->GenerateImportTargetCode(os
, te
);
47 if(this->ExportCommand
&& this->ExportCommand
->ErrorMessage
.empty())
50 e
<< "given target \"" << te
->GetName() << "\" more than once.";
51 this->ExportCommand
->ErrorMessage
= e
.str();
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());
68 //----------------------------------------------------------------------------
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
,
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,
94 // Generate code in the export file.
95 this->GenerateImportPropertyCode(os
, config
, target
, properties
);
100 //----------------------------------------------------------------------------
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";
114 if(target
->IsFrameworkOnApple() || target
->IsAppBundleOnApple())
116 value
= target
->GetFullPath(config
, false);
120 value
= target
->GetFullPath(config
, false, true);
122 properties
[prop
] = value
;
125 // Check whether this is a DLL platform.
127 (mf
->IsOn("WIN32") || mf
->IsOn("CYGWIN") || mf
->IsOn("MINGW"));
129 // Add the import library for windows DLLs.
131 (target
->GetType() == cmTarget::SHARED_LIBRARY
||
132 target
->IsExecutableWithExports()) &&
133 mf
->GetDefinition("CMAKE_IMPORT_LIBRARY_SUFFIX"))
135 std::string prop
= "IMPORTED_IMPLIB";
137 std::string value
= target
->GetFullPath(config
, true);
138 properties
[prop
] = value
;
142 //----------------------------------------------------------------------------
144 cmExportBuildFileGenerator
145 ::ComplainAboutMissingTarget(cmTarget
* depender
,
148 if(!this->ExportCommand
|| !this->ExportCommand
->ErrorMessage
.empty())
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();