ENH: add submit via cp mode
[cmake.git] / Source / cmMakefileUtilityTargetGenerator.cxx
blob69686f2551e3777e9c71e1c18627d570acfd9d7e
1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmMakefileUtilityTargetGenerator.cxx,v $
5 Language: C++
6 Date: $Date: 2009-02-10 13:50:33 $
7 Version: $Revision: 1.9 $
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 "cmMakefileUtilityTargetGenerator.h"
19 #include "cmGeneratedFileStream.h"
20 #include "cmGlobalUnixMakefileGenerator3.h"
21 #include "cmLocalUnixMakefileGenerator3.h"
22 #include "cmMakefile.h"
23 #include "cmSourceFile.h"
24 #include "cmTarget.h"
26 //----------------------------------------------------------------------------
27 cmMakefileUtilityTargetGenerator
28 ::cmMakefileUtilityTargetGenerator(cmTarget* target):
29 cmMakefileTargetGenerator(target)
31 this->CustomCommandDriver = OnUtility;
34 //----------------------------------------------------------------------------
35 void cmMakefileUtilityTargetGenerator::WriteRuleFiles()
37 this->CreateRuleFile();
39 *this->BuildFileStream
40 << "# Utility rule file for " << this->Target->GetName() << ".\n\n";
42 // write the custom commands for this target
43 this->WriteTargetBuildRules();
45 // Collect the commands and dependencies.
46 std::vector<std::string> commands;
47 std::vector<std::string> depends;
49 // Utility targets store their rules in pre- and post-build commands.
50 this->LocalGenerator->AppendCustomDepends
51 (depends, this->Target->GetPreBuildCommands());
53 this->LocalGenerator->AppendCustomDepends
54 (depends, this->Target->GetPostBuildCommands());
56 this->LocalGenerator->AppendCustomCommands
57 (commands, this->Target->GetPreBuildCommands(), this->Target);
59 // Depend on all custom command outputs for sources
60 this->DriveCustomCommands(depends);
62 this->LocalGenerator->AppendCustomCommands
63 (commands, this->Target->GetPostBuildCommands(), this->Target);
65 // Add dependencies on targets that must be built first.
66 this->AppendTargetDepends(depends);
68 // Add a dependency on the rule file itself.
69 this->LocalGenerator->AppendRuleDepend(depends,
70 this->BuildFileNameFull.c_str());
72 // If the rule is empty add the special empty rule dependency needed
73 // by some make tools.
74 if(depends.empty() && commands.empty())
76 std::string hack = this->GlobalGenerator->GetEmptyRuleHackDepends();
77 if(!hack.empty())
79 depends.push_back(hack);
83 // Write the rule.
84 this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0,
85 this->Target->GetName(),
86 depends, commands, true);
88 // Write the main driver rule to build everything in this target.
89 this->WriteTargetDriverRule(this->Target->GetName(), false);
91 // Write clean target
92 this->WriteTargetCleanRules();
94 // Write the dependency generation rule. This must be done last so
95 // that multiple output pair information is available.
96 this->WriteTargetDependRules();
98 // close the streams
99 this->CloseFileStreams();