VS: Use .sln parser to build targets in subdirs with msbuild (#13623)
Use cmVisualStudioSlnParser in GenerateBuildCommand() to provide correct command line for MSBuild even when target project is stored in a subdirectory.
This commit is contained in:
parent
df035e4825
commit
3cd4000601
|
@ -14,6 +14,8 @@
|
||||||
#include "cmLocalVisualStudio10Generator.h"
|
#include "cmLocalVisualStudio10Generator.h"
|
||||||
#include "cmMakefile.h"
|
#include "cmMakefile.h"
|
||||||
#include "cmSourceFile.h"
|
#include "cmSourceFile.h"
|
||||||
|
#include "cmVisualStudioSlnData.h"
|
||||||
|
#include "cmVisualStudioSlnParser.h"
|
||||||
#include "cmake.h"
|
#include "cmake.h"
|
||||||
|
|
||||||
static const char vs10Win32generatorName[] = "Visual Studio 10";
|
static const char vs10Win32generatorName[] = "Visual Studio 10";
|
||||||
|
@ -259,9 +261,38 @@ std::string cmGlobalVisualStudio10Generator
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
std::string targetProject(targetName);
|
||||||
|
targetProject += ".vcxproj";
|
||||||
|
if (targetProject.find('/') == std::string::npos)
|
||||||
|
{
|
||||||
|
// it might be in a subdir
|
||||||
|
cmVisualStudioSlnParser parser;
|
||||||
|
cmSlnData slnData;
|
||||||
|
std::string slnFile;
|
||||||
|
if (projectDir && *projectDir)
|
||||||
|
{
|
||||||
|
slnFile = projectDir;
|
||||||
|
slnFile += '/';
|
||||||
|
slnFile += projectName;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
slnFile = projectName;
|
||||||
|
}
|
||||||
|
if (parser.ParseFile(slnFile + ".sln", slnData,
|
||||||
|
cmVisualStudioSlnParser::DataGroupProjects))
|
||||||
|
{
|
||||||
|
if (cmSlnProjectEntry const* proj =
|
||||||
|
slnData.GetProjectByName(targetName))
|
||||||
|
{
|
||||||
|
targetProject = proj->GetRelativePath();
|
||||||
|
cmSystemTools::ConvertToUnixSlashes(targetProject);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
makeCommand += " ";
|
||||||
|
makeCommand += targetProject;
|
||||||
makeCommand += " ";
|
makeCommand += " ";
|
||||||
makeCommand += targetName;
|
|
||||||
makeCommand += ".vcxproj ";
|
|
||||||
}
|
}
|
||||||
makeCommand += "/p:Configuration=";
|
makeCommand += "/p:Configuration=";
|
||||||
if(config && strlen(config))
|
if(config && strlen(config))
|
||||||
|
|
Loading…
Reference in New Issue