mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-14 02:08:27 +08:00
cmVisualStudioSlnParser: Fix storage of some .sln
parse results
In commit 5cdd774d51
(VS: Handle build target correct for .NET SDK style
projects with Any CPU, 2022-02-02, v3.23.0-rc1~3^2), some parse results
were stored in temporary copies of `cmSlnProjectEntry` and thrown away.
This commit is contained in:
@@ -1131,8 +1131,7 @@ cmGlobalVisualStudio10Generator::GenerateBuildCommand(
|
||||
std::string targetProject = cmStrCat(tname, ".vcxproj");
|
||||
if (targetProject.find('/') == std::string::npos) {
|
||||
// it might be in a subdir
|
||||
if (cm::optional<cmSlnProjectEntry> proj =
|
||||
slnData.GetProjectByName(tname)) {
|
||||
if (cmSlnProjectEntry const* proj = slnData.GetProjectByName(tname)) {
|
||||
targetProject = proj->GetRelativePath();
|
||||
cmSystemTools::ConvertToUnixSlashes(targetProject);
|
||||
}
|
||||
|
@@ -16,29 +16,32 @@ void cmSlnProjectEntry::AddProjectConfiguration(
|
||||
}
|
||||
|
||||
std::string cmSlnProjectEntry::GetProjectConfiguration(
|
||||
std::string const& solutionConfiguration)
|
||||
std::string const& solutionConfiguration) const
|
||||
{
|
||||
return projectConfigurationMap[solutionConfiguration];
|
||||
auto i = projectConfigurationMap.find(solutionConfiguration);
|
||||
if (i != projectConfigurationMap.end()) {
|
||||
return i->second;
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
cm::optional<cmSlnProjectEntry> cmSlnData::GetProjectByGUID(
|
||||
std::string const& projectGUID) const
|
||||
cmSlnProjectEntry* cmSlnData::GetProjectByGUID(std::string const& projectGUID)
|
||||
{
|
||||
auto it(ProjectsByGUID.find(projectGUID));
|
||||
if (it != ProjectsByGUID.end()) {
|
||||
return it->second;
|
||||
return &it->second;
|
||||
}
|
||||
return cm::nullopt;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
cm::optional<cmSlnProjectEntry> cmSlnData::GetProjectByName(
|
||||
cmSlnProjectEntry const* cmSlnData::GetProjectByName(
|
||||
std::string const& projectName) const
|
||||
{
|
||||
auto it(ProjectNameIndex.find(projectName));
|
||||
if (it != ProjectNameIndex.end()) {
|
||||
return it->second->second;
|
||||
return &it->second->second;
|
||||
}
|
||||
return cm::nullopt;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::vector<cmSlnProjectEntry> cmSlnData::GetProjects() const
|
||||
@@ -75,7 +78,7 @@ std::string cmSlnData::GetConfigurationTarget(
|
||||
{
|
||||
std::string solutionTarget =
|
||||
cmStrCat(solutionConfiguration, '|', platformName);
|
||||
cm::optional<cmSlnProjectEntry> project = GetProjectByName(projectName);
|
||||
cmSlnProjectEntry const* project = GetProjectByName(projectName);
|
||||
if (!project) {
|
||||
return platformName;
|
||||
}
|
||||
|
@@ -8,8 +8,6 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <cm/optional>
|
||||
|
||||
class cmSlnProjectEntry
|
||||
{
|
||||
public:
|
||||
@@ -30,7 +28,7 @@ public:
|
||||
std::string const& projectConfiguration);
|
||||
|
||||
std::string GetProjectConfiguration(
|
||||
std::string const& solutionConfiguration);
|
||||
std::string const& solutionConfiguration) const;
|
||||
|
||||
private:
|
||||
std::string Guid, Name, RelativePath;
|
||||
@@ -56,10 +54,9 @@ public:
|
||||
minimumVisualStudioVersion = version;
|
||||
}
|
||||
|
||||
cm::optional<cmSlnProjectEntry> GetProjectByGUID(
|
||||
std::string const& projectGUID) const;
|
||||
cmSlnProjectEntry* GetProjectByGUID(std::string const& projectGUID);
|
||||
|
||||
cm::optional<cmSlnProjectEntry> GetProjectByName(
|
||||
cmSlnProjectEntry const* GetProjectByName(
|
||||
std::string const& projectName) const;
|
||||
|
||||
std::vector<cmSlnProjectEntry> GetProjects() const;
|
||||
|
@@ -320,8 +320,7 @@ bool cmVisualStudioSlnParser::State::Process(
|
||||
std::string guid = tagElements[0];
|
||||
std::string solutionConfiguration = tagElements[1];
|
||||
std::string activeBuild = tagElements[2];
|
||||
cm::optional<cmSlnProjectEntry> projectEntry =
|
||||
output.GetProjectByGUID(guid);
|
||||
cmSlnProjectEntry* projectEntry = output.GetProjectByGUID(guid);
|
||||
|
||||
if (!projectEntry) {
|
||||
result.SetError(ResultErrorInputStructure, this->GetCurrentLine());
|
||||
|
Reference in New Issue
Block a user