Resync
[CMakeLuaTailorHgBridge.git] / CMakeLua / Source / cmMakefileUtilityTargetGenerator.cxx
blob8391b789b74ba23bcf5df01ada7e144f9956dbd2
1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmMakefileUtilityTargetGenerator.cxx,v $
5 Language: C++
6 <<<<<<< cmMakefileUtilityTargetGenerator.cxx
7 Date: $Date: 2008/02/18 21:38:34 $
8 Version: $Revision: 1.8 $
9 =======
10 Date: $Date: 2009-02-10 13:50:33 $
11 Version: $Revision: 1.9 $
12 >>>>>>> 1.9
14 Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
15 See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
17 This software is distributed WITHOUT ANY WARRANTY; without even
18 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
19 PURPOSE. See the above copyright notices for more information.
21 =========================================================================*/
22 #include "cmMakefileUtilityTargetGenerator.h"
24 #include "cmGeneratedFileStream.h"
25 #include "cmGlobalUnixMakefileGenerator3.h"
26 #include "cmLocalUnixMakefileGenerator3.h"
27 #include "cmMakefile.h"
28 #include "cmSourceFile.h"
29 #include "cmTarget.h"
31 //----------------------------------------------------------------------------
32 cmMakefileUtilityTargetGenerator
33 ::cmMakefileUtilityTargetGenerator(cmTarget* target):
34 cmMakefileTargetGenerator(target)
36 this->CustomCommandDriver = OnUtility;
39 //----------------------------------------------------------------------------
40 void cmMakefileUtilityTargetGenerator::WriteRuleFiles()
42 this->CreateRuleFile();
44 *this->BuildFileStream
45 << "# Utility rule file for " << this->Target->GetName() << ".\n\n";
47 // write the custom commands for this target
48 this->WriteTargetBuildRules();
50 // Collect the commands and dependencies.
51 std::vector<std::string> commands;
52 std::vector<std::string> depends;
54 // Utility targets store their rules in pre- and post-build commands.
55 this->LocalGenerator->AppendCustomDepends
56 (depends, this->Target->GetPreBuildCommands());
58 this->LocalGenerator->AppendCustomDepends
59 (depends, this->Target->GetPostBuildCommands());
61 this->LocalGenerator->AppendCustomCommands
62 (commands, this->Target->GetPreBuildCommands(), this->Target);
64 // Depend on all custom command outputs for sources
65 this->DriveCustomCommands(depends);
67 this->LocalGenerator->AppendCustomCommands
68 (commands, this->Target->GetPostBuildCommands(), this->Target);
70 // Add dependencies on targets that must be built first.
71 this->AppendTargetDepends(depends);
73 // Add a dependency on the rule file itself.
74 this->LocalGenerator->AppendRuleDepend(depends,
75 this->BuildFileNameFull.c_str());
77 // If the rule is empty add the special empty rule dependency needed
78 // by some make tools.
79 if(depends.empty() && commands.empty())
81 std::string hack = this->GlobalGenerator->GetEmptyRuleHackDepends();
82 if(!hack.empty())
84 depends.push_back(hack);
88 // Write the rule.
89 this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0,
90 this->Target->GetName(),
91 depends, commands, true);
93 // Write the main driver rule to build everything in this target.
94 this->WriteTargetDriverRule(this->Target->GetName(), false);
96 // Write clean target
97 this->WriteTargetCleanRules();
99 // Write the dependency generation rule. This must be done last so
100 // that multiple output pair information is available.
101 this->WriteTargetDependRules();
103 // close the streams
104 this->CloseFileStreams();