cmMSDotNETGenerator.h 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  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 EnableLanguage(const char*);
  54. /**
  55. * Try running cmake and building a file. This is used for dynalically
  56. * loaded commands, not as part of the usual build process. For the
  57. * generator, it can assume that cmake has been run on the srcdir/bindir
  58. * and it just needs to be compiled.
  59. */
  60. virtual int TryCompile(const char *srcdir, const char *bindir,
  61. const char *projectName);
  62. protected:
  63. /**
  64. * Return array of created VCProj names in a STL vector.
  65. * Each executable must have its own dsp.
  66. */
  67. std::vector<std::string> GetCreatedProjectNames()
  68. {
  69. return m_CreatedProjectNames;
  70. }
  71. /**
  72. * Return the makefile.
  73. */
  74. cmMakefile* GetMakefile()
  75. {
  76. return m_Makefile;
  77. }
  78. private:
  79. void CreateSingleVCProj(const char *lname, cmTarget &tgt);
  80. void WriteVCProjFile(std::ostream& fout, const char *libName,
  81. cmTarget &tgt);
  82. void WriteVCProjBeginGroup(std::ostream& fout,
  83. const char* group,
  84. const char* filter);
  85. void WriteVCProjEndGroup(std::ostream& fout);
  86. void WriteProjectStart(std::ostream& fout, const char *libName,
  87. const cmTarget &tgt, std::vector<cmSourceGroup> &sgs);
  88. void WriteConfigurations(std::ostream& fout,
  89. const char *libName,
  90. const cmTarget &tgt);
  91. void WriteConfiguration(std::ostream& fout,
  92. const char* configName,
  93. const char* libName,
  94. const cmTarget &tgt);
  95. void OutputDefineFlags(std::ostream& fout);
  96. void WriteVCProjFooter(std::ostream& fout);
  97. void AddVCProjBuildRule(cmSourceGroup&);
  98. void WriteCustomRule(std::ostream& fout,
  99. const char* source,
  100. const char* command,
  101. const std::set<std::string>& depends,
  102. const std::set<std::string>& outputs,
  103. const char* extraFlags);
  104. void OutputTargetRules(std::ostream& fout,
  105. const cmTarget &target,
  106. const char *libName);
  107. std::string CombineCommands(const cmSourceGroup::Commands &commands,
  108. cmSourceGroup::CommandFiles &totalCommand,
  109. const char *source);
  110. virtual void OutputSLNFile();
  111. void OutputVCProjFile();
  112. std::string CreateGUID(const char* project);
  113. void WriteSLNFile(std::ostream& fout);
  114. void WriteSLNHeader(std::ostream& fout);
  115. void WriteProject(std::ostream& fout,
  116. const char* name, const char* path,
  117. cmMSDotNETGenerator* project, const cmTarget &t);
  118. void WriteProjectDepends(std::ostream& fout,
  119. const char* name, const char* path,
  120. cmMSDotNETGenerator* project, const cmTarget &t);
  121. void WriteProjectConfigurations(std::ostream& fout, const char* name);
  122. void WriteExternalProject(std::ostream& fout,
  123. const char* name, const char* path,
  124. const std::vector<std::string>& dependencies);
  125. void WriteSLNFooter(std::ostream& fout);
  126. void OutputBuildTool(std::ostream& fout, const char* configName,
  127. const char* libname, const cmTarget& t);
  128. void OutputLibraryDirectories(std::ostream& fout,
  129. const char* configName,
  130. const char* libName,
  131. const cmTarget &target);
  132. void OutputModuleDefinitionFile(std::ostream& fout,
  133. const cmTarget &target);
  134. void OutputLibraries(std::ostream& fout,
  135. const char* configName,
  136. const char* libName,
  137. const cmTarget &target);
  138. std::string ConvertToXMLOutputPath(const char* path);
  139. std::string ConvertToXMLOutputPathSingle(const char* path);
  140. private:
  141. std::map<cmStdString, cmStdString> m_GUIDMap;
  142. bool m_BuildSLN;
  143. std::string m_LibraryOutputPath;
  144. std::string m_ExecutableOutputPath;
  145. std::string m_ModuleDefinitionFile;
  146. std::vector<std::string> m_Configurations;
  147. std::string m_VCProjHeaderTemplate;
  148. std::string m_VCProjFooterTemplate;
  149. std::vector<std::string> m_CreatedProjectNames;
  150. };
  151. #endif