1
1
/*=========================================================================
3
Program: Insight Segmentation & Registration Toolkit
3
Program: CMake - Cross-Platform Makefile Generator
4
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.
6
Date: $Date: 2004/07/07 21:09:56 $
7
Version: $Revision: 1.17.2.1 $
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.
41
16
=========================================================================*/
42
17
#include "cmQTWrapUICommand.h"
44
19
// cmQTWrapUICommand
45
bool cmQTWrapUICommand::InitialPass(std::vector<std::string> const& args)
20
bool cmQTWrapUICommand::InitialPass(std::vector<std::string> const& argsIn)
22
if(argsIn.size() < 4 )
49
24
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 : ");
27
std::vector<std::string> args;
28
m_Makefile->ExpandSourceListArguments(argsIn, args, 3);
68
30
// what is the current source dir
69
31
std::string cdir = m_Makefile->GetCurrentDirectory();
72
34
m_LibraryName = args[0];
73
35
m_HeaderList = args[1];
74
36
m_SourceList = args[2];
37
std::string sourceListValue;
38
std::string headerListValue;
39
const char *def = m_Makefile->GetDefinition(m_SourceList.c_str());
42
sourceListValue = def;
76
45
// 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);
46
for(std::vector<std::string>::iterator j = (args.begin() + 3);
81
47
j != args.end(); ++j)
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());
49
cmSourceFile *curr = m_Makefile->GetSource(j->c_str());
51
// if we should wrap the class
52
if (!curr || !curr->GetPropertyAsBool("WRAP_EXCLUDE"))
54
cmSourceFile header_file;
55
cmSourceFile source_file;
56
cmSourceFile moc_file;
57
std::string srcName = cmSystemTools::GetFilenameWithoutExtension(*j);
58
header_file.SetName(srcName.c_str(),
59
m_Makefile->GetCurrentOutputDirectory(),
61
source_file.SetName(srcName.c_str(),
62
m_Makefile->GetCurrentOutputDirectory(),
64
std::string moc_source_name("moc_");
65
moc_source_name = moc_source_name + srcName;
66
moc_file.SetName(moc_source_name.c_str(),
67
m_Makefile->GetCurrentOutputDirectory(),
70
if ( (*j)[0] == '/' || (*j)[1] == ':' )
76
if ( curr && curr->GetPropertyAsBool("GENERATED") )
78
origname = std::string( m_Makefile->GetCurrentOutputDirectory() ) + "/" + *j;
82
origname = cdir + "/" + *j;
85
std::string hname = header_file.GetFullPath();
86
m_WrapUserInterface.push_back(origname);
87
// add starting depends
88
moc_file.GetDepends().push_back(hname);
89
source_file.GetDepends().push_back(hname);
90
source_file.GetDepends().push_back(origname);
91
header_file.GetDepends().push_back(origname);
92
m_WrapHeadersClasses.push_back(header_file);
93
m_WrapSourcesClasses.push_back(source_file);
94
m_WrapMocClasses.push_back(moc_file);
95
m_Makefile->AddSource(header_file);
96
m_Makefile->AddSource(source_file);
97
m_Makefile->AddSource(moc_file);
99
// create the list of headers
100
if (headerListValue.size() > 0)
102
headerListValue += ";";
104
headerListValue += header_file.GetFullPath();
106
// create the list of sources
107
if (sourceListValue.size() > 0)
109
sourceListValue += ";";
111
sourceListValue += source_file.GetFullPath();
112
sourceListValue += ";";
113
sourceListValue += moc_file.GetFullPath();
117
m_Makefile->AddDefinition(m_SourceList.c_str(), sourceListValue.c_str());
118
m_Makefile->AddDefinition(m_HeaderList.c_str(), headerListValue.c_str());
191
178
mocargs.push_back(mocres);
192
179
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());
182
depends.push_back(m_WrapUserInterface[classNum]);
183
m_Makefile->AddCustomCommandToOutput(
185
uic_exe.c_str(), hargs, 0,
188
depends.push_back(hres);
190
m_Makefile->AddCustomCommandToOutput(
192
uic_exe.c_str(), cxxargs, 0, depends);
197
depends.push_back(hres);
199
m_Makefile->AddCustomCommandToOutput(
201
moc_exe.c_str(), mocargs, 0, depends);