From f85fc7cda1e6caa625eee71019bcb57c932ba0ab Mon Sep 17 00:00:00 2001 From: Ken Martin Date: Tue, 28 Aug 2001 14:55:14 -0400 Subject: better network build support --- Source/cmDSPWriter.cxx | 78 +++++++++++++++++------------------------------- Source/cmSystemTools.cxx | 27 +++++++++++++++-- Source/cmSystemTools.h | 5 ++++ 3 files changed, 57 insertions(+), 53 deletions(-) diff --git a/Source/cmDSPWriter.cxx b/Source/cmDSPWriter.cxx index 32a6be3..602dad5 100644 --- a/Source/cmDSPWriter.cxx +++ b/Source/cmDSPWriter.cxx @@ -72,19 +72,8 @@ void cmDSPWriter::OutputDSPFile() std::vector::iterator i; for(i = includes.begin(); i != includes.end(); ++i) { - m_IncludeOptions += "/I \""; - // watch for network paths, MSVC can't seem to load // - if (strlen(i->c_str()) > 2 && i->c_str()[0] == '/' && - i->c_str()[1] == '/') - { - m_IncludeOptions += "\\\\"; - m_IncludeOptions += (i->c_str() + 2); - } - else - { - m_IncludeOptions += *i; - } - m_IncludeOptions += "\" "; + m_IncludeOptions += "/I "; + m_IncludeOptions += cmSystemTools::EscapeSpaces(i->c_str()); } // Create the DSP or set of DSP's for libraries and executables @@ -156,20 +145,22 @@ void cmDSPWriter::AddDSPBuildRule(cmSourceGroup& sourceGroup) return; } dspname += ".dsp"; - std::string makefileIn = "\""; - makefileIn += m_Makefile->GetStartDirectory(); + std::string makefileIn = m_Makefile->GetStartDirectory(); makefileIn += "/"; - makefileIn += "CMakeLists.txt\""; + makefileIn += "CMakeLists.txt"; + makefileIn = cmSystemTools::HandleNetworkPaths(makefileIn.c_str()); std::string dsprule = "${CMAKE_COMMAND} "; + m_Makefile->ExpandVariablesInString(dsprule); + dsprule = cmSystemTools::HandleNetworkPaths(dsprule.c_str()); dsprule += makefileIn; dsprule += " -DSP -H\""; - dsprule += m_Makefile->GetHomeDirectory(); + dsprule += cmSystemTools::HandleNetworkPaths(m_Makefile->GetHomeDirectory()); dsprule += "\" -S\""; - dsprule += m_Makefile->GetStartDirectory(); + dsprule += cmSystemTools::HandleNetworkPaths(m_Makefile->GetStartDirectory()); dsprule += "\" -O\""; - dsprule += m_Makefile->GetStartOutputDirectory(); + dsprule += cmSystemTools::HandleNetworkPaths(m_Makefile->GetStartOutputDirectory()); dsprule += "\" -B\""; - dsprule += m_Makefile->GetHomeOutputDirectory(); + dsprule += cmSystemTools::HandleNetworkPaths(m_Makefile->GetHomeOutputDirectory()); dsprule += "\""; m_Makefile->ExpandVariablesInString(dsprule); @@ -259,7 +250,7 @@ void cmDSPWriter::WriteDSPFile(std::ostream& fout, // Tell MS-Dev what the source is. If the compiler knows how to // build it, then it will. - fout << "SOURCE=" << source.c_str() << "\n\n"; + fout << "SOURCE=" << cmSystemTools::EscapeSpaces(source.c_str()) << "\n\n"; if (!commands.empty()) { // Loop through every custom command generating code from the @@ -329,7 +320,7 @@ void cmDSPWriter::WriteCustomRule(std::ostream& fout, for(std::set::const_iterator d = depends.begin(); d != depends.end(); ++d) { - fout << "\\\n\t\"" << d->c_str() << "\""; + fout << "\\\n\t" << cmSystemTools::EscapeSpaces(d->c_str()); } fout << "\n"; @@ -479,16 +470,16 @@ void cmDSPWriter::WriteDSPHeader(std::ostream& fout, const char *libName, libPath += "/"; } libOptions += " /LIBPATH:\""; - libOptions += libPath; + libOptions += cmSystemTools::HandleNetworkPaths(libPath.c_str()); libOptions += "$(IntDir)\" "; libOptions += " /LIBPATH:\""; - libOptions += libPath; + libOptions += cmSystemTools::HandleNetworkPaths(libPath.c_str()); libOptions += "\" "; libMultiLineOptions += "# ADD LINK32 /LIBPATH:\""; - libMultiLineOptions += libPath; + libMultiLineOptions += cmSystemTools::HandleNetworkPaths(libPath.c_str()); libMultiLineOptions += "$(IntDir)\" "; libMultiLineOptions += " /LIBPATH:\""; - libMultiLineOptions += libPath; + libMultiLineOptions += cmSystemTools::HandleNetworkPaths(libPath.c_str()); libMultiLineOptions += "\" \n"; } if(exePath.size()) @@ -499,16 +490,16 @@ void cmDSPWriter::WriteDSPHeader(std::ostream& fout, const char *libName, exePath += "/"; } libOptions += " /LIBPATH:\""; - libOptions += exePath; + libOptions += cmSystemTools::HandleNetworkPaths(exePath.c_str()); libOptions += "$(IntDir)\" "; libOptions += " /LIBPATH:\""; - libOptions += exePath; + libOptions += cmSystemTools::HandleNetworkPaths(exePath.c_str()); libOptions += "\" "; libMultiLineOptions += "# ADD LINK32 /LIBPATH:\""; - libMultiLineOptions += exePath; + libMultiLineOptions += cmSystemTools::HandleNetworkPaths(exePath.c_str()); libMultiLineOptions += "$(IntDir)\" "; libMultiLineOptions += " /LIBPATH:\""; - libMultiLineOptions += exePath; + libMultiLineOptions += cmSystemTools::HandleNetworkPaths(exePath.c_str()); libMultiLineOptions += "\" \n"; } std::vector::iterator i; @@ -516,17 +507,17 @@ void cmDSPWriter::WriteDSPHeader(std::ostream& fout, const char *libName, for(i = libdirs.begin(); i != libdirs.end(); ++i) { libOptions += " /LIBPATH:\""; - libOptions += *i; + libOptions += cmSystemTools::HandleNetworkPaths(i->c_str()); libOptions += "/$(IntDir)\" "; libOptions += " /LIBPATH:\""; - libOptions += *i; + libOptions += cmSystemTools::HandleNetworkPaths(i->c_str()); libOptions += "\" "; libMultiLineOptions += "# ADD LINK32 /LIBPATH:\""; - libMultiLineOptions += *i; + libMultiLineOptions += cmSystemTools::HandleNetworkPaths(i->c_str()); libMultiLineOptions += "/$(IntDir)\" "; libMultiLineOptions += " /LIBPATH:\""; - libMultiLineOptions += *i; + libMultiLineOptions += cmSystemTools::HandleNetworkPaths(i->c_str()); libMultiLineOptions += "\" \n"; } // find link libraries @@ -546,21 +537,6 @@ void cmDSPWriter::WriteDSPHeader(std::ostream& fout, const char *libName, lib += ".lib"; } lib = cmSystemTools::EscapeSpaces(lib.c_str()); - // watch for network paths, MSVC can't seem to load // - if (strlen(lib.c_str()) > 2 && lib.c_str()[0] == '/' && - lib.c_str()[1] == '/') - { - std::string lib2 = "\\\\"; - lib2 += (lib.c_str() + 2); - lib = lib2; - } - if (strlen(lib.c_str()) > 3 && lib.c_str()[0] == '"' && - lib.c_str()[1] == '/' && lib.c_str()[2] == '/') - { - std::string lib2 = "\"\\\\"; - lib2 += (lib.c_str() + 3); - lib = lib2; - } if (j->second == cmTarget::GENERAL) { @@ -630,9 +606,9 @@ void cmDSPWriter::WriteDSPHeader(std::ostream& fout, const char *libName, m_IncludeOptions.c_str()); cmSystemTools::ReplaceString(line, "OUTPUT_LIBNAME",libName); cmSystemTools::ReplaceString(line, "LIBRARY_OUTPUT_PATH", - libPath.c_str()); + cmSystemTools::HandleNetworkPaths(libPath.c_str()).c_str()); cmSystemTools::ReplaceString(line, "EXECUTABLE_OUTPUT_PATH", - exePath.c_str()); + cmSystemTools::HandleNetworkPaths(exePath.c_str()).c_str()); cmSystemTools::ReplaceString(line, "EXTRA_DEFINES", m_Makefile->GetDefineFlags()); diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 72ffca0..557a80d 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -313,11 +313,34 @@ void cmSystemTools::ExpandRegistryValues(std::string& source) } +std::string cmSystemTools::HandleNetworkPaths(const char* str) +{ +#if defined(_WIN32) && !defined(__CYGWIN__) + std::string result; + // watch for network paths, MSVC can't seem to load // + if (strlen(str) > 2 && str[0] == '/' && str[1] == '/') + { + result = "\\\\"; + result += (str + 2); + } + else + { + result += str; + } +#else + std::string result = ""; +#endif + return result; +} + std::string cmSystemTools::EscapeSpaces(const char* str) { #if defined(_WIN32) && !defined(__CYGWIN__) - std::string result = str; - return "\""+result+"\""; + std::string result; + + result = "\""; + result += cmSystemTools::HandleNetworkPaths(str); + return result+"\""; #else std::string result = ""; for(const char* ch = str; *ch != '\0'; ++ch) diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h index c63da9b..75c53d3 100644 --- a/Source/cmSystemTools.h +++ b/Source/cmSystemTools.h @@ -73,6 +73,11 @@ public: static void ExpandRegistryValues(std::string& source); /** + * make sure on windows that paths with // are converted to \\ + */ + static std::string HandleNetworkPaths(const char*); + + /** * Return a string equivalent to the input string, but with all " " replaced * with "\ " to escape the spaces. */ -- cgit v0.12