cmCommonTargetGenerator.h 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /*============================================================================
  2. CMake - Cross Platform Makefile Generator
  3. Copyright 2000-2015 Kitware, Inc., Insight Software Consortium
  4. Distributed under the OSI-approved BSD License (the "License");
  5. see accompanying file Copyright.txt for details.
  6. This software is distributed WITHOUT ANY WARRANTY; without even the
  7. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  8. See the License for more information.
  9. ============================================================================*/
  10. #ifndef cmCommonTargetGenerator_h
  11. #define cmCommonTargetGenerator_h
  12. #include "cmStandardIncludes.h"
  13. #include "cmLocalGenerator.h"
  14. class cmGeneratorTarget;
  15. class cmGlobalCommonGenerator;
  16. class cmLocalCommonGenerator;
  17. class cmMakefile;
  18. class cmSourceFile;
  19. class cmTarget;
  20. /** \class cmCommonTargetGenerator
  21. * \brief Common infrastructure for Makefile and Ninja per-target generators
  22. */
  23. class cmCommonTargetGenerator
  24. {
  25. public:
  26. cmCommonTargetGenerator(cmOutputConverter::RelativeRoot wd,
  27. cmGeneratorTarget* gt);
  28. virtual ~cmCommonTargetGenerator();
  29. std::string const& GetConfigName() const;
  30. protected:
  31. // Add language feature flags.
  32. void AddFeatureFlags(std::string& flags, const std::string& lang);
  33. // Feature query methods.
  34. const char* GetFeature(const std::string& feature);
  35. bool GetFeatureAsBool(const std::string& feature);
  36. // Helper to add flag for windows .def file.
  37. void AddModuleDefinitionFlag(std::string& flags);
  38. cmOutputConverter::RelativeRoot WorkingDirectory;
  39. cmGeneratorTarget* GeneratorTarget;
  40. cmTarget* Target;
  41. cmMakefile* Makefile;
  42. cmLocalCommonGenerator* LocalGenerator;
  43. cmGlobalCommonGenerator* GlobalGenerator;
  44. std::string ConfigName;
  45. // The windows module definition source file (.def), if any.
  46. std::string ModuleDefinitionFile;
  47. // Target-wide Fortran module output directory.
  48. bool FortranModuleDirectoryComputed;
  49. std::string FortranModuleDirectory;
  50. std::string GetFortranModuleDirectory();
  51. // Compute target-specific Fortran language flags.
  52. void AddFortranFlags(std::string& flags);
  53. std::string Convert(std::string const& source,
  54. cmLocalGenerator::RelativeRoot relative,
  55. cmLocalGenerator::OutputFormat output =
  56. cmLocalGenerator::UNCHANGED);
  57. void AppendFortranFormatFlags(std::string& flags,
  58. cmSourceFile const& source);
  59. // Return the a string with -F flags on apple
  60. std::string GetFrameworkFlags(std::string const& l);
  61. virtual void AddIncludeFlags(std::string& flags,
  62. std::string const& lang) = 0;
  63. typedef std::map<std::string, std::string> ByLanguageMap;
  64. std::string GetFlags(const std::string &l);
  65. ByLanguageMap FlagsByLanguage;
  66. std::string GetDefines(const std::string &l);
  67. ByLanguageMap DefinesByLanguage;
  68. std::string GetIncludes(std::string const& l);
  69. ByLanguageMap IncludesByLanguage;
  70. std::vector<std::string> GetLinkedTargetDirectories() const;
  71. };
  72. #endif