diff options
author | Brad King <brad.king@kitware.com> | 2013-11-13 20:12:06 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2013-11-18 16:30:48 (GMT) |
commit | 123a0608dfe6cf155f0fc095cf389ae7b3d4ebb0 (patch) | |
tree | b9f62255e7c1f8c6194e93abed2fae4875c3db58 /Source/cmGlobalVisualStudio10Generator.cxx | |
parent | 5f5c92b9a2c2f9c780c08e23231b93af71f175bd (diff) | |
download | CMake-123a0608dfe6cf155f0fc095cf389ae7b3d4ebb0.zip CMake-123a0608dfe6cf155f0fc095cf389ae7b3d4ebb0.tar.gz CMake-123a0608dfe6cf155f0fc095cf389ae7b3d4ebb0.tar.bz2 |
Teach GenerateBuildCommand to find its own make program
Add a cmGlobalGenerator::SelectMakeProgram method to select a
caller-provided make program, the CMAKE_MAKE_PROGRAM cache entry, or a
generator-provided default. Call it from all implementations of the
GenerateBuildCommand method with the corresponding generator's default,
if any.
Diffstat (limited to 'Source/cmGlobalVisualStudio10Generator.cxx')
-rw-r--r-- | Source/cmGlobalVisualStudio10Generator.cxx | 78 |
1 files changed, 47 insertions, 31 deletions
diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index d4d67d0..741d591 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -311,23 +311,56 @@ void cmGlobalVisualStudio10Generator::GenerateBuildCommand( bool fast, std::vector<std::string> const& makeOptions) { - // now build the test - std::string lowerCaseCommand = makeProgram; - cmSystemTools::LowerCase(lowerCaseCommand); - - // If makeProgram is devenv, parent class knows how to generate command: - if (lowerCaseCommand.find("devenv") != std::string::npos || - lowerCaseCommand.find("VCExpress") != std::string::npos) + // Select the caller- or user-preferred make program, else MSBuild. + std::string makeProgramSelected = + this->SelectMakeProgram(makeProgram, this->GetMSBuildCommand()); + + // Check if the caller explicitly requested a devenv tool. + std::string makeProgramLower = makeProgramSelected; + cmSystemTools::LowerCase(makeProgramLower); + bool useDevEnv = + (makeProgramLower.find("devenv") != std::string::npos || + makeProgramLower.find("vcexpress") != std::string::npos); + + // MSBuild is preferred (and required for VS Express), but if the .sln has + // an Intel Fortran .vfproj then we have to use devenv. Parse it to find out. + cmSlnData slnData; + { + std::string slnFile; + if(projectDir && *projectDir) + { + slnFile = projectDir; + slnFile += "/"; + } + slnFile += projectName; + slnFile += ".sln"; + cmVisualStudioSlnParser parser; + if(parser.ParseFile(slnFile, slnData, + cmVisualStudioSlnParser::DataGroupProjects)) + { + std::vector<cmSlnProjectEntry> slnProjects = slnData.GetProjects(); + for(std::vector<cmSlnProjectEntry>::iterator i = slnProjects.begin(); + !useDevEnv && i != slnProjects.end(); ++i) + { + std::string proj = i->GetRelativePath(); + if(proj.size() > 7 && + proj.substr(proj.size()-7) == ".vfproj") + { + useDevEnv = true; + } + } + } + } + if(useDevEnv) { + // Use devenv to build solutions containing Intel Fortran projects. cmGlobalVisualStudio7Generator::GenerateBuildCommand( makeCommand, makeProgram, projectName, projectDir, targetName, config, fast, makeOptions); return; } - // Otherwise, assume MSBuild command line, and construct accordingly. - - makeCommand.push_back(makeProgram); + makeCommand.push_back(makeProgramSelected); // msbuild.exe CxxOnly.sln /t:Build /p:Configuration=Debug /target:ALL_BUILD if(!targetName || strlen(targetName) == 0) @@ -346,28 +379,11 @@ void cmGlobalVisualStudio10Generator::GenerateBuildCommand( 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)) { - if (cmSlnProjectEntry const* proj = - slnData.GetProjectByName(targetName)) - { - targetProject = proj->GetRelativePath(); - cmSystemTools::ConvertToUnixSlashes(targetProject); - } + targetProject = proj->GetRelativePath(); + cmSystemTools::ConvertToUnixSlashes(targetProject); } } makeCommand.push_back(targetProject); |