cmVisualStudioGeneratorOptions.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. file LICENSE.rst or https://cmake.org/licensing for details. */
  3. #pragma once
  4. #include "cmConfigure.h" // IWYU pragma: keep
  5. #include <iosfwd>
  6. #include <string>
  7. #include <cm/optional>
  8. #include "cmGeneratorTarget.h"
  9. #include "cmGlobalVisualStudioGenerator.h"
  10. #include "cmIDEFlagTable.h"
  11. #include "cmIDEOptions.h"
  12. class cmLocalVisualStudioGenerator;
  13. using cmVS7FlagTable = cmIDEFlagTable;
  14. class cmVisualStudioGeneratorOptions : public cmIDEOptions
  15. {
  16. public:
  17. // Construct an options table for a given tool.
  18. enum Tool
  19. {
  20. Compiler,
  21. ResourceCompiler,
  22. CudaCompiler,
  23. MarmasmCompiler,
  24. MasmCompiler,
  25. NasmCompiler,
  26. Linker,
  27. FortranCompiler,
  28. CSharpCompiler
  29. };
  30. cmVisualStudioGeneratorOptions(cmLocalVisualStudioGenerator* lg, Tool tool,
  31. cmVS7FlagTable const* table = nullptr,
  32. cmVS7FlagTable const* extraTable = nullptr);
  33. // Add a table of flags.
  34. void AddTable(cmVS7FlagTable const* table);
  35. // Clear the flag tables.
  36. void ClearTables();
  37. // Store options from command line flags.
  38. void Parse(std::string const& flags);
  39. void ParseFinish();
  40. void PrependInheritedString(std::string const& key);
  41. // Parse the content of the given flag table entry again to extract
  42. // known flags and leave the rest in the original entry.
  43. void Reparse(std::string const& key);
  44. // Fix the ExceptionHandling option to default to off.
  45. void FixExceptionHandlingDefault();
  46. // Store options for verbose builds.
  47. void SetVerboseMakefile(bool verbose);
  48. // Check for specific options.
  49. bool UsingUnicode() const;
  50. bool UsingSBCS() const;
  51. void FixCudaCodeGeneration();
  52. void FixManifestUACFlags();
  53. bool UsingDebugInfo() const;
  54. cm::optional<bool> UsingDebugRuntime() const;
  55. bool IsWinRt() const;
  56. bool IsManaged() const;
  57. // Write options to output.
  58. void OutputPreprocessorDefinitions(std::ostream& fout, int indent,
  59. std::string const& lang);
  60. void OutputAdditionalIncludeDirectories(std::ostream& fout, int indent,
  61. std::string const& lang);
  62. void OutputFlagMap(std::ostream& fout, int indent);
  63. void SetConfiguration(std::string const& config);
  64. std::string const& GetConfiguration() const;
  65. protected:
  66. virtual void OutputFlag(std::ostream& fout, int indent,
  67. std::string const& tag,
  68. std::string const& content) = 0;
  69. private:
  70. cmLocalVisualStudioGenerator* LocalGenerator;
  71. std::string Configuration;
  72. Tool CurrentTool;
  73. bool FortranRuntimeDebug;
  74. bool FortranRuntimeDLL;
  75. bool FortranRuntimeMT;
  76. std::string UnknownFlagField;
  77. mutable cm::optional<cmGeneratorTarget::MsvcCharSet> CachedCharset;
  78. void StoreUnknownFlag(std::string const& flag) override;
  79. FlagValue TakeFlag(std::string const& key);
  80. void CacheCharsetValue() const;
  81. };