cmMSDotNETGenerator.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  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. enum BuildType {STATIC_LIBRARY, DLL, EXECUTABLE, WIN32_EXECUTABLE, UTILITY};
  28. ///! Constructor sets the generation of SLN files on.
  29. cmMSDotNETGenerator();
  30. ///! Destructor.
  31. ~cmMSDotNETGenerator();
  32. ///! Get the name for the generator.
  33. virtual const char* GetName() {return "Visual Studio 7";}
  34. ///! virtual copy constructor
  35. virtual cmMakefileGenerator* CreateObject()
  36. { return new cmMSDotNETGenerator;}
  37. ///! Produce the makefile (in this case a Microsoft Visual C++ project).
  38. virtual void GenerateMakefile();
  39. ///! controls the SLN/DSP settings
  40. virtual void SetLocal(bool);
  41. /**
  42. * Turn off the generation of a Microsoft Visual C++ SLN file.
  43. * This causes only the dsp file to be created. This
  44. * is used to run as a command line program from inside visual
  45. * studio.
  46. */
  47. void BuildSLNOff() {m_BuildSLN = false;}
  48. ///! Turn on the generation of a Microsoft Visual C++ SLN file.
  49. void BuildProjOn() {m_BuildSLN = true;}
  50. /**
  51. * Try to determine system infomation such as shared library
  52. * extension, pthreads, byte order etc.
  53. */
  54. virtual void ComputeSystemInfo();
  55. protected:
  56. /**
  57. * Specify the type of the build: static, dll, or executable.
  58. */
  59. void SetBuildType(BuildType,const char *name);
  60. /**
  61. * Return array of created VCProj names in a STL vector.
  62. * Each executable must have its own dsp.
  63. */
  64. std::vector<std::string> GetCreatedProjectNames()
  65. {
  66. return m_CreatedProjectNames;
  67. }
  68. /**
  69. * Return the makefile.
  70. */
  71. cmMakefile* GetMakefile()
  72. {
  73. return m_Makefile;
  74. }
  75. private:
  76. void CreateSingleVCProj(const char *lname, cmTarget &tgt);
  77. void WriteVCProjFile(std::ostream& fout, const char *libName,
  78. cmTarget &tgt);
  79. void WriteVCProjBeginGroup(std::ostream& fout,
  80. const char* group,
  81. const char* filter);
  82. void WriteVCProjEndGroup(std::ostream& fout);
  83. void WriteProjectStart(std::ostream& fout, const char *libName,
  84. const cmTarget &tgt, std::vector<cmSourceGroup> &sgs);
  85. void WriteConfigurations(std::ostream& fout,
  86. const char *libName,
  87. const cmTarget &tgt);
  88. void WriteConfiguration(std::ostream& fout,
  89. const char* configName,
  90. const char* libName,
  91. const cmTarget &tgt);
  92. void OutputDefineFlags(std::ostream& fout);
  93. void WriteVCProjFooter(std::ostream& fout);
  94. void AddVCProjBuildRule(cmSourceGroup&);
  95. void WriteCustomRule(std::ostream& fout,
  96. const char* source,
  97. const char* command,
  98. const std::set<std::string>& depends,
  99. const std::set<std::string>& outputs);
  100. std::string CreateTargetRules(const cmTarget &target,
  101. const char *libName);
  102. std::string CombineCommands(const cmSourceGroup::Commands &commands,
  103. cmSourceGroup::CommandFiles &totalCommand,
  104. const char *source);
  105. virtual void OutputSLNFile();
  106. void OutputVCProjFile();
  107. std::string CreateGUID(const char* project);
  108. void WriteSLNFile(std::ostream& fout);
  109. void WriteSLNHeader(std::ostream& fout);
  110. void WriteProject(std::ostream& fout,
  111. const char* name, const char* path,
  112. cmMSDotNETGenerator* project, const cmTarget &t);
  113. void WriteProjectDepends(std::ostream& fout,
  114. const char* name, const char* path,
  115. cmMSDotNETGenerator* project, const cmTarget &t);
  116. void WriteProjectConfigurations(std::ostream& fout, const char* name);
  117. void WriteExternalProject(std::ostream& fout,
  118. const char* name, const char* path,
  119. const std::vector<std::string>& dependencies);
  120. void WriteSLNFooter(std::ostream& fout);
  121. void OutputBuildTool(std::ostream& fout, const char* libname, const cmTarget& t);
  122. private:
  123. std::map<cmStdString, cmStdString> m_GUIDMap;
  124. BuildType m_BuildType;
  125. bool m_BuildSLN;
  126. std::string m_IncludeOptions;
  127. std::vector<std::string> m_Configurations;
  128. std::string m_VCProjHeaderTemplate;
  129. std::string m_VCProjFooterTemplate;
  130. std::vector<std::string> m_CreatedProjectNames;
  131. };
  132. #endif