2016-09-27 22:01:08 +03:00
|
|
|
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
|
|
|
file Copyright.txt or https://cmake.org/licensing for details. */
|
2001-11-09 20:03:41 +03:00
|
|
|
#include "cmQTWrapUICommand.h"
|
|
|
|
|
|
|
|
// cmQTWrapUICommand
|
2015-01-18 19:10:03 +03:00
|
|
|
bool cmQTWrapUICommand::InitialPass(std::vector<std::string> const& args,
|
2016-05-16 17:34:04 +03:00
|
|
|
cmExecutionStatus&)
|
2001-11-09 20:03:41 +03:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (args.size() < 4) {
|
2001-11-09 20:03:41 +03:00
|
|
|
this->SetError("called with incorrect number of arguments");
|
|
|
|
return false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-06-18 19:59:23 +04:00
|
|
|
|
|
|
|
// Get the uic and moc executables to run in the custom commands.
|
|
|
|
const char* uic_exe =
|
|
|
|
this->Makefile->GetRequiredDefinition("QT_UIC_EXECUTABLE");
|
|
|
|
const char* moc_exe =
|
|
|
|
this->Makefile->GetRequiredDefinition("QT_MOC_EXECUTABLE");
|
|
|
|
|
|
|
|
// Get the variable holding the list of sources.
|
|
|
|
std::string const& headerList = args[1];
|
|
|
|
std::string const& sourceList = args[2];
|
2016-05-16 17:34:04 +03:00
|
|
|
std::string headerListValue = this->Makefile->GetSafeDefinition(headerList);
|
|
|
|
std::string sourceListValue = this->Makefile->GetSafeDefinition(sourceList);
|
2007-06-18 19:59:23 +04:00
|
|
|
|
|
|
|
// Create rules for all sources listed.
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<std::string>::const_iterator j = (args.begin() + 3);
|
|
|
|
j != args.end(); ++j) {
|
|
|
|
cmSourceFile* curr = this->Makefile->GetSource(*j);
|
2002-06-27 23:57:09 +04:00
|
|
|
// if we should wrap the class
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!(curr && curr->GetPropertyAsBool("WRAP_EXCLUDE"))) {
|
2007-06-18 19:59:23 +04:00
|
|
|
// Compute the name of the files to generate.
|
2016-05-16 17:34:04 +03:00
|
|
|
std::string srcName = cmSystemTools::GetFilenameWithoutLastExtension(*j);
|
2015-04-16 22:33:09 +03:00
|
|
|
std::string hName = this->Makefile->GetCurrentBinaryDirectory();
|
2007-06-18 19:59:23 +04:00
|
|
|
hName += "/";
|
|
|
|
hName += srcName;
|
|
|
|
hName += ".h";
|
2015-04-16 22:33:09 +03:00
|
|
|
std::string cxxName = this->Makefile->GetCurrentBinaryDirectory();
|
2007-06-18 19:59:23 +04:00
|
|
|
cxxName += "/";
|
|
|
|
cxxName += srcName;
|
|
|
|
cxxName += ".cxx";
|
2015-04-16 22:33:09 +03:00
|
|
|
std::string mocName = this->Makefile->GetCurrentBinaryDirectory();
|
2007-06-18 19:59:23 +04:00
|
|
|
mocName += "/moc_";
|
|
|
|
mocName += srcName;
|
|
|
|
mocName += ".cxx";
|
|
|
|
|
|
|
|
// Compute the name of the ui file from which to generate others.
|
|
|
|
std::string uiName;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (cmSystemTools::FileIsFullPath(j->c_str())) {
|
2007-06-18 19:59:23 +04:00
|
|
|
uiName = *j;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
|
|
|
if (curr && curr->GetPropertyAsBool("GENERATED")) {
|
2015-04-16 22:33:09 +03:00
|
|
|
uiName = this->Makefile->GetCurrentBinaryDirectory();
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2015-04-16 22:17:41 +03:00
|
|
|
uiName = this->Makefile->GetCurrentSourceDirectory();
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-06-18 19:59:23 +04:00
|
|
|
uiName += "/";
|
|
|
|
uiName += *j;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-06-18 19:59:23 +04:00
|
|
|
|
|
|
|
// create the list of headers
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!headerListValue.empty()) {
|
2002-09-12 00:44:52 +04:00
|
|
|
headerListValue += ";";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-06-18 19:59:23 +04:00
|
|
|
headerListValue += hName;
|
|
|
|
|
2002-06-27 23:57:09 +04:00
|
|
|
// create the list of sources
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!sourceListValue.empty()) {
|
2002-06-27 23:57:09 +04:00
|
|
|
sourceListValue += ";";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-06-18 19:59:23 +04:00
|
|
|
sourceListValue += cxxName;
|
2002-06-27 23:57:09 +04:00
|
|
|
sourceListValue += ";";
|
2007-06-18 19:59:23 +04:00
|
|
|
sourceListValue += mocName;
|
|
|
|
|
|
|
|
// set up .ui to .h and .cxx command
|
|
|
|
cmCustomCommandLine hCommand;
|
|
|
|
hCommand.push_back(uic_exe);
|
|
|
|
hCommand.push_back("-o");
|
|
|
|
hCommand.push_back(hName);
|
|
|
|
hCommand.push_back(uiName);
|
|
|
|
cmCustomCommandLines hCommandLines;
|
|
|
|
hCommandLines.push_back(hCommand);
|
|
|
|
|
|
|
|
cmCustomCommandLine cxxCommand;
|
|
|
|
cxxCommand.push_back(uic_exe);
|
|
|
|
cxxCommand.push_back("-impl");
|
|
|
|
cxxCommand.push_back(hName);
|
|
|
|
cxxCommand.push_back("-o");
|
|
|
|
cxxCommand.push_back(cxxName);
|
|
|
|
cxxCommand.push_back(uiName);
|
|
|
|
cmCustomCommandLines cxxCommandLines;
|
|
|
|
cxxCommandLines.push_back(cxxCommand);
|
|
|
|
|
|
|
|
cmCustomCommandLine mocCommand;
|
|
|
|
mocCommand.push_back(moc_exe);
|
|
|
|
mocCommand.push_back("-o");
|
|
|
|
mocCommand.push_back(mocName);
|
|
|
|
mocCommand.push_back(hName);
|
|
|
|
cmCustomCommandLines mocCommandLines;
|
|
|
|
mocCommandLines.push_back(mocCommand);
|
|
|
|
|
|
|
|
std::vector<std::string> depends;
|
|
|
|
depends.push_back(uiName);
|
2014-02-25 05:32:55 +04:00
|
|
|
std::string no_main_dependency = "";
|
2016-06-27 23:44:16 +03:00
|
|
|
const char* no_comment = CM_NULLPTR;
|
|
|
|
const char* no_working_dir = CM_NULLPTR;
|
2016-05-16 17:34:04 +03:00
|
|
|
this->Makefile->AddCustomCommandToOutput(
|
|
|
|
hName, depends, no_main_dependency, hCommandLines, no_comment,
|
|
|
|
no_working_dir);
|
2007-06-18 19:59:23 +04:00
|
|
|
|
|
|
|
depends.push_back(hName);
|
2016-05-16 17:34:04 +03:00
|
|
|
this->Makefile->AddCustomCommandToOutput(
|
|
|
|
cxxName, depends, no_main_dependency, cxxCommandLines, no_comment,
|
|
|
|
no_working_dir);
|
2007-06-18 19:59:23 +04:00
|
|
|
|
|
|
|
depends.clear();
|
|
|
|
depends.push_back(hName);
|
2016-05-16 17:34:04 +03:00
|
|
|
this->Makefile->AddCustomCommandToOutput(
|
|
|
|
mocName, depends, no_main_dependency, mocCommandLines, no_comment,
|
|
|
|
no_working_dir);
|
2001-11-09 20:03:41 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2001-11-09 20:03:41 +03:00
|
|
|
|
2007-06-18 19:59:23 +04:00
|
|
|
// Store the final list of source files and headers.
|
2016-05-16 17:34:04 +03:00
|
|
|
this->Makefile->AddDefinition(sourceList, sourceListValue.c_str());
|
|
|
|
this->Makefile->AddDefinition(headerList, headerListValue.c_str());
|
2007-06-18 19:59:23 +04:00
|
|
|
return true;
|
2001-11-09 20:03:41 +03:00
|
|
|
}
|