2009-10-02 01:21:28 +04:00
|
|
|
/*============================================================================
|
|
|
|
CMake - Cross Platform Makefile Generator
|
|
|
|
Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
|
2001-11-09 20:03:41 +03:00
|
|
|
|
2009-10-02 01:21:28 +04:00
|
|
|
Distributed under the OSI-approved BSD License (the "License");
|
|
|
|
see accompanying file Copyright.txt for details.
|
2001-11-09 20:03:41 +03:00
|
|
|
|
2009-10-02 01:21:28 +04: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 20:03:41 +03:00
|
|
|
#include "cmQTWrapUICommand.h"
|
|
|
|
|
|
|
|
// cmQTWrapUICommand
|
2008-01-23 18:28:26 +03:00
|
|
|
bool cmQTWrapUICommand::InitialPass(std::vector<std::string> const& argsIn,
|
|
|
|
cmExecutionStatus &)
|
2001-11-09 20:03:41 +03:00
|
|
|
{
|
2002-03-29 22:20:32 +03:00
|
|
|
if(argsIn.size() < 4 )
|
2001-11-09 20:03:41 +03:00
|
|
|
{
|
|
|
|
this->SetError("called with incorrect number of arguments");
|
|
|
|
return false;
|
|
|
|
}
|
2007-06-18 19:59:23 +04:00
|
|
|
|
|
|
|
// This command supports source list inputs for compatibility.
|
2002-03-29 22:20:32 +03:00
|
|
|
std::vector<std::string> args;
|
2006-03-15 19:02:08 +03:00
|
|
|
this->Makefile->ExpandSourceListArguments(argsIn, args, 3);
|
2001-11-09 20:03:41 +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];
|
|
|
|
std::string headerListValue =
|
|
|
|
this->Makefile->GetSafeDefinition(headerList.c_str());
|
|
|
|
std::string sourceListValue =
|
|
|
|
this->Makefile->GetSafeDefinition(sourceList.c_str());
|
|
|
|
|
|
|
|
// Create rules for all sources listed.
|
2002-06-27 23:57:09 +04:00
|
|
|
for(std::vector<std::string>::iterator j = (args.begin() + 3);
|
2001-11-09 20:03:41 +03:00
|
|
|
j != args.end(); ++j)
|
2007-06-18 19:59:23 +04:00
|
|
|
{
|
2006-03-15 19:02:08 +03:00
|
|
|
cmSourceFile *curr = this->Makefile->GetSource(j->c_str());
|
2002-06-27 23:57:09 +04:00
|
|
|
// if we should wrap the class
|
2007-06-18 19:59:23 +04:00
|
|
|
if(!(curr && curr->GetPropertyAsBool("WRAP_EXCLUDE")))
|
2001-11-09 20:03:41 +03:00
|
|
|
{
|
2007-06-18 19:59:23 +04:00
|
|
|
// Compute the name of the files to generate.
|
|
|
|
std::string srcName =
|
|
|
|
cmSystemTools::GetFilenameWithoutLastExtension(*j);
|
|
|
|
std::string hName = this->Makefile->GetCurrentOutputDirectory();
|
|
|
|
hName += "/";
|
|
|
|
hName += srcName;
|
|
|
|
hName += ".h";
|
|
|
|
std::string cxxName = this->Makefile->GetCurrentOutputDirectory();
|
|
|
|
cxxName += "/";
|
|
|
|
cxxName += srcName;
|
|
|
|
cxxName += ".cxx";
|
|
|
|
std::string mocName = this->Makefile->GetCurrentOutputDirectory();
|
|
|
|
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 21:27:41 +04:00
|
|
|
{
|
2007-06-18 19:59:23 +04:00
|
|
|
uiName = *j;
|
2003-07-30 21:27:41 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-06-18 19:59:23 +04:00
|
|
|
if(curr && curr->GetPropertyAsBool("GENERATED"))
|
2003-07-30 21:27:41 +04:00
|
|
|
{
|
2007-06-18 19:59:23 +04:00
|
|
|
uiName = this->Makefile->GetCurrentOutputDirectory();
|
2003-07-30 21:27:41 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-06-18 19:59:23 +04:00
|
|
|
uiName = this->Makefile->GetCurrentDirectory();
|
2003-07-30 21:27:41 +04:00
|
|
|
}
|
2007-06-18 19:59:23 +04:00
|
|
|
uiName += "/";
|
|
|
|
uiName += *j;
|
2003-07-30 21:27:41 +04:00
|
|
|
}
|
2007-06-18 19:59:23 +04:00
|
|
|
|
|
|
|
// create the list of headers
|
|
|
|
if(!headerListValue.empty())
|
2002-09-12 00:44:52 +04:00
|
|
|
{
|
|
|
|
headerListValue += ";";
|
|
|
|
}
|
2007-06-18 19:59:23 +04:00
|
|
|
headerListValue += hName;
|
|
|
|
|
2002-06-27 23:57:09 +04:00
|
|
|
// create the list of sources
|
2007-06-18 19:59:23 +04:00
|
|
|
if(!sourceListValue.empty())
|
2001-11-09 20:03:41 +03:00
|
|
|
{
|
2002-06-27 23:57:09 +04:00
|
|
|
sourceListValue += ";";
|
2001-11-09 20:03:41 +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);
|
|
|
|
const char* no_main_dependency = 0;
|
|
|
|
const char* no_comment = 0;
|
|
|
|
const char* no_working_dir = 0;
|
|
|
|
this->Makefile->AddCustomCommandToOutput(hName.c_str(),
|
|
|
|
depends,
|
|
|
|
no_main_dependency,
|
|
|
|
hCommandLines,
|
|
|
|
no_comment,
|
|
|
|
no_working_dir);
|
|
|
|
|
|
|
|
depends.push_back(hName);
|
|
|
|
this->Makefile->AddCustomCommandToOutput(cxxName.c_str(),
|
|
|
|
depends,
|
|
|
|
no_main_dependency,
|
|
|
|
cxxCommandLines,
|
|
|
|
no_comment,
|
|
|
|
no_working_dir);
|
|
|
|
|
|
|
|
depends.clear();
|
|
|
|
depends.push_back(hName);
|
|
|
|
this->Makefile->AddCustomCommandToOutput(mocName.c_str(),
|
|
|
|
depends,
|
|
|
|
no_main_dependency,
|
|
|
|
mocCommandLines,
|
|
|
|
no_comment,
|
|
|
|
no_working_dir);
|
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.
|
|
|
|
this->Makefile->AddDefinition(sourceList.c_str(),
|
|
|
|
sourceListValue.c_str());
|
|
|
|
this->Makefile->AddDefinition(headerList.c_str(),
|
|
|
|
headerListValue.c_str());
|
|
|
|
return true;
|
2001-11-09 20:03:41 +03:00
|
|
|
}
|