1 /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
2 file Copyright.txt or https://cmake.org/licensing for details. */
5 #include "cmConfigure.h" // IWYU pragma: keep
13 #include <cm/optional>
14 #include <cmext/string_view>
16 #include "cmScanDepFormat.h"
18 enum class CxxModuleMapFormat
24 struct CxxModuleLocations
26 // The path from which all relative paths should be computed. If
27 // this is relative, it is relative to the compiler's working
29 std::string RootDirectory;
31 // A function to convert a full path to a path for the generator.
32 std::function<std::string(std::string const&)> PathForGenerator;
34 // Lookup the BMI location of a logical module name.
35 std::function<cm::optional<std::string>(std::string const&)>
38 // Returns the generator path (if known) for the BMI given a
39 // logical module name.
40 cm::optional<std::string> BmiGeneratorPathForModule(
41 std::string const& logical_name) const;
44 struct CxxModuleReference
46 // The path to the module file used.
48 // How the module was looked up.
54 // The usage requirements for this object.
55 std::map<std::string, std::set<std::string>> Usage;
57 // The references for this object.
58 std::map<std::string, CxxModuleReference> Reference;
60 // Add a reference to a module.
62 // Returns `true` if it matches how it was found previously, `false` if it
64 bool AddReference(std::string const& logical, std::string const& loc,
68 // Return the extension to use for a given modulemap format.
69 cm::static_string_view CxxModuleMapExtension(
70 cm::optional<CxxModuleMapFormat> format);
72 // Fill in module usage information for internal usages.
74 // Returns the set of unresolved module usage requirements (these form an
76 std::set<std::string> CxxModuleUsageSeed(
77 CxxModuleLocations const& loc, std::vector<cmScanDepInfo> const& objects,
78 CxxModuleUsage& usages);
80 // Return the contents of the module map in the given format for the
82 std::string CxxModuleMapContent(CxxModuleMapFormat format,
83 CxxModuleLocations const& loc,
84 cmScanDepInfo const& obj,
85 CxxModuleUsage const& usages);