cmDependsFortran.h 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. file Copyright.txt or https://cmake.org/licensing for details. */
  3. #ifndef cmFortran_h
  4. #define cmFortran_h
  5. #include "cmConfigure.h" // IWYU pragma: keep
  6. #include <iosfwd>
  7. #include <set>
  8. #include <string>
  9. #include <vector>
  10. #include "cmDepends.h"
  11. class cmDependsFortranInternals;
  12. class cmFortranSourceInfo;
  13. class cmLocalGenerator;
  14. /** \class cmDependsFortran
  15. * \brief Dependency scanner for Fortran object files.
  16. */
  17. class cmDependsFortran : public cmDepends
  18. {
  19. public:
  20. /** Checking instances need to know the build directory name and the
  21. relative path from the build directory to the target file. */
  22. cmDependsFortran();
  23. /** Scanning need to know the build directory name, the relative
  24. path from the build directory to the target file, the source
  25. file from which to start scanning, the include file search
  26. path, and the target directory. */
  27. cmDependsFortran(cmLocalGenerator* lg);
  28. /** Virtual destructor to cleanup subclasses properly. */
  29. ~cmDependsFortran() override;
  30. cmDependsFortran(cmDependsFortran const&) = delete;
  31. cmDependsFortran& operator=(cmDependsFortran const&) = delete;
  32. /** Callback from build system after a .mod file has been generated
  33. by a Fortran90 compiler to copy the .mod file to the
  34. corresponding stamp file. */
  35. static bool CopyModule(const std::vector<std::string>& args);
  36. /** Determine if a mod file and the corresponding mod.stamp file
  37. are representing different module information. */
  38. static bool ModulesDiffer(const std::string& modFile,
  39. const std::string& stampFile,
  40. const std::string& compilerId);
  41. protected:
  42. // Finalize the dependency information for the target.
  43. bool Finalize(std::ostream& makeDepends,
  44. std::ostream& internalDepends) override;
  45. // Find all the modules required by the target.
  46. void LocateModules();
  47. void MatchLocalModules();
  48. void MatchRemoteModules(std::istream& fin, const std::string& stampDir);
  49. void ConsiderModule(const std::string& name, const std::string& stampDir);
  50. bool FindModule(std::string const& name, std::string& module);
  51. // Implement writing/checking methods required by superclass.
  52. bool WriteDependencies(const std::set<std::string>& sources,
  53. const std::string& file, std::ostream& makeDepends,
  54. std::ostream& internalDepends) override;
  55. // Actually write the dependencies to the streams.
  56. bool WriteDependenciesReal(std::string const& obj,
  57. cmFortranSourceInfo const& info,
  58. std::string const& mod_dir,
  59. std::string const& stamp_dir,
  60. std::ostream& makeDepends,
  61. std::ostream& internalDepends);
  62. // The source file from which to start scanning.
  63. std::string SourceFile;
  64. std::string CompilerId;
  65. std::set<std::string> PPDefinitions;
  66. // Internal implementation details.
  67. cmDependsFortranInternals* Internal = nullptr;
  68. private:
  69. std::string MaybeConvertToRelativePath(std::string const& base,
  70. std::string const& path);
  71. };
  72. #endif