cmMakefileUtilityTargetGenerator.cxx 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*=========================================================================
  2. Program: CMake - Cross-Platform Makefile Generator
  3. Module: $RCSfile$
  4. Language: C++
  5. Date: $Date$
  6. Version: $Revision$
  7. Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
  8. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
  9. This software is distributed WITHOUT ANY WARRANTY; without even
  10. the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  11. PURPOSE. See the above copyright notices for more information.
  12. =========================================================================*/
  13. #include "cmMakefileUtilityTargetGenerator.h"
  14. #include "cmGeneratedFileStream.h"
  15. #include "cmGlobalGenerator.h"
  16. #include "cmLocalUnixMakefileGenerator3.h"
  17. #include "cmMakefile.h"
  18. #include "cmSourceFile.h"
  19. #include "cmTarget.h"
  20. //----------------------------------------------------------------------------
  21. void cmMakefileUtilityTargetGenerator::WriteRuleFiles()
  22. {
  23. this->CreateRuleFile();
  24. *this->BuildFileStream
  25. << "# Utility rule file for " << this->Target->GetName() << ".\n\n";
  26. // write the custom commands for this target
  27. this->WriteTargetBuildRules();
  28. // Collect the commands and dependencies.
  29. std::vector<std::string> commands;
  30. std::vector<std::string> depends;
  31. // Utility targets store their rules in pre- and post-build commands.
  32. this->LocalGenerator->AppendCustomDepends
  33. (depends, this->Target->GetPreBuildCommands());
  34. this->LocalGenerator->AppendCustomDepends
  35. (depends, this->Target->GetPostBuildCommands());
  36. this->LocalGenerator->AppendCustomCommands
  37. (commands, this->Target->GetPreBuildCommands());
  38. this->LocalGenerator->AppendCustomCommands
  39. (commands, this->Target->GetPostBuildCommands());
  40. // Add dependencies on targets that must be built first.
  41. this->AppendTargetDepends(depends);
  42. // Add a dependency on the rule file itself.
  43. std::string relPath = this->LocalGenerator->GetHomeRelativeOutputPath();
  44. std::string objTarget = relPath;
  45. objTarget += this->BuildFileName;
  46. this->LocalGenerator->AppendRuleDepend(depends, objTarget.c_str());
  47. // Write the rule.
  48. this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0,
  49. this->Target->GetName(),
  50. depends, commands, true);
  51. // Write the main driver rule to build everything in this target.
  52. this->WriteTargetDriverRule(this->Target->GetName(), false);
  53. // Write clean target
  54. this->WriteTargetCleanRules();
  55. // close the streams
  56. this->CloseFileStreams();
  57. }