1
0

cmMSDotNETGenerator.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. /*=========================================================================
  2. Program: Insight Segmentation & Registration Toolkit
  3. Module: $RCSfile$
  4. Language: C++
  5. Date: $Date$
  6. Version: $Revision$
  7. Copyright (c) 2002 Insight Consortium. All rights reserved.
  8. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm 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. #ifndef cmMSDotNETGenerator_h
  14. #define cmMSDotNETGenerator_h
  15. #include "cmStandardIncludes.h"
  16. #include "cmMakefileGenerator.h"
  17. #include "cmTarget.h"
  18. #include "cmSourceGroup.h"
  19. /** \class cmMSDotNETGenerator
  20. * \brief Write a Microsoft Visual C++ DSP (project) file.
  21. *
  22. * cmMSDotNETGenerator produces a Microsoft Visual C++ DSP (project) file.
  23. */
  24. class cmMSDotNETGenerator : public cmMakefileGenerator
  25. {
  26. public:
  27. ///! Constructor sets the generation of SLN files on.
  28. cmMSDotNETGenerator();
  29. ///! Destructor.
  30. ~cmMSDotNETGenerator();
  31. ///! Get the name for the generator.
  32. virtual const char* GetName() {return "Visual Studio 7";}
  33. ///! virtual copy constructor
  34. virtual cmMakefileGenerator* CreateObject()
  35. { return new cmMSDotNETGenerator;}
  36. ///! Produce the makefile (in this case a Microsoft Visual C++ project).
  37. virtual void GenerateMakefile();
  38. ///! controls the SLN/DSP settings
  39. virtual void SetLocal(bool);
  40. /**
  41. * Turn off the generation of a Microsoft Visual C++ SLN file.
  42. * This causes only the dsp file to be created. This
  43. * is used to run as a command line program from inside visual
  44. * studio.
  45. */
  46. void BuildSLNOff() {m_BuildSLN = false;}
  47. ///! Turn on the generation of a Microsoft Visual C++ SLN file.
  48. void BuildProjOn() {m_BuildSLN = true;}
  49. /**
  50. * Try to determine system infomation such as shared library
  51. * extension, pthreads, byte order etc.
  52. */
  53. virtual void ComputeSystemInfo();
  54. protected:
  55. /**
  56. * Return array of created VCProj names in a STL vector.
  57. * Each executable must have its own dsp.
  58. */
  59. std::vector<std::string> GetCreatedProjectNames()
  60. {
  61. return m_CreatedProjectNames;
  62. }
  63. /**
  64. * Return the makefile.
  65. */
  66. cmMakefile* GetMakefile()
  67. {
  68. return m_Makefile;
  69. }
  70. private:
  71. void CreateSingleVCProj(const char *lname, cmTarget &tgt);
  72. void WriteVCProjFile(std::ostream& fout, const char *libName,
  73. cmTarget &tgt);
  74. void WriteVCProjBeginGroup(std::ostream& fout,
  75. const char* group,
  76. const char* filter);
  77. void WriteVCProjEndGroup(std::ostream& fout);
  78. void WriteProjectStart(std::ostream& fout, const char *libName,
  79. const cmTarget &tgt, std::vector<cmSourceGroup> &sgs);
  80. void WriteConfigurations(std::ostream& fout,
  81. const char *libName,
  82. const cmTarget &tgt);
  83. void WriteConfiguration(std::ostream& fout,
  84. const char* configName,
  85. const char* libName,
  86. const cmTarget &tgt);
  87. void OutputDefineFlags(std::ostream& fout);
  88. void WriteVCProjFooter(std::ostream& fout);
  89. void AddVCProjBuildRule(cmSourceGroup&);
  90. void WriteCustomRule(std::ostream& fout,
  91. const char* source,
  92. const char* command,
  93. const std::set<std::string>& depends,
  94. const std::set<std::string>& outputs,
  95. const char* extraFlags);
  96. void OutputTargetRules(std::ostream& fout,
  97. const cmTarget &target,
  98. const char *libName);
  99. std::string CombineCommands(const cmSourceGroup::Commands &commands,
  100. cmSourceGroup::CommandFiles &totalCommand,
  101. const char *source);
  102. virtual void OutputSLNFile();
  103. void OutputVCProjFile();
  104. std::string CreateGUID(const char* project);
  105. void WriteSLNFile(std::ostream& fout);
  106. void WriteSLNHeader(std::ostream& fout);
  107. void WriteProject(std::ostream& fout,
  108. const char* name, const char* path,
  109. cmMSDotNETGenerator* project, const cmTarget &t);
  110. void WriteProjectDepends(std::ostream& fout,
  111. const char* name, const char* path,
  112. cmMSDotNETGenerator* project, const cmTarget &t);
  113. void WriteProjectConfigurations(std::ostream& fout, const char* name);
  114. void WriteExternalProject(std::ostream& fout,
  115. const char* name, const char* path,
  116. const std::vector<std::string>& dependencies);
  117. void WriteSLNFooter(std::ostream& fout);
  118. void OutputBuildTool(std::ostream& fout, const char* configName,
  119. const char* libname, const cmTarget& t);
  120. void OutputLibraryDirectories(std::ostream& fout,
  121. const char* configName,
  122. const char* libName,
  123. const cmTarget &target);
  124. void OutputModuleDefinitionFile(std::ostream& fout,
  125. const cmTarget &target);
  126. void OutputLibraries(std::ostream& fout,
  127. const char* configName,
  128. const char* libName,
  129. const cmTarget &target);
  130. std::string ConvertToXMLOutputPath(const char* path);
  131. private:
  132. std::map<cmStdString, cmStdString> m_GUIDMap;
  133. bool m_BuildSLN;
  134. std::string m_LibraryOutputPath;
  135. std::string m_ExecutableOutputPath;
  136. std::string m_ModuleDefinitionFile;
  137. std::vector<std::string> m_Configurations;
  138. std::string m_VCProjHeaderTemplate;
  139. std::string m_VCProjFooterTemplate;
  140. std::vector<std::string> m_CreatedProjectNames;
  141. };
  142. #endif