1
/*=========================================================================
3
Program: Insight Segmentation & Registration Toolkit
4
Module: $RCSfile: cmQTWrapUICommand.cxx,v $
6
Date: $Date: 2001/11/21 13:46:59 $
7
Version: $Revision: 1.3 $
8
Author: Franck Bettinger.
10
Copyright (c) 2001 Insight Consortium
13
Redistribution and use in source and binary forms, with or without
14
modification, are permitted provided that the following conditions are met:
16
* Redistributions of source code must retain the above copyright notice,
17
this list of conditions and the following disclaimer.
19
* Redistributions in binary form must reproduce the above copyright notice,
20
this list of conditions and the following disclaimer in the documentation
21
and/or other materials provided with the distribution.
23
* The name of the Insight Consortium, nor the names of any consortium members,
24
nor of any contributors, may be used to endorse or promote products derived
25
from this software without specific prior written permission.
27
* Modified source versions must be plainly marked as such, and must not be
28
misrepresented as being the original software.
30
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS ``AS IS''
31
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
32
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
33
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
34
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
35
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
36
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
37
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
38
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
39
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
41
=========================================================================*/
42
#include "cmQTWrapUICommand.h"
45
bool cmQTWrapUICommand::InitialPass(std::vector<std::string> const& args)
49
this->SetError("called with incorrect number of arguments");
53
// Now check and see if the value has been stored in the cache
54
// already, if so use that value and don't look for the program
55
const char* QT_WRAP_UI_value = m_Makefile->GetDefinition("QT_WRAP_UI");
56
if (QT_WRAP_UI_value==0)
58
this->SetError("called with QT_WRAP_UI undefined");
62
if(cmSystemTools::IsOff(QT_WRAP_UI_value))
64
this->SetError("called with QT_WRAP_UI off : ");
68
// what is the current source dir
69
std::string cdir = m_Makefile->GetCurrentDirectory();
71
// keep the library name
72
m_LibraryName = args[0];
73
m_HeaderList = args[1];
74
m_SourceList = args[2];
76
// get the list of classes for this library
77
cmMakefile::SourceMap &Classes = m_Makefile->GetSources();
80
for(std::vector<std::string>::const_iterator j = (args.begin() + 3);
83
cmMakefile::SourceMap::iterator l = Classes.find(*j);
84
if (l == Classes.end())
86
this->SetError("bad source list passed to QTWrapUICommand");
89
for(std::vector<cmSourceFile>::iterator i = l->second.begin();
90
i != l->second.end(); i++)
92
cmSourceFile &curr = *i;
93
// if we should wrap the class
94
if (!curr.GetWrapExclude())
96
cmSourceFile header_file;
97
cmSourceFile source_file;
98
cmSourceFile moc_file;
99
header_file.SetName(curr.GetSourceName().c_str(),
100
m_Makefile->GetCurrentOutputDirectory(),
102
source_file.SetName(curr.GetSourceName().c_str(),
103
m_Makefile->GetCurrentOutputDirectory(),
105
std::string moc_source_name("moc_");
106
moc_source_name = moc_source_name + curr.GetSourceName().c_str();
107
moc_file.SetName(moc_source_name.c_str(),
108
m_Makefile->GetCurrentOutputDirectory(),
110
std::string origname = cdir + "/" + curr.GetSourceName() + "." +
111
curr.GetSourceExtension();
112
std::string hname = header_file.GetFullPath();
113
m_WrapUserInterface.push_back(origname);
114
// add starting depends
115
moc_file.GetDepends().push_back(hname);
116
source_file.GetDepends().push_back(hname);
117
source_file.GetDepends().push_back(origname);
118
header_file.GetDepends().push_back(origname);
119
m_WrapHeadersClasses.push_back(header_file);
120
m_WrapSourcesClasses.push_back(source_file);
121
m_WrapMocClasses.push_back(moc_file);
122
m_Makefile->AddSource(header_file,
123
m_HeaderList.c_str());
124
m_Makefile->AddSource(source_file,
125
m_SourceList.c_str());
126
m_Makefile->AddSource(moc_file,
127
m_SourceList.c_str());
135
void cmQTWrapUICommand::FinalPass()
138
// first we add the rules for all the .ui to .h and .cxx files
139
int lastHeadersClass = m_WrapHeadersClasses.size();
140
std::vector<std::string> depends;
141
std::string uic_exe = "${QT_UIC_EXE}";
142
std::string moc_exe = "${QT_MOC_EXE}";
145
// wrap all the .h files
146
depends.push_back(uic_exe);
148
const char * GENERATED_QT_FILES_value=
149
m_Makefile->GetDefinition("GENERATED_QT_FILES");
150
std::string ui_list("");
151
if (GENERATED_QT_FILES_value!=0)
153
ui_list=ui_list+GENERATED_QT_FILES_value;
156
for(int classNum = 0; classNum < lastHeadersClass; classNum++)
158
// set up .ui to .h and .cxx command
160
std::string hres = m_Makefile->GetCurrentOutputDirectory();
162
hres += m_WrapHeadersClasses[classNum].GetSourceName() + "." +
163
m_WrapHeadersClasses[classNum].GetSourceExtension();
165
std::string cxxres = m_Makefile->GetCurrentOutputDirectory();
167
cxxres += m_WrapSourcesClasses[classNum].GetSourceName() + "." +
168
m_WrapSourcesClasses[classNum].GetSourceExtension();
170
std::string mocres = m_Makefile->GetCurrentOutputDirectory();
172
mocres += m_WrapMocClasses[classNum].GetSourceName() + "." +
173
m_WrapMocClasses[classNum].GetSourceExtension();
175
ui_list = ui_list + " " + hres + " " + cxxres + " " + mocres;
177
std::vector<std::string> hargs;
178
hargs.push_back("-o");
179
hargs.push_back(hres);
180
hargs.push_back(m_WrapUserInterface[classNum]);
182
std::vector<std::string> cxxargs;
183
cxxargs.push_back("-impl");
184
cxxargs.push_back(hres);
185
cxxargs.push_back("-o");
186
cxxargs.push_back(cxxres);
187
cxxargs.push_back(m_WrapUserInterface[classNum]);
189
std::vector<std::string> mocargs;
190
mocargs.push_back("-o");
191
mocargs.push_back(mocres);
192
mocargs.push_back(hres);
194
m_Makefile->AddCustomCommand(m_WrapUserInterface[classNum].c_str(),
195
uic_exe.c_str(), hargs, depends,
196
hres.c_str(), m_LibraryName.c_str());
198
depends.push_back(hres);
200
m_Makefile->AddCustomCommand(m_WrapUserInterface[classNum].c_str(),
201
uic_exe.c_str(), cxxargs, depends,
202
cxxres.c_str(), m_LibraryName.c_str());
205
depends.push_back(moc_exe);
207
m_Makefile->AddCustomCommand(hres.c_str(),
208
moc_exe.c_str(), mocargs, depends,
209
mocres.c_str(), m_LibraryName.c_str());
213
m_Makefile->AddDefinition("GENERATED_QT_FILES",ui_list.c_str());