1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmExportBuildFileGenerator.cxx,v $
6 Date: $Date: 2009-01-20 20:49:37 $
7 Version: $Revision: 1.7 $
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
)
36 if(this->ExportedTargets
.insert(te
).second
)
38 this->GenerateImportTargetCode(os
, te
);
42 if(this->ExportCommand
&& this->ExportCommand
->ErrorMessage
.empty())
45 e
<< "given target \"" << te
->GetName() << "\" more than once.";
46 this->ExportCommand
->ErrorMessage
= e
.str();
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());
63 //----------------------------------------------------------------------------
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
,
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,
89 // Generate code in the export file.
90 this->GenerateImportPropertyCode(os
, config
, target
, properties
);
95 //----------------------------------------------------------------------------
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";
109 if(target
->IsFrameworkOnApple() || target
->IsAppBundleOnApple())
111 value
= target
->GetFullPath(config
, false);
115 value
= target
->GetFullPath(config
, false, true);
117 properties
[prop
] = value
;
120 // Check whether this is a DLL platform.
122 (mf
->IsOn("WIN32") || mf
->IsOn("CYGWIN") || mf
->IsOn("MINGW"));
124 // Add the import library for windows DLLs.
126 (target
->GetType() == cmTarget::SHARED_LIBRARY
||
127 target
->IsExecutableWithExports()) &&
128 mf
->GetDefinition("CMAKE_IMPORT_LIBRARY_SUFFIX"))
130 std::string prop
= "IMPORTED_IMPLIB";
132 std::string value
= target
->GetFullPath(config
, true);
133 properties
[prop
] = value
;
137 //----------------------------------------------------------------------------
139 cmExportBuildFileGenerator
140 ::ComplainAboutMissingTarget(cmTarget
* depender
,
143 if(!this->ExportCommand
|| !this->ExportCommand
->ErrorMessage
.empty())
149 e
<< "called with target \"" << depender
->GetName()
150 << "\" which requires target \"" << dependee
->GetName()
151 << "\" that is not in the export list.\n"
152 << "If the required target is not easy to reference in this call, "
153 << "consider using the APPEND option with multiple separate calls.";
154 this->ExportCommand
->ErrorMessage
= e
.str();