diff --git a/Source/cmGlobalVisualStudio14Generator.cxx b/Source/cmGlobalVisualStudio14Generator.cxx index 5c526c7280..2cebf6e478 100644 --- a/Source/cmGlobalVisualStudio14Generator.cxx +++ b/Source/cmGlobalVisualStudio14Generator.cxx @@ -568,7 +568,7 @@ void cmGlobalVisualStudio14Generator::AddSolutionItems(cmLocalGenerator* root, } void cmGlobalVisualStudio14Generator::WriteFolderSolutionItems( - std::ostream& fout, cmVisualStudioFolder const& folder) + std::ostream& fout, cmVisualStudioFolder const& folder) const { fout << "\tProjectSection(SolutionItems) = preProject\n"; diff --git a/Source/cmGlobalVisualStudio14Generator.h b/Source/cmGlobalVisualStudio14Generator.h index 3f73574eec..a71326f934 100644 --- a/Source/cmGlobalVisualStudio14Generator.h +++ b/Source/cmGlobalVisualStudio14Generator.h @@ -68,8 +68,8 @@ protected: void AddSolutionItems(cmLocalGenerator* root, VSFolders& vsFolders) override; - void WriteFolderSolutionItems(std::ostream& fout, - cmVisualStudioFolder const& folder) override; + void WriteFolderSolutionItems( + std::ostream& fout, cmVisualStudioFolder const& folder) const override; private: class Factory; diff --git a/Source/cmGlobalVisualStudio71Generator.cxx b/Source/cmGlobalVisualStudio71Generator.cxx index 5f00bda01c..0abce6bf10 100644 --- a/Source/cmGlobalVisualStudio71Generator.cxx +++ b/Source/cmGlobalVisualStudio71Generator.cxx @@ -26,7 +26,7 @@ cmGlobalVisualStudio71Generator::cmGlobalVisualStudio71Generator(cmake* cm) void cmGlobalVisualStudio71Generator::WriteSLNFile( std::ostream& fout, cmLocalGenerator* root, OrderedTargetDependSet const& orderedProjectTargets, - VSFolders const& vsFolders) + VSFolders const& vsFolders) const { std::vector configs = root->GetMakefile()->GetGeneratorConfigs(cmMakefile::ExcludeEmptyConfig); @@ -67,7 +67,7 @@ void cmGlobalVisualStudio71Generator::WriteSLNFile( } void cmGlobalVisualStudio71Generator::WriteSolutionConfigurations( - std::ostream& fout, std::vector const& configs) + std::ostream& fout, std::vector const& configs) const { fout << "\tGlobalSection(SolutionConfiguration) = preSolution\n"; for (std::string const& i : configs) { @@ -79,10 +79,9 @@ void cmGlobalVisualStudio71Generator::WriteSolutionConfigurations( // Write a dsp file into the SLN file, // Note, that dependencies from executables to // the libraries it uses are also done here -void cmGlobalVisualStudio71Generator::WriteProject(std::ostream& fout, - std::string const& dspname, - std::string const& dir, - cmGeneratorTarget const* t) +void cmGlobalVisualStudio71Generator::WriteProject( + std::ostream& fout, std::string const& dspname, std::string const& dir, + cmGeneratorTarget const* t) const { // check to see if this is a fortran build std::string ext = ".vcproj"; @@ -133,9 +132,11 @@ void cmGlobalVisualStudio71Generator::WriteProject(std::ostream& fout, // the libraries it uses are also done here void cmGlobalVisualStudio71Generator::WriteProjectDepends( std::ostream& fout, std::string const&, std::string const&, - cmGeneratorTarget const* target) + cmGeneratorTarget const* target) const { - VSDependSet const& depends = this->VSTargetDepends[target]; + auto i = this->VSTargetDepends.find(target); + assert(i != this->VSTargetDepends.end()); + VSDependSet const& depends = i->second; for (std::string const& name : depends) { std::string guid = this->GetGUID(name); if (guid.empty()) { @@ -151,7 +152,8 @@ void cmGlobalVisualStudio71Generator::WriteProjectDepends( // executables to the libraries it uses are also done here void cmGlobalVisualStudio71Generator::WriteExternalProject( std::ostream& fout, std::string const& name, std::string const& location, - cmValue typeGuid, std::set>> const& depends) + cmValue typeGuid, + std::set>> const& depends) const { fout << "Project(\"{" << (typeGuid ? *typeGuid @@ -185,7 +187,7 @@ void cmGlobalVisualStudio71Generator::WriteProjectConfigurations( std::ostream& fout, std::string const& name, cmGeneratorTarget const& target, std::vector const& configs, std::set const& configsPartOfDefaultBuild, - std::string const& platformMapping) + std::string const& platformMapping) const { std::string const& platformName = !platformMapping.empty() ? platformMapping : this->GetPlatformName(); diff --git a/Source/cmGlobalVisualStudio71Generator.h b/Source/cmGlobalVisualStudio71Generator.h index d25b52087e..0d0e83881d 100644 --- a/Source/cmGlobalVisualStudio71Generator.h +++ b/Source/cmGlobalVisualStudio71Generator.h @@ -30,24 +30,24 @@ public: protected: void WriteSLNFile(std::ostream& fout, cmLocalGenerator* root, OrderedTargetDependSet const& orderedProjectTargets, - VSFolders const& vsFolders) override; + VSFolders const& vsFolders) const override; virtual void WriteSolutionConfigurations( - std::ostream& fout, std::vector const& configs); + std::ostream& fout, std::vector const& configs) const; void WriteProject(std::ostream& fout, std::string const& name, std::string const& path, - cmGeneratorTarget const* t) override; + cmGeneratorTarget const* t) const override; void WriteProjectDepends(std::ostream& fout, std::string const& name, std::string const& path, - cmGeneratorTarget const* t) override; + cmGeneratorTarget const* t) const override; void WriteProjectConfigurations( std::ostream& fout, std::string const& name, cmGeneratorTarget const& target, std::vector const& configs, std::set const& configsPartOfDefaultBuild, - std::string const& platformMapping = "") override; + std::string const& platformMapping = "") const override; void WriteExternalProject( std::ostream& fout, std::string const& name, std::string const& path, cmValue typeGuid, - std::set>> const& depends) override; + std::set>> const& depends) const override; // Folders are not supported by VS 7.1. bool UseFolderProperty() const override { return false; } diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx index e52eca20d6..9fe69ee569 100644 --- a/Source/cmGlobalVisualStudio7Generator.cxx +++ b/Source/cmGlobalVisualStudio7Generator.cxx @@ -350,7 +350,7 @@ void cmGlobalVisualStudio7Generator::OutputSLNFile() void cmGlobalVisualStudio7Generator::WriteTargetConfigurations( std::ostream& fout, std::vector const& configs, - OrderedTargetDependSet const& projectTargets) + OrderedTargetDependSet const& projectTargets) const { // loop over again and write out configurations for each target // in the solution @@ -443,7 +443,7 @@ cmVisualStudioFolder* cmGlobalVisualStudio7Generator::VSFolders::Create( void cmGlobalVisualStudio7Generator::WriteTargetsToSolution( std::ostream& fout, cmLocalGenerator* root, - OrderedTargetDependSet const& projectTargets) + OrderedTargetDependSet const& projectTargets) const { std::vector configs = root->GetMakefile()->GetGeneratorConfigs(cmMakefile::ExcludeEmptyConfig); @@ -476,8 +476,8 @@ void cmGlobalVisualStudio7Generator::WriteTargetsToSolution( } } -void cmGlobalVisualStudio7Generator::WriteFolders(std::ostream& fout, - VSFolders const& vsFolders) +void cmGlobalVisualStudio7Generator::WriteFolders( + std::ostream& fout, VSFolders const& vsFolders) const { cm::string_view const prefix = "CMAKE_FOLDER_GUID_"; std::string guidProjectTypeFolder = "2150E333-8FDC-42A3-9474-1A3956D46DE8"; @@ -504,7 +504,7 @@ void cmGlobalVisualStudio7Generator::WriteFolders(std::ostream& fout, } void cmGlobalVisualStudio7Generator::WriteFoldersContent( - std::ostream& fout, VSFolders const& vsFolders) + std::ostream& fout, VSFolders const& vsFolders) const { for (auto const& iter : vsFolders.Folders) { std::string key(iter.first); @@ -520,7 +520,7 @@ void cmGlobalVisualStudio7Generator::WriteFoldersContent( } std::string cmGlobalVisualStudio7Generator::ConvertToSolutionPath( - std::string const& path) + std::string const& path) const { // Convert to backslashes. Do not use ConvertToOutputPath because // we will add quoting ourselves, and we know these projects always @@ -534,7 +534,7 @@ std::string cmGlobalVisualStudio7Generator::ConvertToSolutionPath( } void cmGlobalVisualStudio7Generator::WriteSLNGlobalSections( - std::ostream& fout, cmLocalGenerator* root) + std::ostream& fout, cmLocalGenerator* root) const { std::string const guid = this->GetGUID(cmStrCat(root->GetProjectName(), ".sln")); @@ -600,7 +600,7 @@ void cmGlobalVisualStudio7Generator::WriteSLNGlobalSections( } // Standard end of dsw file -void cmGlobalVisualStudio7Generator::WriteSLNFooter(std::ostream& fout) +void cmGlobalVisualStudio7Generator::WriteSLNFooter(std::ostream& fout) const { fout << "EndGlobal\n"; } @@ -668,7 +668,8 @@ std::string cmGlobalVisualStudio7Generator::WriteUtilityDepend( return pname; } -std::string cmGlobalVisualStudio7Generator::GetGUID(std::string const& name) +std::string cmGlobalVisualStudio7Generator::GetGUID( + std::string const& name) const { std::string const& guidStoreName = cmStrCat(name, "_GUID_CMAKE"); if (cmValue storedGUID = @@ -702,7 +703,7 @@ void cmGlobalVisualStudio7Generator::AppendDirectoryForConfig( std::set cmGlobalVisualStudio7Generator::IsPartOfDefaultBuild( std::vector const& configs, OrderedTargetDependSet const& projectTargets, - cmGeneratorTarget const* target) + cmGeneratorTarget const* target) const { std::set activeConfigs; // if it is a utility target then only make it part of the @@ -745,7 +746,8 @@ std::set cmGlobalVisualStudio7Generator::IsPartOfDefaultBuild( } bool cmGlobalVisualStudio7Generator::IsDependedOn( - OrderedTargetDependSet const& projectTargets, cmGeneratorTarget const* gtIn) + OrderedTargetDependSet const& projectTargets, + cmGeneratorTarget const* gtIn) const { return std::any_of(projectTargets.begin(), projectTargets.end(), [this, gtIn](cmTargetDepend const& l) { diff --git a/Source/cmGlobalVisualStudio7Generator.h b/Source/cmGlobalVisualStudio7Generator.h index f1ae133b23..f35f6c6b60 100644 --- a/Source/cmGlobalVisualStudio7Generator.h +++ b/Source/cmGlobalVisualStudio7Generator.h @@ -88,7 +88,7 @@ public: virtual void OutputSLNFile(); //! Lookup a stored GUID or compute one deterministically. - std::string GetGUID(std::string const& name); + std::string GetGUID(std::string const& name) const; /** Append the subdirectory for the given configuration. */ void AppendDirectoryForConfig(std::string const& prefix, @@ -150,21 +150,21 @@ protected: virtual void WriteSLNFile( std::ostream& fout, cmLocalGenerator* root, OrderedTargetDependSet const& orderedProjectTargets, - VSFolders const& vsFolders) = 0; + VSFolders const& vsFolders) const = 0; virtual void WriteProject(std::ostream& fout, std::string const& name, std::string const& path, - cmGeneratorTarget const* t) = 0; + cmGeneratorTarget const* t) const = 0; virtual void WriteProjectDepends(std::ostream& fout, std::string const& name, std::string const& path, - cmGeneratorTarget const* t) = 0; + cmGeneratorTarget const* t) const = 0; virtual void WriteProjectConfigurations( std::ostream& fout, std::string const& name, cmGeneratorTarget const& target, std::vector const& configs, std::set const& configsPartOfDefaultBuild, - std::string const& platformMapping = "") = 0; + std::string const& platformMapping = "") const = 0; virtual void WriteSLNGlobalSections(std::ostream& fout, - cmLocalGenerator* root); - virtual void WriteSLNFooter(std::ostream& fout); + cmLocalGenerator* root) const; + virtual void WriteSLNFooter(std::ostream& fout) const; std::string WriteUtilityDepend(cmGeneratorTarget const* target) override; VSFolders CreateSolutionFolders( @@ -172,34 +172,35 @@ protected: virtual void WriteTargetsToSolution( std::ostream& fout, cmLocalGenerator* root, - OrderedTargetDependSet const& projectTargets); + OrderedTargetDependSet const& projectTargets) const; virtual void WriteTargetConfigurations( std::ostream& fout, std::vector const& configs, - OrderedTargetDependSet const& projectTargets); + OrderedTargetDependSet const& projectTargets) const; virtual void WriteExternalProject( std::ostream& fout, std::string const& name, std::string const& path, cmValue typeGuid, - std::set>> const& dependencies) = 0; + std::set>> const& dependencies) const = 0; - std::string ConvertToSolutionPath(std::string const& path); + std::string ConvertToSolutionPath(std::string const& path) const; std::set IsPartOfDefaultBuild( std::vector const& configs, OrderedTargetDependSet const& projectTargets, - cmGeneratorTarget const* target); + cmGeneratorTarget const* target) const; bool IsDependedOn(OrderedTargetDependSet const& projectTargets, - cmGeneratorTarget const* target); + cmGeneratorTarget const* target) const; std::map GUIDMap; - virtual void WriteFolders(std::ostream& fout, VSFolders const& vsFolders); + virtual void WriteFolders(std::ostream& fout, + VSFolders const& vsFolders) const; virtual void WriteFoldersContent(std::ostream& fout, - VSFolders const& vsFolders); + VSFolders const& vsFolders) const; virtual void AddSolutionItems(cmLocalGenerator* root, VSFolders& vsFolders) = 0; virtual void WriteFolderSolutionItems( - std::ostream& fout, cmVisualStudioFolder const& folder) = 0; + std::ostream& fout, cmVisualStudioFolder const& folder) const = 0; bool MarmasmEnabled; bool MasmEnabled; diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx index e8edb0354e..db7b1419e6 100644 --- a/Source/cmGlobalVisualStudio8Generator.cxx +++ b/Source/cmGlobalVisualStudio8Generator.cxx @@ -363,7 +363,7 @@ void cmGlobalVisualStudio8Generator::AddExtraIDETargets() } void cmGlobalVisualStudio8Generator::WriteSolutionConfigurations( - std::ostream& fout, std::vector const& configs) + std::ostream& fout, std::vector const& configs) const { fout << "\tGlobalSection(SolutionConfigurationPlatforms) = preSolution\n"; for (std::string const& i : configs) { @@ -377,7 +377,7 @@ void cmGlobalVisualStudio8Generator::WriteProjectConfigurations( std::ostream& fout, std::string const& name, cmGeneratorTarget const& target, std::vector const& configs, std::set const& configsPartOfDefaultBuild, - std::string const& platformMapping) + std::string const& platformMapping) const { std::string guid = this->GetGUID(name); for (std::string const& i : configs) { @@ -460,7 +460,7 @@ bool cmGlobalVisualStudio8Generator::ComputeTargetDepends() void cmGlobalVisualStudio8Generator::WriteProjectDepends( std::ostream& fout, std::string const&, std::string const&, - cmGeneratorTarget const* gt) + cmGeneratorTarget const* gt) const { TargetDependSet const& unordered = this->GetTargetDirectDepends(gt); OrderedTargetDependSet depends(unordered, std::string()); diff --git a/Source/cmGlobalVisualStudio8Generator.h b/Source/cmGlobalVisualStudio8Generator.h index 52f94bfabf..23032d71aa 100644 --- a/Source/cmGlobalVisualStudio8Generator.h +++ b/Source/cmGlobalVisualStudio8Generator.h @@ -73,16 +73,17 @@ protected: static cmIDEFlagTable const* GetExtraFlagTableVS8(); void WriteSolutionConfigurations( - std::ostream& fout, std::vector const& configs) override; + std::ostream& fout, + std::vector const& configs) const override; void WriteProjectConfigurations( std::ostream& fout, std::string const& name, cmGeneratorTarget const& target, std::vector const& configs, std::set const& configsPartOfDefaultBuild, - std::string const& platformMapping = "") override; + std::string const& platformMapping = "") const override; bool ComputeTargetDepends() override; void WriteProjectDepends(std::ostream& fout, std::string const& name, std::string const& path, - cmGeneratorTarget const* t) override; + cmGeneratorTarget const* t) const override; bool UseFolderProperty() const override; diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index c905a4e8e1..c903f74f02 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -119,7 +119,7 @@ char const* cmGlobalVisualStudioGenerator::GetIDEVersion() const return ""; } -void cmGlobalVisualStudioGenerator::WriteSLNHeader(std::ostream& fout) +void cmGlobalVisualStudioGenerator::WriteSLNHeader(std::ostream& fout) const { char utf8bom[] = { char(0xEF), char(0xBB), char(0xBF) }; fout.write(utf8bom, 3); @@ -780,7 +780,7 @@ void RegisterVisualStudioMacros(std::string const& macrosFile, } } bool cmGlobalVisualStudioGenerator::TargetIsFortranOnly( - cmGeneratorTarget const* gt) + cmGeneratorTarget const* gt) const { // If there's only one source language, Fortran has to be used // in order for the sources to compile. diff --git a/Source/cmGlobalVisualStudioGenerator.h b/Source/cmGlobalVisualStudioGenerator.h index 2fce9bbcdc..3a68ec655f 100644 --- a/Source/cmGlobalVisualStudioGenerator.h +++ b/Source/cmGlobalVisualStudioGenerator.h @@ -93,7 +93,7 @@ public: void CallVisualStudioMacro(MacroName m, std::string const& vsSolutionFile); // return true if target is fortran only - bool TargetIsFortranOnly(cmGeneratorTarget const* gt); + bool TargetIsFortranOnly(cmGeneratorTarget const* gt) const; // return true if target should be included in solution. virtual bool IsInSolution(cmGeneratorTarget const* gt) const; @@ -172,7 +172,7 @@ protected: char const* GetIDEVersion() const; - void WriteSLNHeader(std::ostream& fout); + void WriteSLNHeader(std::ostream& fout) const; bool ComputeTargetDepends() override; class VSDependSet : public std::set