VS: Fix .vcproj and .vfproj file OutputDirectory generation

Teach cmLocalVisualStudio7Generator to set 'OutputDirectory' using the
same method as is used to set the 'OutputFile' in the generated project
file.  Also, OutputDirectory only needs to be set for targets that run the
linker or librarian.  These two changes make the VS 7 OutputDirectory
consistent with what cmVisualStudio10TargetGenerator generates for OutDir.

Without this, since the VS Intel Fortran plugin for VS >= 10 still uses
the VS 7 .vfproj file format, when executing test VSGNUFortran using
Intel Fortran Compiler 15.xx, the following warning is issued just
before compilation:

  TargetPath(...) does not match the Linker's OutputFile property value (...).
  This may cause your project to build incorrectly.
  To correct this, please make sure that $(OutDir), $(TargetName) and $(TargetExt)
  property values match the value specified in %(Link.OutputFile).

Subsequently, an error is reported during linking.

Inspired-by: Vincent Newsum <vynewsum@gmail.com>
This commit is contained in:
Brad King 2015-02-16 11:13:43 -05:00
parent aa2ba12164
commit fa8b30ebb5
1 changed files with 11 additions and 2 deletions

View File

@ -669,8 +669,7 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout,
static_cast<cmGlobalVisualStudio7Generator*>(this->GlobalGenerator);
fout << "\t\t<Configuration\n"
<< "\t\t\tName=\"" << configName
<< "|" << gg->GetPlatformName() << "\"\n"
<< "\t\t\tOutputDirectory=\"" << configName << "\"\n";
<< "|" << gg->GetPlatformName() << "\"\n";
// This is an internal type to Visual Studio, it seems that:
// 4 == static library
// 2 == dll
@ -798,6 +797,16 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout,
std::string intermediateDir = this->GetTargetDirectory(target);
intermediateDir += "/";
intermediateDir += configName;
if (target.GetType() < cmTarget::UTILITY)
{
std::string const& outDir =
target.GetType() == cmTarget::OBJECT_LIBRARY?
intermediateDir : target.GetDirectory(configName);
fout << "\t\t\tOutputDirectory=\""
<< this->ConvertToXMLOutputPathSingle(outDir.c_str()) << "\"\n";
}
fout << "\t\t\tIntermediateDirectory=\""
<< this->ConvertToXMLOutputPath(intermediateDir.c_str())
<< "\"\n"