cmDependsFortran.h 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. CM_DISABLE_COPY(cmDependsFortran)
  20. public:
  21. /** Checking instances need to know the build directory name and the
  22. relative path from the build directory to the target file. */
  23. cmDependsFortran();
  24. /** Scanning need to know the build directory name, the relative
  25. path from the build directory to the target file, the source
  26. file from which to start scanning, the include file search
  27. path, and the target directory. */
  28. cmDependsFortran(cmLocalGenerator* lg);
  29. /** Virtual destructor to cleanup subclasses properly. */
  30. ~cmDependsFortran() override;
  31. /** Callback from build system after a .mod file has been generated
  32. by a Fortran90 compiler to copy the .mod file to the
  33. corresponding stamp file. */
  34. static bool CopyModule(const std::vector<std::string>& args);
  35. /** Determine if a mod file and the corresponding mod.stamp file
  36. are representing different module information. */
  37. static bool ModulesDiffer(const char* modFile, const char* stampFile,
  38. const char* compilerId);
  39. protected:
  40. // Finalize the dependency information for the target.
  41. bool Finalize(std::ostream& makeDepends,
  42. std::ostream& internalDepends) override;
  43. // Find all the modules required by the target.
  44. void LocateModules();
  45. void MatchLocalModules();
  46. void MatchRemoteModules(std::istream& fin, const char* stampDir);
  47. void ConsiderModule(const char* name, const char* stampDir);
  48. bool FindModule(std::string const& name, std::string& module);
  49. // Implement writing/checking methods required by superclass.
  50. bool WriteDependencies(const std::set<std::string>& sources,
  51. const std::string& file, std::ostream& makeDepends,
  52. std::ostream& internalDepends) override;
  53. // Actually write the dependencies to the streams.
  54. bool WriteDependenciesReal(const char* obj, cmFortranSourceInfo const& info,
  55. std::string const& mod_dir, const char* stamp_dir,
  56. std::ostream& makeDepends,
  57. std::ostream& internalDepends);
  58. // The source file from which to start scanning.
  59. std::string SourceFile;
  60. std::set<std::string> PPDefinitions;
  61. // Internal implementation details.
  62. cmDependsFortranInternals* Internal;
  63. private:
  64. std::string MaybeConvertToRelativePath(std::string const& base,
  65. std::string const& path);
  66. };
  67. #endif