cmMakefile.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. /*=========================================================================
  2. Program: Insight Segmentation & Registration Toolkit
  3. Module: $RCSfile$
  4. Language: C++
  5. Date: $Date$
  6. Version: $Revision$
  7. Copyright (c) 2000 National Library of Medicine
  8. All rights reserved.
  9. See COPYRIGHT.txt for copyright details.
  10. =========================================================================*/
  11. /**
  12. * cmMakefile - used to parse and store the contents of a
  13. * CMakeLists.txt makefile in memory.
  14. */
  15. #ifndef cmMakefile_h
  16. #define cmMakefile_h
  17. #ifdef _MSC_VER
  18. #pragma warning ( disable : 4786 )
  19. #endif
  20. #include "cmClassFile.h"
  21. #include "cmCollectFlags.h"
  22. #include <vector>
  23. #include <fstream>
  24. #include <iostream>
  25. class cmMakefile
  26. {
  27. public:
  28. cmMakefile();
  29. // Parse a Makfile.in file
  30. bool ReadMakefile(const char* makefile);
  31. // Print useful stuff to stdout
  32. void Print();
  33. // Set the home directory for the project
  34. void SetHomeDirectory(const char* dir)
  35. {
  36. m_cmHomeDirectory = dir;
  37. }
  38. const char* GetHomeDirectory()
  39. {
  40. return m_cmHomeDirectory.c_str();
  41. }
  42. // Set the current directory in the project
  43. void SetCurrentDirectory(const char* dir)
  44. {
  45. m_cmCurrentDirectory = dir;
  46. }
  47. const char* GetCurrentDirectory()
  48. {
  49. return m_cmCurrentDirectory.c_str();
  50. }
  51. // Set the name of the library that is built by this makefile
  52. void SetLibraryName(const char* lib)
  53. {
  54. m_LibraryName = lib;
  55. }
  56. const char* GetLibraryName()
  57. {
  58. return m_LibraryName.c_str();
  59. }
  60. // Set the name of the library that is built by this makefile
  61. void SetProjectName(const char* lib)
  62. {
  63. m_ProjectName = lib;
  64. }
  65. const char* GetProjectName()
  66. {
  67. return m_ProjectName.c_str();
  68. }
  69. // Set the name of the library that is built by this makefile
  70. void SetOutputDirectory(const char* lib)
  71. {
  72. m_OutputDirectory = lib;
  73. }
  74. const char* GetOutputDirectory()
  75. {
  76. return m_OutputDirectory.c_str();
  77. }
  78. // Set the name of the library that is built by this makefile
  79. void SetOutputHomeDirectory(const char* lib)
  80. {
  81. m_OutputHomeDirectory = lib;
  82. }
  83. const char* GetOutputHomeDirectory()
  84. {
  85. return m_OutputHomeDirectory.c_str();
  86. }
  87. cmCollectFlags& GetBuildFlags()
  88. {
  89. return m_BuildFlags;
  90. }
  91. const std::vector<std::string>& GetSubDirectories()
  92. {
  93. return m_SubDirectories;
  94. }
  95. bool HasExecutables()
  96. {
  97. return m_Executables;
  98. }
  99. private:
  100. void ReadTemplateInstanceDirectory(std::string&);
  101. void ReadClasses(std::ifstream& fin, bool t);
  102. friend class cmMakeDepend; // make depend needs direct access
  103. // to the m_Classes array
  104. protected:
  105. bool m_Executables;
  106. std::string m_Prefix;
  107. std::vector<std::string> m_TemplateDirectories; // Template directory name if found in file
  108. std::string m_OutputDirectory; // Current output directory for makefile
  109. std::string m_OutputHomeDirectory; // Top level output directory
  110. std::string m_cmHomeDirectory; // Home directory for source
  111. std::string m_cmCurrentDirectory; // current directory in source
  112. std::string m_LibraryName; // library name
  113. std::string m_ProjectName; // project name
  114. std::vector<cmClassFile> m_Classes; // list of classes in makefile
  115. std::vector<std::string> m_SubDirectories; // list of sub directories
  116. std::vector<std::string> m_MakeVerbatim; // lines copied from input file
  117. cmCollectFlags m_BuildFlags;
  118. };
  119. #endif