1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmQTWrapCPPCommand.cxx,v $
6 Date: $Date: 2008-01-23 15:27:59 $
7 Version: $Revision: 1.27 $
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 "cmQTWrapCPPCommand.h"
20 bool cmQTWrapCPPCommand::InitialPass(std::vector
<std::string
> const& argsIn
,
23 if(argsIn
.size() < 3 )
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
, 2);
33 // Get the moc executable to run in the custom command.
35 this->Makefile
->GetRequiredDefinition("QT_MOC_EXECUTABLE");
37 // Get the variable holding the list of sources.
38 std::string
const& sourceList
= args
[1];
39 std::string sourceListValue
=
40 this->Makefile
->GetSafeDefinition(sourceList
.c_str());
42 // Create a rule for all sources listed.
43 for(std::vector
<std::string
>::iterator j
= (args
.begin() + 2);
46 cmSourceFile
*curr
= this->Makefile
->GetSource(j
->c_str());
47 // if we should wrap the class
48 if(!(curr
&& curr
->GetPropertyAsBool("WRAP_EXCLUDE")))
50 // Compute the name of the file to generate.
52 cmSystemTools::GetFilenameWithoutLastExtension(*j
);
53 std::string newName
= this->Makefile
->GetCurrentOutputDirectory();
58 this->Makefile
->GetOrCreateSource(newName
.c_str(), true);
61 sf
->SetProperty("ABSTRACT", curr
->GetProperty("ABSTRACT"));
64 // Compute the name of the header from which to generate the file.
66 if(cmSystemTools::FileIsFullPath(j
->c_str()))
72 if(curr
&& curr
->GetPropertyAsBool("GENERATED"))
74 hname
= this->Makefile
->GetCurrentOutputDirectory();
78 hname
= this->Makefile
->GetCurrentDirectory();
84 // Append the generated source file to the list.
85 if(!sourceListValue
.empty())
87 sourceListValue
+= ";";
89 sourceListValue
+= newName
;
91 // Create the custom command to generate the file.
92 cmCustomCommandLine commandLine
;
93 commandLine
.push_back(moc_exe
);
94 commandLine
.push_back("-o");
95 commandLine
.push_back(newName
);
96 commandLine
.push_back(hname
);
98 cmCustomCommandLines commandLines
;
99 commandLines
.push_back(commandLine
);
101 std::vector
<std::string
> depends
;
102 depends
.push_back(moc_exe
);
103 depends
.push_back(hname
);
105 const char* no_main_dependency
= 0;
106 const char* no_working_dir
= 0;
107 this->Makefile
->AddCustomCommandToOutput(newName
.c_str(),
116 // Store the final list of source files.
117 this->Makefile
->AddDefinition(sourceList
.c_str(),
118 sourceListValue
.c_str());