1 /*============================================================================
2 CMake - Cross Platform Makefile Generator
3 Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
5 Distributed under the OSI-approved BSD License (the "License");
6 see accompanying file Copyright.txt for details.
8 This software is distributed WITHOUT ANY WARRANTY; without even the
9 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10 See the License for more information.
11 ============================================================================*/
12 #include "cmQTWrapCPPCommand.h"
15 bool cmQTWrapCPPCommand::InitialPass(std::vector<std::string> const& argsIn,
18 if(argsIn.size() < 3 )
20 this->SetError("called with incorrect number of arguments");
24 // This command supports source list inputs for compatibility.
25 std::vector<std::string> args;
26 this->Makefile->ExpandSourceListArguments(argsIn, args, 2);
28 // Get the moc executable to run in the custom command.
30 this->Makefile->GetRequiredDefinition("QT_MOC_EXECUTABLE");
32 // Get the variable holding the list of sources.
33 std::string const& sourceList = args[1];
34 std::string sourceListValue =
35 this->Makefile->GetSafeDefinition(sourceList.c_str());
37 // Create a rule for all sources listed.
38 for(std::vector<std::string>::iterator j = (args.begin() + 2);
41 cmSourceFile *curr = this->Makefile->GetSource(j->c_str());
42 // if we should wrap the class
43 if(!(curr && curr->GetPropertyAsBool("WRAP_EXCLUDE")))
45 // Compute the name of the file to generate.
47 cmSystemTools::GetFilenameWithoutLastExtension(*j);
48 std::string newName = this->Makefile->GetCurrentOutputDirectory();
53 this->Makefile->GetOrCreateSource(newName.c_str(), true);
56 sf->SetProperty("ABSTRACT", curr->GetProperty("ABSTRACT"));
59 // Compute the name of the header from which to generate the file.
61 if(cmSystemTools::FileIsFullPath(j->c_str()))
67 if(curr && curr->GetPropertyAsBool("GENERATED"))
69 hname = this->Makefile->GetCurrentOutputDirectory();
73 hname = this->Makefile->GetCurrentDirectory();
79 // Append the generated source file to the list.
80 if(!sourceListValue.empty())
82 sourceListValue += ";";
84 sourceListValue += newName;
86 // Create the custom command to generate the file.
87 cmCustomCommandLine commandLine;
88 commandLine.push_back(moc_exe);
89 commandLine.push_back("-o");
90 commandLine.push_back(newName);
91 commandLine.push_back(hname);
93 cmCustomCommandLines commandLines;
94 commandLines.push_back(commandLine);
96 std::vector<std::string> depends;
97 depends.push_back(moc_exe);
98 depends.push_back(hname);
100 const char* no_main_dependency = 0;
101 const char* no_working_dir = 0;
102 this->Makefile->AddCustomCommandToOutput(newName.c_str(),
111 // Store the final list of source files.
112 this->Makefile->AddDefinition(sourceList.c_str(),
113 sourceListValue.c_str());