1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmQTWrapUICommand.cxx,v $
6 Date: $Date: 2008-01-23 15:27:59 $
7 Version: $Revision: 1.26 $
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 "cmQTWrapUICommand.h"
20 bool cmQTWrapUICommand::InitialPass(std::vector
<std::string
> const& argsIn
,
23 if(argsIn
.size() < 4 )
25 this->SetError("called with incorrect number of arguments");
29 // This command supports source list inputs for compatibility.
30 std::vector
<std::string
> args
;
31 this->Makefile
->ExpandSourceListArguments(argsIn
, args
, 3);
33 // Get the uic and moc executables to run in the custom commands.
35 this->Makefile
->GetRequiredDefinition("QT_UIC_EXECUTABLE");
37 this->Makefile
->GetRequiredDefinition("QT_MOC_EXECUTABLE");
39 // Get the variable holding the list of sources.
40 std::string
const& headerList
= args
[1];
41 std::string
const& sourceList
= args
[2];
42 std::string headerListValue
=
43 this->Makefile
->GetSafeDefinition(headerList
.c_str());
44 std::string sourceListValue
=
45 this->Makefile
->GetSafeDefinition(sourceList
.c_str());
47 // Create rules for all sources listed.
48 for(std::vector
<std::string
>::iterator j
= (args
.begin() + 3);
51 cmSourceFile
*curr
= this->Makefile
->GetSource(j
->c_str());
52 // if we should wrap the class
53 if(!(curr
&& curr
->GetPropertyAsBool("WRAP_EXCLUDE")))
55 // Compute the name of the files to generate.
57 cmSystemTools::GetFilenameWithoutLastExtension(*j
);
58 std::string hName
= this->Makefile
->GetCurrentOutputDirectory();
62 std::string cxxName
= this->Makefile
->GetCurrentOutputDirectory();
66 std::string mocName
= this->Makefile
->GetCurrentOutputDirectory();
71 // Compute the name of the ui file from which to generate others.
73 if(cmSystemTools::FileIsFullPath(j
->c_str()))
79 if(curr
&& curr
->GetPropertyAsBool("GENERATED"))
81 uiName
= this->Makefile
->GetCurrentOutputDirectory();
85 uiName
= this->Makefile
->GetCurrentDirectory();
91 // create the list of headers
92 if(!headerListValue
.empty())
94 headerListValue
+= ";";
96 headerListValue
+= hName
;
98 // create the list of sources
99 if(!sourceListValue
.empty())
101 sourceListValue
+= ";";
103 sourceListValue
+= cxxName
;
104 sourceListValue
+= ";";
105 sourceListValue
+= mocName
;
107 // set up .ui to .h and .cxx command
108 cmCustomCommandLine hCommand
;
109 hCommand
.push_back(uic_exe
);
110 hCommand
.push_back("-o");
111 hCommand
.push_back(hName
);
112 hCommand
.push_back(uiName
);
113 cmCustomCommandLines hCommandLines
;
114 hCommandLines
.push_back(hCommand
);
116 cmCustomCommandLine cxxCommand
;
117 cxxCommand
.push_back(uic_exe
);
118 cxxCommand
.push_back("-impl");
119 cxxCommand
.push_back(hName
);
120 cxxCommand
.push_back("-o");
121 cxxCommand
.push_back(cxxName
);
122 cxxCommand
.push_back(uiName
);
123 cmCustomCommandLines cxxCommandLines
;
124 cxxCommandLines
.push_back(cxxCommand
);
126 cmCustomCommandLine mocCommand
;
127 mocCommand
.push_back(moc_exe
);
128 mocCommand
.push_back("-o");
129 mocCommand
.push_back(mocName
);
130 mocCommand
.push_back(hName
);
131 cmCustomCommandLines mocCommandLines
;
132 mocCommandLines
.push_back(mocCommand
);
134 std::vector
<std::string
> depends
;
135 depends
.push_back(uiName
);
136 const char* no_main_dependency
= 0;
137 const char* no_comment
= 0;
138 const char* no_working_dir
= 0;
139 this->Makefile
->AddCustomCommandToOutput(hName
.c_str(),
146 depends
.push_back(hName
);
147 this->Makefile
->AddCustomCommandToOutput(cxxName
.c_str(),
155 depends
.push_back(hName
);
156 this->Makefile
->AddCustomCommandToOutput(mocName
.c_str(),
165 // Store the final list of source files and headers.
166 this->Makefile
->AddDefinition(sourceList
.c_str(),
167 sourceListValue
.c_str());
168 this->Makefile
->AddDefinition(headerList
.c_str(),
169 headerListValue
.c_str());