summaryrefslogtreecommitdiffstats
path: root/Source/cmGlobalVisualStudio10Generator.cxx
diff options
context:
space:
mode:
authorFlorian Schweiger <husker@dzdm.de>2022-02-02 17:23:35 (GMT)
committerFlorian Schweiger <husker@dzdm.de>2022-02-07 12:08:37 (GMT)
commit5cdd774d519d7a524c398855573781dfdbf41a02 (patch)
treecc727ea79d59d35c4743722e6353311af3d8720a /Source/cmGlobalVisualStudio10Generator.cxx
parent309191052cf83bc5535ff66e9ece04cda18d5fe5 (diff)
downloadCMake-5cdd774d519d7a524c398855573781dfdbf41a02.zip
CMake-5cdd774d519d7a524c398855573781dfdbf41a02.tar.gz
CMake-5cdd774d519d7a524c398855573781dfdbf41a02.tar.bz2
VS: Handle build target correct for .NET SDK style projects with Any CPU
* Extend Visual Studio solution parser for reading build target * Map solution build target to project build target (especially for Any CPU) * Use C++ <optional> template instead of pointer return value for cmSlnData::GetProjectByGUID
Diffstat (limited to 'Source/cmGlobalVisualStudio10Generator.cxx')
-rw-r--r--Source/cmGlobalVisualStudio10Generator.cxx41
1 files changed, 27 insertions, 14 deletions
diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx
index a52c831..a96f6f0 100644
--- a/Source/cmGlobalVisualStudio10Generator.cxx
+++ b/Source/cmGlobalVisualStudio10Generator.cxx
@@ -1134,7 +1134,7 @@ cmGlobalVisualStudio10Generator::GenerateBuildCommand(
slnFile += ".sln";
cmVisualStudioSlnParser parser;
if (parser.ParseFile(slnFile, slnData,
- cmVisualStudioSlnParser::DataGroupProjects)) {
+ cmVisualStudioSlnParser::DataGroupAll)) {
std::vector<cmSlnProjectEntry> slnProjects = slnData.GetProjects();
for (cmSlnProjectEntry const& project : slnProjects) {
if (useDevEnv) {
@@ -1170,15 +1170,17 @@ cmGlobalVisualStudio10Generator::GenerateBuildCommand(
GeneratedMakeCommand makeCommand;
makeCommand.RequiresOutputForward = requiresOutputForward;
makeCommand.Add(makeProgramSelected);
+ cm::optional<cmSlnProjectEntry> proj = cm::nullopt;
if (tname == "clean") {
- makeCommand.Add(std::string(projectName) + ".sln");
+ makeCommand.Add(cmStrCat(projectName, ".sln"));
makeCommand.Add("/t:Clean");
} else {
std::string targetProject = cmStrCat(tname, ".vcxproj");
+ proj = slnData.GetProjectByName(tname);
if (targetProject.find('/') == std::string::npos) {
// it might be in a subdir
- if (cmSlnProjectEntry const* proj = slnData.GetProjectByName(tname)) {
+ if (proj) {
targetProject = proj->GetRelativePath();
cmSystemTools::ConvertToUnixSlashes(targetProject);
}
@@ -1243,22 +1245,33 @@ cmGlobalVisualStudio10Generator::GenerateBuildCommand(
}
}
- std::string configArg = "/p:Configuration=";
- if (!config.empty()) {
- configArg += config;
- } else {
- configArg += "Debug";
+ std::string plainConfig = config;
+ if (config.empty()) {
+ plainConfig = "Debug";
}
- makeCommand.Add(configArg);
- makeCommand.Add(std::string("/p:Platform=") + this->GetPlatformName());
- makeCommand.Add(std::string("/p:VisualStudioVersion=") +
- this->GetIDEVersion());
+
+ std::string platform = GetPlatformName();
+ if (proj) {
+ std::string extension =
+ cmSystemTools::GetFilenameLastExtension(proj->GetRelativePath());
+ extension = cmSystemTools::LowerCase(extension);
+ if (extension.compare(".csproj") == 0) {
+ // Use correct platform name
+ platform =
+ slnData.GetConfigurationTarget(tname, plainConfig, platform);
+ }
+ }
+
+ makeCommand.Add(cmStrCat("/p:Configuration=", plainConfig));
+ makeCommand.Add(cmStrCat("/p:Platform=", platform));
+ makeCommand.Add(
+ cmStrCat("/p:VisualStudioVersion=", this->GetIDEVersion()));
if (jobs != cmake::NO_BUILD_PARALLEL_LEVEL) {
if (jobs == cmake::DEFAULT_BUILD_PARALLEL_LEVEL) {
makeCommand.Add("/m");
} else {
- makeCommand.Add(std::string("/m:") + std::to_string(jobs));
+ makeCommand.Add(cmStrCat("/m:", std::to_string(jobs)));
}
// Having msbuild.exe and cl.exe using multiple jobs is discouraged
makeCommand.Add("/p:CL_MPCount=1");
@@ -1266,7 +1279,7 @@ cmGlobalVisualStudio10Generator::GenerateBuildCommand(
// Respect the verbosity: 'n' normal will show build commands
// 'm' minimal only the build step's title
- makeCommand.Add(std::string("/v:") + ((verbose) ? "n" : "m"));
+ makeCommand.Add(cmStrCat("/v:", ((verbose) ? "n" : "m")));
makeCommand.Add(makeOptions.begin(), makeOptions.end());
makeCommands.emplace_back(std::move(makeCommand));
}