Perhaps something like this?

  ...
  else if ( realTarget == "build" )
    {
    makeCommand.push_back(std::string(projectName)+".sln");
    makeCommand.push_back("/t:Build");
    }
  ...

From: Robert Goulet
Sent: Tuesday, May 5, 2015 4:58 PM
To: [email protected]
Subject: Set msbuild.exe to build the solution instead of the ALL_BUILD target?

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]

-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake-developers

Reply via email to