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
14 #include "cmLocalVisualStudioGenerator.h"
15 #include "cmVisualStudioGeneratorOptions.h"
17 class cmCustomCommand
;
18 class cmGeneratorTarget
;
19 class cmGlobalGenerator
;
20 class cmLocalVisualStudio7GeneratorFCInfo
;
21 class cmLocalVisualStudio7GeneratorInternals
;
26 class cmVS7GeneratorOptions
: public cmVisualStudioGeneratorOptions
29 cmVS7GeneratorOptions(cmLocalVisualStudioGenerator
* lg
, Tool tool
,
30 cmVS7FlagTable
const* table
= nullptr,
31 cmVS7FlagTable
const* extraTable
= nullptr)
32 : cmVisualStudioGeneratorOptions(lg
, tool
, table
, extraTable
)
35 void OutputFlag(std::ostream
& fout
, int indent
, const std::string
& tag
,
36 const std::string
& content
) override
;
39 /** \class cmLocalVisualStudio7Generator
40 * \brief Write Visual Studio .NET project files.
42 * cmLocalVisualStudio7Generator produces a Visual Studio .NET project
43 * file for each target in its directory.
45 class cmLocalVisualStudio7Generator
: public cmLocalVisualStudioGenerator
48 //! Set cache only and recurse to false by default.
49 cmLocalVisualStudio7Generator(cmGlobalGenerator
* gg
, cmMakefile
* mf
);
51 ~cmLocalVisualStudio7Generator() override
;
53 cmLocalVisualStudio7Generator(const cmLocalVisualStudio7Generator
&) = delete;
54 const cmLocalVisualStudio7Generator
& operator=(
55 const cmLocalVisualStudio7Generator
&) = delete;
57 void AddHelperCommands() override
;
60 * Generate the makefile for this directory.
62 void Generate() override
;
74 * Specify the type of the build: static, dll, or executable.
76 void SetBuildType(BuildType
, const std::string
& name
);
78 std::string
GetTargetDirectory(
79 cmGeneratorTarget
const* target
) const override
;
80 cmSourceFile
* CreateVCProjBuildRule();
81 void WriteStampFiles();
82 std::string
ComputeLongestObjectDirectory(
83 cmGeneratorTarget
const*) const override
;
85 virtual void ReadAndStoreExternalGUID(const std::string
& name
,
88 std::set
<cmSourceFile
const*>& GetSourcesVisited(
89 cmGeneratorTarget
const* target
)
91 return this->SourcesVisited
[target
];
94 bool IsVFProj() const override
{ return this->FortranProject
; }
97 virtual void GenerateTarget(cmGeneratorTarget
* target
);
100 using Options
= cmVS7GeneratorOptions
;
101 using FCInfo
= cmLocalVisualStudio7GeneratorFCInfo
;
102 std::string
GetBuildTypeLinkerFlags(std::string
const& rootLinkerFlags
,
103 const std::string
& configName
);
104 void FixGlobalTargets();
105 void WriteVCProjHeader(std::ostream
& fout
, const std::string
& libName
,
106 cmGeneratorTarget
* tgt
,
107 std::vector
<cmSourceGroup
>& sgs
);
108 void WriteVCProjFooter(std::ostream
& fout
, cmGeneratorTarget
* target
);
109 void WriteVCProjFile(std::ostream
& fout
, const std::string
& libName
,
110 cmGeneratorTarget
* tgt
);
111 void WriteConfigurations(std::ostream
& fout
,
112 std::vector
<std::string
> const& configs
,
113 const std::string
& libName
, cmGeneratorTarget
* tgt
);
114 void WriteConfiguration(std::ostream
& fout
, const std::string
& configName
,
115 const std::string
& libName
, cmGeneratorTarget
* tgt
);
116 std::string
EscapeForXML(const std::string
& s
);
117 std::string
ConvertToXMLOutputPath(const std::string
& path
);
118 std::string
ConvertToXMLOutputPathSingle(const std::string
& path
);
119 void OutputTargetRules(std::ostream
& fout
, const std::string
& configName
,
120 cmGeneratorTarget
* target
,
121 const std::string
& libName
);
122 void OutputBuildTool(std::ostream
& fout
, const std::string
& configName
,
123 cmGeneratorTarget
* t
, const Options
& targetOptions
);
124 void OutputDeploymentDebuggerTool(std::ostream
& fout
,
125 std::string
const& config
,
126 cmGeneratorTarget
* target
);
127 void OutputLibraryDirectories(std::ostream
& fout
,
128 std::vector
<std::string
> const& stdlink
,
129 std::vector
<std::string
> const& dirs
);
130 void WriteProjectSCC(std::ostream
& fout
, cmGeneratorTarget
* target
);
131 void WriteProjectStart(std::ostream
& fout
, const std::string
& libName
,
132 cmGeneratorTarget
* tgt
,
133 std::vector
<cmSourceGroup
>& sgs
);
134 void WriteProjectStartFortran(std::ostream
& fout
, const std::string
& libName
,
135 cmGeneratorTarget
* tgt
);
136 void WriteVCProjBeginGroup(std::ostream
& fout
, const char* group
,
138 void WriteVCProjEndGroup(std::ostream
& fout
);
140 void WriteCustomRule(std::ostream
& fout
,
141 std::vector
<std::string
> const& configs
,
142 const char* source
, const cmCustomCommand
& command
,
144 void WriteTargetVersionAttribute(std::ostream
& fout
, cmGeneratorTarget
* gt
);
146 class AllConfigSources
;
147 bool WriteGroup(const cmSourceGroup
* sg
, cmGeneratorTarget
* target
,
148 std::ostream
& fout
, const std::string
& libName
,
149 std::vector
<std::string
> const& configs
,
150 AllConfigSources
const& sources
);
152 friend class cmLocalVisualStudio7GeneratorFCInfo
;
153 friend class cmLocalVisualStudio7GeneratorInternals
;
157 friend class EventWriter
;
159 bool FortranProject
= false;
160 bool WindowsCEProject
= false;
161 std::unique_ptr
<cmLocalVisualStudio7GeneratorInternals
> Internal
;
163 std::map
<cmGeneratorTarget
const*, std::set
<cmSourceFile
const*>>