[cmake-developers] Set msbuild.exe to build the solution instead of the ALL_BUILD target?

Robert Goulet Robert.Goulet at autodesk.com
Tue May 5 16:57:43 EDT 2015


Hi all,

When I do not specify any targets (--target <target>) when using cmake.exe to launch a build using the --build option, it still specify ALL_BUILD as the target to build to the msbuild.exe command line. Looking at the cmake code, we see the following (see below). Essentially this means we cannot completely avoid setting the target when calling msbuild.exe. This is a major issue because when building with msbuild.exe, specifying a target project will not respect the rules set in the solution file, which might have some projects disabled by the EXCLUDE_FROM_DEFAULT_BUILD cmake target property.

So I am willing to make a patch to allow, somehow, to use the solution file as the file to build with msbuild.exe, but I would like your input as to how you would prefer to pass this option to cmake? I do not want to change the behavior of not setting the target cause it to set ALL_BUILD by default, but I need a way to also be able to set no target at all and just build the solution.

Any preferences?

  if(realTarget.empty())
    {
    realTarget = "ALL_BUILD";
    }
  if ( realTarget == "clean" )
    {
    makeCommand.push_back(std::string(projectName)+".sln");
    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);
    }



Robert Goulet
Senior Software Developer
Games Solutions Group
Autodesk Media & Entertainment

MAIN +1 514 393 1616
DIRECT +1 514 954 3911
MOBILE +1 438 397 4075

Autodesk, Inc.
10 Rue Duke
Montreal, QC, H3C 2L7
www.autodesk.com<http://www.autodesk.com/>

[Description: Email_Signature_Logobar]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake-developers/attachments/20150505/1aafef77/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.jpg
Type: image/jpeg
Size: 14277 bytes
Desc: image001.jpg
URL: <http://public.kitware.com/pipermail/cmake-developers/attachments/20150505/1aafef77/attachment-0001.jpg>


More information about the cmake-developers mailing list