2009-09-28 15:43:28 +00:00
|
|
|
/*============================================================================
|
|
|
|
CMake - Cross Platform Makefile Generator
|
|
|
|
Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
|
2001-11-09 17:03:41 +00:00
|
|
|
|
2009-09-28 15:43:28 +00:00
|
|
|
Distributed under the OSI-approved BSD License (the "License");
|
|
|
|
see accompanying file Copyright.txt for details.
|
2001-11-09 17:03:41 +00:00
|
|
|
|
2009-09-28 15:43:28 +00:00
|
|
|
This software is distributed WITHOUT ANY WARRANTY; without even the
|
|
|
|
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
See the License for more information.
|
|
|
|
============================================================================*/
|
2001-11-09 17:03:41 +00:00
|
|
|
#include "cmQTWrapUICommand.h"
|
|
|
|
|
|
|
|
// cmQTWrapUICommand
|
2015-01-18 16:10:03 +00:00
|
|
|
bool cmQTWrapUICommand::InitialPass(std::vector<std::string> const& args,
|
2008-01-23 15:28:26 +00:00
|
|
|
cmExecutionStatus &)
|
2001-11-09 17:03:41 +00:00
|
|
|
{
|
2015-01-18 16:10:03 +00:00
|
|
|
if(args.size() < 4 )
|
2001-11-09 17:03:41 +00:00
|
|
|
{
|
|
|
|
this->SetError("called with incorrect number of arguments");
|
|
|
|
return false;
|
|
|
|
}
|
2007-06-18 15:59:23 +00: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];
|
|
|
|
std::string headerListValue =
|
2014-03-10 23:04:11 +00:00
|
|
|
this->Makefile->GetSafeDefinition(headerList);
|
2007-06-18 15:59:23 +00:00
|
|
|
std::string sourceListValue =
|
2014-03-10 23:04:11 +00:00
|
|
|
this->Makefile->GetSafeDefinition(sourceList);
|
2007-06-18 15:59:23 +00:00
|
|
|
|
|
|
|
// Create rules for all sources listed.
|
2015-01-18 16:10:03 +00:00
|
|
|
for(std::vector<std::string>::const_iterator j = (args.begin() + 3);
|
2001-11-09 17:03:41 +00:00
|
|
|
j != args.end(); ++j)
|
2007-06-18 15:59:23 +00:00
|
|
|
{
|
2014-03-10 23:04:11 +00:00
|
|
|
cmSourceFile *curr = this->Makefile->GetSource(*j);
|
2002-06-27 19:57:09 +00:00
|
|
|
// if we should wrap the class
|
2007-06-18 15:59:23 +00:00
|
|
|
if(!(curr && curr->GetPropertyAsBool("WRAP_EXCLUDE")))
|
2001-11-09 17:03:41 +00:00
|
|
|
{
|
2007-06-18 15:59:23 +00:00
|
|
|
// Compute the name of the files to generate.
|
|
|
|
std::string srcName =
|
|
|
|
cmSystemTools::GetFilenameWithoutLastExtension(*j);
|
2015-04-16 19:33:09 +00:00
|
|
|
std::string hName = this->Makefile->GetCurrentBinaryDirectory();
|
2007-06-18 15:59:23 +00:00
|
|
|
hName += "/";
|
|
|
|
hName += srcName;
|
|
|
|
hName += ".h";
|
2015-04-16 19:33:09 +00:00
|
|
|
std::string cxxName = this->Makefile->GetCurrentBinaryDirectory();
|
2007-06-18 15:59:23 +00:00
|
|
|
cxxName += "/";
|
|
|
|
cxxName += srcName;
|
|
|
|
cxxName += ".cxx";
|
2015-04-16 19:33:09 +00:00
|
|
|
std::string mocName = this->Makefile->GetCurrentBinaryDirectory();
|
2007-06-18 15:59:23 +00:00
|
|
|
mocName += "/moc_";
|
|
|
|
mocName += srcName;
|
|
|
|
mocName += ".cxx";
|
|
|
|
|
|
|
|
// Compute the name of the ui file from which to generate others.
|
|
|
|
std::string uiName;
|
|
|
|
if(cmSystemTools::FileIsFullPath(j->c_str()))
|
2003-07-30 17:27:41 +00:00
|
|
|
{
|
2007-06-18 15:59:23 +00:00
|
|
|
uiName = *j;
|
2003-07-30 17:27:41 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-06-18 15:59:23 +00:00
|
|
|
if(curr && curr->GetPropertyAsBool("GENERATED"))
|
2003-07-30 17:27:41 +00:00
|
|
|
{
|
2015-04-16 19:33:09 +00:00
|
|
|
uiName = this->Makefile->GetCurrentBinaryDirectory();
|
2003-07-30 17:27:41 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-04-16 19:17:41 +00:00
|
|
|
uiName = this->Makefile->GetCurrentSourceDirectory();
|
2003-07-30 17:27:41 +00:00
|
|
|
}
|
2007-06-18 15:59:23 +00:00
|
|
|
uiName += "/";
|
|
|
|
uiName += *j;
|
2003-07-30 17:27:41 +00:00
|
|
|
}
|
2007-06-18 15:59:23 +00:00
|
|
|
|
|
|
|
// create the list of headers
|
|
|
|
if(!headerListValue.empty())
|
2002-09-11 20:44:52 +00:00
|
|
|
{
|
|
|
|
headerListValue += ";";
|
|
|
|
}
|
2007-06-18 15:59:23 +00:00
|
|
|
headerListValue += hName;
|
|
|
|
|
2002-06-27 19:57:09 +00:00
|
|
|
// create the list of sources
|
2007-06-18 15:59:23 +00:00
|
|
|
if(!sourceListValue.empty())
|
2001-11-09 17:03:41 +00:00
|
|
|
{
|
2002-06-27 19:57:09 +00:00
|
|
|
sourceListValue += ";";
|
2001-11-09 17:03:41 +00:00
|
|
|
}
|
2007-06-18 15:59:23 +00:00
|
|
|
sourceListValue += cxxName;
|
2002-06-27 19:57:09 +00:00
|
|
|
sourceListValue += ";";
|
2007-06-18 15:59:23 +00: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 01:32:55 +00:00
|
|
|
std::string no_main_dependency = "";
|
2007-06-18 15:59:23 +00:00
|
|
|
const char* no_comment = 0;
|
|
|
|
const char* no_working_dir = 0;
|
2014-03-10 23:04:11 +00:00
|
|
|
this->Makefile->AddCustomCommandToOutput(hName,
|
2007-06-18 15:59:23 +00:00
|
|
|
depends,
|
|
|
|
no_main_dependency,
|
|
|
|
hCommandLines,
|
|
|
|
no_comment,
|
|
|
|
no_working_dir);
|
|
|
|
|
|
|
|
depends.push_back(hName);
|
2014-03-10 23:04:11 +00:00
|
|
|
this->Makefile->AddCustomCommandToOutput(cxxName,
|
2007-06-18 15:59:23 +00:00
|
|
|
depends,
|
|
|
|
no_main_dependency,
|
|
|
|
cxxCommandLines,
|
|
|
|
no_comment,
|
|
|
|
no_working_dir);
|
|
|
|
|
|
|
|
depends.clear();
|
|
|
|
depends.push_back(hName);
|
2014-03-10 23:04:11 +00:00
|
|
|
this->Makefile->AddCustomCommandToOutput(mocName,
|
2007-06-18 15:59:23 +00:00
|
|
|
depends,
|
|
|
|
no_main_dependency,
|
|
|
|
mocCommandLines,
|
|
|
|
no_comment,
|
|
|
|
no_working_dir);
|
2001-11-09 17:03:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-06-18 15:59:23 +00:00
|
|
|
// Store the final list of source files and headers.
|
2014-03-10 23:04:11 +00:00
|
|
|
this->Makefile->AddDefinition(sourceList,
|
2007-06-18 15:59:23 +00:00
|
|
|
sourceListValue.c_str());
|
2014-03-10 23:04:11 +00:00
|
|
|
this->Makefile->AddDefinition(headerList,
|
2007-06-18 15:59:23 +00:00
|
|
|
headerListValue.c_str());
|
|
|
|
return true;
|
2001-11-09 17:03:41 +00:00
|
|
|
}
|