Add option to CMake --build tool to use `.sln` file for VS10 generators and above
MSBuild, when building the vcxproj file (ALL_BUILD or another target), will build all References to that target, essentially ignoring the EXCLUDE_FROM_DEFAULT_BUILD
, EXCLUDE_FROM_DEFAULT_BUILD_<CONFIG>
, and EXCLUDE_FROM_ALL
properties.
For the --target option, can it be set to use the solution file if no target was specified (and not ALL_BUILD.vcxproj), instead of only when it is set to 'clean'?
The code that determines what filetype to use is below:
// msbuild.exe CxxOnly.sln /t:Build /p:Configuration=Debug /target:ALL_BUILD
if (realTarget.empty()) {
realTarget = "ALL_BUILD";
}
if (realTarget == "clean") {
makeCommand.push_back(std::string(projectName) + ".sln"); // <- '--target clean' is the only way to use the sln file
makeCommand.push_back("/t:Clean");
} else {
std::string targetProject(realTarget);
targetProject += ".vcxproj";
if (targetProject.find('/') == std::string::npos) {
// it might be in a subdir
if (cmSlnProjectEntry const* proj =
slnData.GetProjectByName(realTarget)) {
targetProject = proj->GetRelativePath();
cmSystemTools::ConvertToUnixSlashes(targetProject);
}
}
makeCommand.push_back(targetProject);
}
I wrote up a mail a couple months ago regarding this issue. https://cmake.org/pipermail/cmake/2017-May/065415.html