1 /* Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
2    file Copyright.txt or https://cmake.org/licensing for details.  */
3 #pragma once
4 
5 #include "cmConfigure.h" // IWYU pragma: keep
6 
7 #include <map>
8 #include <string>
9 #include <vector>
10 
11 #include "cmLocalGenerator.h"
12 
13 class cmGeneratorTarget;
14 class cmGlobalGenerator;
15 class cmMakefile;
16 class cmSourceFile;
17 
18 /** \class cmLocalCommonGenerator
19  * \brief Common infrastructure for Makefile and Ninja local generators.
20  */
21 class cmLocalCommonGenerator : public cmLocalGenerator
22 {
23 protected:
24   enum class WorkDir
25   {
26     TopBin,
27     CurBin,
28   };
29 
30 public:
31   cmLocalCommonGenerator(cmGlobalGenerator* gg, cmMakefile* mf, WorkDir wd);
32   ~cmLocalCommonGenerator() override;
33 
GetConfigNames()34   std::vector<std::string> const& GetConfigNames() const
35   {
36     return this->ConfigNames;
37   }
38 
39   std::string const& GetWorkingDirectory() const;
40 
41   std::string MaybeRelativeToWorkDir(std::string const& path) const;
42 
43   std::string GetTargetFortranFlags(cmGeneratorTarget const* target,
44                                     std::string const& config) override;
45 
46   void ComputeObjectFilenames(
47     std::map<cmSourceFile const*, std::string>& mapping,
48     cmGeneratorTarget const* gt = nullptr) override;
49 
50 protected:
51   WorkDir WorkingDirectory;
52 
53   std::vector<std::string> ConfigNames;
54 
55   friend class cmCommonTargetGenerator;
56 };
57