summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Cole <david.cole@kitware.com>2008-12-09 21:07:10 (GMT)
committerDavid Cole <david.cole@kitware.com>2008-12-09 21:07:10 (GMT)
commit16f35e189e9af72be1422245391c4b3ba9cd826c (patch)
tree78e517fd01c86bbd08b2a658842b0f86192a3924
parent09084d89fb16a7ffc0d8ebf642cd478c51ad65ef (diff)
downloadCMake-16f35e189e9af72be1422245391c4b3ba9cd826c.zip
CMake-16f35e189e9af72be1422245391c4b3ba9cd826c.tar.gz
CMake-16f35e189e9af72be1422245391c4b3ba9cd826c.tar.bz2
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.
-rw-r--r--Source/cmGlobalVisualStudio6Generator.cxx23
-rw-r--r--Source/cmLocalVisualStudio6Generator.cxx40
-rw-r--r--Source/cmake.cxx8
3 files changed, 52 insertions, 19 deletions
diff --git a/Source/cmGlobalVisualStudio6Generator.cxx b/Source/cmGlobalVisualStudio6Generator.cxx
index 723ac7c..e6456e8 100644
--- a/Source/cmGlobalVisualStudio6Generator.cxx
+++ b/Source/cmGlobalVisualStudio6Generator.cxx
@@ -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";
diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx
index 6a60801..cc2bb4c 100644
--- a/Source/cmLocalVisualStudio6Generator.cxx
+++ b/Source/cmLocalVisualStudio6Generator.cxx
@@ -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,12 +1409,15 @@ 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
+ // because LIBRARY_OUTPUT_PATH and EXECUTABLE_OUTPUT_PATH
// are already quoted in the template file,
// we need to remove the quotes here, we still need
- // to convert to output path for unix to win32 conversion
+ // to convert to output path for unix to win32 conversion
cmSystemTools::ReplaceString
(line, "LIBRARY_OUTPUT_PATH",
removeQuotes(this->ConvertToOptionallyRelativeOutputPath
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index 7c8378a..b025185 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -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