COMP: Fix the ExternalProject test for Visual Studio 6. Visual Studio 6 *.dsp files cannot have hyphens in them. Add utility function GetVS6TargetName to replace hyphens with underscores when generating *.dsp file names. Use the function everywhere necessary in the VS6 generators. And, a workaround: VS6 uses ".\Debug" (for example) as an "$(IntDir)" value - strip any leading ".\" when processing a --config argument in the cmake --build handling code.
This commit is contained in:
parent
09084d89fb
commit
16f35e189e
|
@ -372,6 +372,23 @@ void cmGlobalVisualStudio6Generator::OutputDSWFile()
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
// Utility function to make a valid VS6 *.dsp filename out
|
||||
// of a CMake target name:
|
||||
//
|
||||
std::string GetVS6TargetName(const std::string& targetName)
|
||||
{
|
||||
std::string name(targetName);
|
||||
|
||||
// Eliminate hyphens. VS6 cannot handle hyphens in *.dsp filenames...
|
||||
// Replace them with underscores.
|
||||
//
|
||||
cmSystemTools::ReplaceString(name, "-", "_");
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
|
||||
// Write a dsp file into the DSW file,
|
||||
// Note, that dependencies from executables to
|
||||
// the libraries it uses are also done here
|
||||
|
@ -402,7 +419,7 @@ void cmGlobalVisualStudio6Generator::WriteProject(std::ostream& fout,
|
|||
if(this->FindTarget(0, j->first.c_str()))
|
||||
{
|
||||
fout << "Begin Project Dependency\n";
|
||||
fout << "Project_Dep_Name " << j->first.c_str() << "\n";
|
||||
fout << "Project_Dep_Name " << GetVS6TargetName(j->first.c_str()) << "\n";
|
||||
fout << "End Project Dependency\n";
|
||||
}
|
||||
}
|
||||
|
@ -419,7 +436,7 @@ void cmGlobalVisualStudio6Generator::WriteProject(std::ostream& fout,
|
|||
{
|
||||
std::string depName = this->GetUtilityForTarget(target, i->c_str());
|
||||
fout << "Begin Project Dependency\n";
|
||||
fout << "Project_Dep_Name " << depName << "\n";
|
||||
fout << "Project_Dep_Name " << GetVS6TargetName(depName) << "\n";
|
||||
fout << "End Project Dependency\n";
|
||||
}
|
||||
}
|
||||
|
@ -451,7 +468,7 @@ void cmGlobalVisualStudio6Generator::WriteExternalProject(std::ostream& fout,
|
|||
for(;i!= end; ++i)
|
||||
{
|
||||
fout << "Begin Project Dependency\n";
|
||||
fout << "Project_Dep_Name " << *i << "\n";
|
||||
fout << "Project_Dep_Name " << GetVS6TargetName(*i) << "\n";
|
||||
fout << "End Project Dependency\n";
|
||||
}
|
||||
fout << "}}}\n\n";
|
||||
|
|
|
@ -63,7 +63,7 @@ void cmLocalVisualStudio6Generator::OutputDSPFile()
|
|||
|
||||
// Setup /I and /LIBPATH options for the resulting DSP file. VS 6
|
||||
// truncates long include paths so make it as short as possible if
|
||||
// the length threatents this problem.
|
||||
// the length threatens this problem.
|
||||
unsigned int maxIncludeLength = 3000;
|
||||
bool useShortPath = false;
|
||||
for(int j=0; j < 2; ++j)
|
||||
|
@ -167,17 +167,23 @@ void cmLocalVisualStudio6Generator::OutputDSPFile()
|
|||
}
|
||||
}
|
||||
|
||||
// Utility function to make a valid VS6 *.dsp filename out
|
||||
// of a CMake target name:
|
||||
//
|
||||
extern std::string GetVS6TargetName(const std::string& targetName);
|
||||
|
||||
void cmLocalVisualStudio6Generator::CreateSingleDSP(const char *lname,
|
||||
cmTarget &target)
|
||||
{
|
||||
// add to the list of projects
|
||||
std::string pname = lname;
|
||||
std::string pname = GetVS6TargetName(lname);
|
||||
|
||||
this->CreatedProjectNames.push_back(pname);
|
||||
// create the dsp.cmake file
|
||||
std::string fname;
|
||||
fname = this->Makefile->GetStartOutputDirectory();
|
||||
fname += "/";
|
||||
fname += lname;
|
||||
fname += pname;
|
||||
fname += ".dsp";
|
||||
// save the name of the real dsp file
|
||||
std::string realDSP = fname;
|
||||
|
@ -188,7 +194,7 @@ void cmLocalVisualStudio6Generator::CreateSingleDSP(const char *lname,
|
|||
cmSystemTools::Error("Error Writing ", fname.c_str());
|
||||
cmSystemTools::ReportLastSystemError("");
|
||||
}
|
||||
this->WriteDSPFile(fout,lname,target);
|
||||
this->WriteDSPFile(fout,pname.c_str(),target);
|
||||
fout.close();
|
||||
// if the dsp file has changed, then write it.
|
||||
cmSystemTools::CopyFileIfDifferent(fname.c_str(), realDSP.c_str());
|
||||
|
@ -197,7 +203,7 @@ void cmLocalVisualStudio6Generator::CreateSingleDSP(const char *lname,
|
|||
|
||||
void cmLocalVisualStudio6Generator::AddDSPBuildRule(cmTarget& tgt)
|
||||
{
|
||||
std::string dspname = tgt.GetName();
|
||||
std::string dspname = GetVS6TargetName(tgt.GetName());
|
||||
dspname += ".dsp.cmake";
|
||||
const char* dsprule =
|
||||
this->Makefile->GetRequiredDefinition("CMAKE_COMMAND");
|
||||
|
@ -287,10 +293,6 @@ void cmLocalVisualStudio6Generator::WriteDSPFile(std::ostream& fout,
|
|||
}
|
||||
}
|
||||
|
||||
// trace the visual studio dependencies
|
||||
std::string name = libName;
|
||||
name += ".dsp.cmake";
|
||||
|
||||
// We may be modifying the source groups temporarily, so make a copy.
|
||||
std::vector<cmSourceGroup> sourceGroups = this->Makefile->GetSourceGroups();
|
||||
|
||||
|
@ -462,7 +464,8 @@ void cmLocalVisualStudio6Generator
|
|||
{
|
||||
cmSystemTools::ExpandListArgument(dependsValue, depends);
|
||||
}
|
||||
if (source != libName || target.GetType() == cmTarget::UTILITY ||
|
||||
if (GetVS6TargetName(source) != libName ||
|
||||
target.GetType() == cmTarget::UTILITY ||
|
||||
target.GetType() == cmTarget::GLOBAL_TARGET)
|
||||
{
|
||||
fout << "# Begin Source File\n\n";
|
||||
|
@ -758,11 +761,13 @@ void cmLocalVisualStudio6Generator::SetBuildType(BuildType b,
|
|||
// reset this->Configurations
|
||||
this->Configurations.erase(this->Configurations.begin(),
|
||||
this->Configurations.end());
|
||||
|
||||
// now add all the configurations possible
|
||||
std::string vs6name = GetVS6TargetName(libName);
|
||||
std::string line;
|
||||
while(cmSystemTools::GetLineFromStream(fin, line))
|
||||
{
|
||||
cmSystemTools::ReplaceString(line, "OUTPUT_LIBNAME",libName);
|
||||
cmSystemTools::ReplaceString(line, "OUTPUT_LIBNAME", vs6name.c_str());
|
||||
if (reg.find(line))
|
||||
{
|
||||
this->Configurations.push_back(line.substr(reg.end()));
|
||||
|
@ -1055,8 +1060,8 @@ void cmLocalVisualStudio6Generator
|
|||
if ((target.GetType() != cmTarget::SHARED_LIBRARY
|
||||
&& target.GetType() != cmTarget::STATIC_LIBRARY
|
||||
&& target.GetType() != cmTarget::MODULE_LIBRARY) ||
|
||||
(target.GetType()==cmTarget::SHARED_LIBRARY && libName != j->first) ||
|
||||
(target.GetType()==cmTarget::MODULE_LIBRARY && libName != j->first))
|
||||
(target.GetType()==cmTarget::SHARED_LIBRARY && libName != GetVS6TargetName(j->first)) ||
|
||||
(target.GetType()==cmTarget::MODULE_LIBRARY && libName != GetVS6TargetName(j->first)))
|
||||
{
|
||||
// Compute the proper name to use to link this library.
|
||||
std::string lib;
|
||||
|
@ -1404,7 +1409,10 @@ void cmLocalVisualStudio6Generator
|
|||
targetImplibFlagMinSizeRel.c_str());
|
||||
cmSystemTools::ReplaceString(line, "TARGET_IMPLIB_FLAG_RELWITHDEBINFO",
|
||||
targetImplibFlagRelWithDebInfo.c_str());
|
||||
cmSystemTools::ReplaceString(line, "OUTPUT_LIBNAME",libName);
|
||||
|
||||
std::string vs6name = GetVS6TargetName(libName);
|
||||
cmSystemTools::ReplaceString(line, "OUTPUT_LIBNAME", vs6name.c_str());
|
||||
|
||||
#ifdef CM_USE_OLD_VS6
|
||||
// because LIBRARY_OUTPUT_PATH and EXECUTABLE_OUTPUT_PATH
|
||||
// are already quoted in the template file,
|
||||
|
|
|
@ -4417,6 +4417,14 @@ int cmake::DoBuild(int ac, char* av[])
|
|||
std::cerr << arg.GetHelp() << "\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Hack for vs6 that passes ".\Debug" as "$(IntDir)" value:
|
||||
//
|
||||
if (cmSystemTools::StringStartsWith(config.c_str(), ".\\"))
|
||||
{
|
||||
config = config.substr(2);
|
||||
}
|
||||
|
||||
cmake cm;
|
||||
return cm.Build(dir, target, config, extraBuildOptions, clean);
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue