From c80c5d245d6a11182d308ebec62984bd3043d07c Mon Sep 17 00:00:00 2001 From: Bill Hoffman Date: Thu, 29 Nov 2001 23:24:37 -0500 Subject: [PATCH] ENH: fix various problems caused by the generalization of nmake generator --- Source/Makefile.borland | 3 ++ Source/cmBorlandMakefileGenerator2.cxx | 58 ++++++++++++++-------- Source/cmNMakeMakefileGenerator.cxx | 1 + Source/cmUnixMakefileGenerator.cxx | 13 ++--- Templates/CMakeSystemConfig.cmake.in | 2 +- Templates/CMakeWindowsBorlandConfig2.cmake | 14 ++++++ 6 files changed, 63 insertions(+), 28 deletions(-) diff --git a/Source/Makefile.borland b/Source/Makefile.borland index 4c8b8a040f..64c0cc250d 100644 --- a/Source/Makefile.borland +++ b/Source/Makefile.borland @@ -9,6 +9,9 @@ .cxx.obj: bcc32 -Pcxx -c -DCMAKE_ROOT_DIR='"."' {$< } +.cpp.obj: + bcc32 -Pcxx -c -DCMAKE_ROOT_DIR='"."' {$< } + OBJS = \ cmake.obj \ diff --git a/Source/cmBorlandMakefileGenerator2.cxx b/Source/cmBorlandMakefileGenerator2.cxx index befcb5907d..8461d57f8b 100644 --- a/Source/cmBorlandMakefileGenerator2.cxx +++ b/Source/cmBorlandMakefileGenerator2.cxx @@ -83,12 +83,12 @@ void cmBorlandMakefileGenerator2::OutputMakeVariables(std::ostream& fout) const char* variables = "# general varibles used in the makefile\n" "\n" - "# Path to cmake\n" - "CMAKE_COMMAND = ${CMAKE_COMMAND}\n" "CMAKE_STANDARD_WINDOWS_LIBRARIES = @CMAKE_STANDARD_WINDOWS_LIBRARIES@\n" - "CMAKE_C_COMPILER = @CMAKE_C_COMPILER@ \n" "CMAKE_C_FLAGS = @CMAKE_C_FLAGS@ @BUILD_FLAGS@\n" - "CMAKE_CXX_COMPILER = @CMAKE_CXX_COMPILER@\n" + "CMAKE_OBJECT_FILE_SUFFIX = @CMAKE_OBJECT_FILE_SUFFIX@\n" + "CMAKE_EXECUTABLE_SUFFIX = @CMAKE_EXECUTABLE_SUFFIX@\n" + "CMAKE_STATICLIB_SUFFIX = @CMAKE_STATICLIB_SUFFIX@\n" + "CMAKE_SHLIB_SUFFIX = @CMAKE_SHLIB_SUFFIX@\n" "CMAKE_CXXFLAGS = -P @CMAKE_CXX_FLAGS@ @BUILD_FLAGS@\n"; std::string buildType = "CMAKE_CXX_FLAGS_"; buildType += m_Makefile->GetDefinition("CMAKE_BUILD_TYPE"); @@ -98,6 +98,21 @@ void cmBorlandMakefileGenerator2::OutputMakeVariables(std::ostream& fout) buildType.c_str())); std::string replaceVars = variables; m_Makefile->ExpandVariablesInString(replaceVars); + + std::string ccompiler = m_Makefile->GetDefinition("CMAKE_C_COMPILER"); + cmSystemTools::ConvertToWindowsSlashes(ccompiler); + fout << "CMAKE_C_COMPILER = " << cmSystemTools::EscapeSpaces(ccompiler.c_str()) + << "\n"; + std::string cxxcompiler = m_Makefile->GetDefinition("CMAKE_CXX_COMPILER"); + cmSystemTools::ConvertToWindowsSlashes(cxxcompiler); + fout << "CMAKE_CXX_COMPILER = " << cmSystemTools::EscapeSpaces(cxxcompiler.c_str()) + << "\n"; + + + std::string cmakecommand = m_Makefile->GetDefinition("CMAKE_COMMAND"); + cmSystemTools::ConvertToWindowsSlashes(cmakecommand); + fout << "CMAKE_COMMAND = " << cmSystemTools::EscapeSpaces(cmakecommand.c_str()) << "\n"; + fout << replaceVars.c_str(); fout << "CMAKE_CURRENT_SOURCE = " << ShortPath(m_Makefile->GetStartDirectory() ) @@ -302,18 +317,20 @@ void cmBorlandMakefileGenerator2::OutputSharedLibraryRule(std::ostream& fout, const char* name, const cmTarget &t) { - std::string target = m_LibraryOutputPath + name + ".dll"; + std::string target = m_LibraryOutputPath + name; + std::string libpath = target + ".lib"; + target += ".dll"; + cmSystemTools::ConvertToWindowsSlashes(libpath); + cmSystemTools::ConvertToWindowsSlashes(target); + target = cmSystemTools::EscapeSpaces(target.c_str()); + libpath = cmSystemTools::EscapeSpaces(libpath.c_str()); std::string depend = "$("; depend += name; depend += "_SRC_OBJS) $(" + std::string(name) + "_DEPEND_LIBS)"; std::string command = "$(CMAKE_CXX_COMPILER) -tWD @&&|\n"; - std::string dllpath = m_LibraryOutputPath + std::string(name); - std::string libpath = dllpath + ".lib"; - dllpath += ".dll"; - cmSystemTools::ConvertToWindowsSlashes(dllpath); // must be executable name command += "-e"; - command += cmSystemTools::EscapeSpaces(dllpath.c_str()); + command += target; command += " "; std::strstream linklibs; this->OutputLinkLibraries(linklibs, name, t); @@ -324,7 +341,7 @@ void cmBorlandMakefileGenerator2::OutputSharedLibraryRule(std::ostream& fout, // then list of object files command += " $(" + std::string(name) + "_SRC_OBJS) "; std::string command2 = "implib -w "; - command2 += libpath + " " + dllpath; + command2 += libpath + " " + target; const std::vector& sources = t.GetSourceFiles(); for(std::vector::const_iterator i = sources.begin(); i != sources.end(); ++i) @@ -357,16 +374,16 @@ void cmBorlandMakefileGenerator2::OutputStaticLibraryRule(std::ostream& fout, const cmTarget &) { std::string target = m_LibraryOutputPath + std::string(name) + ".lib"; + cmSystemTools::ConvertToWindowsSlashes(target); + target = cmSystemTools::EscapeSpaces(target.c_str()); std::string depend = "$("; depend += std::string(name) + "_SRC_OBJS)"; std::string command = "tlib @&&|\n\t /u "; - std::string libpath = m_LibraryOutputPath + std::string(name) + ".lib"; - cmSystemTools::ConvertToWindowsSlashes(libpath); - command += cmSystemTools::EscapeSpaces(libpath.c_str()); + command += target; std::string deleteCommand = "if exist "; - deleteCommand += libpath; + deleteCommand += target; deleteCommand += " del "; - deleteCommand += libpath; + deleteCommand += target; command += " $("; command += std::string(name) + "_SRC_OBJS)"; command += "\n|\n"; @@ -385,15 +402,14 @@ void cmBorlandMakefileGenerator2::OutputExecutableRule(std::ostream& fout, const char* name, const cmTarget &t) { - std::string target = m_ExecutableOutputPath + name; - target += ".exe"; + std::string target = m_ExecutableOutputPath + name + m_ExecutableExtension; + cmSystemTools::ConvertToWindowsSlashes(target); + target = cmSystemTools::EscapeSpaces(target.c_str()); std::string depend = "$("; depend += std::string(name) + "_SRC_OBJS) $(" + std::string(name) + "_DEPEND_LIBS)"; std::string command = "$(CMAKE_CXX_COMPILER) "; - std::string path = m_ExecutableOutputPath + name + ".exe"; - command += " -e" + - cmSystemTools::EscapeSpaces(path.c_str()); + command += " -e" + target; if(t.GetType() == cmTarget::WIN32_EXECUTABLE) { command += " -tWM "; diff --git a/Source/cmNMakeMakefileGenerator.cxx b/Source/cmNMakeMakefileGenerator.cxx index 3c208a7386..b392b7500e 100644 --- a/Source/cmNMakeMakefileGenerator.cxx +++ b/Source/cmNMakeMakefileGenerator.cxx @@ -69,6 +69,7 @@ cmNMakeMakefileGenerator::~cmNMakeMakefileGenerator() std::string cmNMakeMakefileGenerator::ShortPath(const char* path) { std::string ret = path; + cmSystemTools::ConvertToWindowsSlashes(ret); // if there are no spaces in path, then just return path if(ret.find(' ') == std::string::npos) { diff --git a/Source/cmUnixMakefileGenerator.cxx b/Source/cmUnixMakefileGenerator.cxx index e100b7c14d..33842ec4bc 100644 --- a/Source/cmUnixMakefileGenerator.cxx +++ b/Source/cmUnixMakefileGenerator.cxx @@ -235,12 +235,13 @@ void cmUnixMakefileGenerator::OutputMakefile(const char* file) for(std::vector::const_iterator i = lfiles.begin(); i != lfiles.end(); ++i) { - fout << " " << cmSystemTools::EscapeSpaces(i->c_str()); + fout << " " << this->ConvertToNativePath(cmSystemTools::EscapeSpaces(i->c_str()).c_str()); } // Add the cache to the list std::string cacheFile = m_Makefile->GetHomeOutputDirectory(); cacheFile += "/CMakeCache.txt"; - fout << " " << cmSystemTools::EscapeSpaces(cacheFile.c_str()); + fout << " " << + this->ConvertToNativePath(cmSystemTools::EscapeSpaces(cacheFile.c_str()).c_str()); fout << "\n\n\n"; this->OutputMakeVariables(fout); // Set up the default target as the VERY first target, so that make with no arguments will run it @@ -309,21 +310,21 @@ void cmUnixMakefileGenerator::OutputTargetRules(std::ostream& fout) { path = path + l->first + m_StaticLibraryExtension; fout << " \\\n" - << cmSystemTools::EscapeSpaces(path.c_str()); + << this->ConvertToNativePath(cmSystemTools::EscapeSpaces(path.c_str()).c_str()); } else if(l->second.GetType() == cmTarget::SHARED_LIBRARY) { path = path + l->first + m_Makefile->GetDefinition("CMAKE_SHLIB_SUFFIX"); fout << " \\\n" - << cmSystemTools::EscapeSpaces(path.c_str()); + << this->ConvertToNativePath(cmSystemTools::EscapeSpaces(path.c_str()).c_str()); } else if(l->second.GetType() == cmTarget::MODULE_LIBRARY) { path = path + l->first + m_Makefile->GetDefinition("CMAKE_MODULE_SUFFIX"); fout << " \\\n" - << cmSystemTools::EscapeSpaces(path.c_str()); + << this->ConvertToNativePath(cmSystemTools::EscapeSpaces(path.c_str()).c_str()); } } } @@ -337,7 +338,7 @@ void cmUnixMakefileGenerator::OutputTargetRules(std::ostream& fout) { std::string path = m_ExecutableOutputPath + l->first + m_ExecutableExtension; - fout << " \\\n" << cmSystemTools::EscapeSpaces(path.c_str()); + fout << " \\\n" << this->ConvertToNativePath(cmSystemTools::EscapeSpaces(path.c_str()).c_str()); } } // list utilities last diff --git a/Templates/CMakeSystemConfig.cmake.in b/Templates/CMakeSystemConfig.cmake.in index b9835ded24..b06ae8ae8d 100644 --- a/Templates/CMakeSystemConfig.cmake.in +++ b/Templates/CMakeSystemConfig.cmake.in @@ -101,7 +101,7 @@ SET (CMAKE_X_CFLAGS "@X_CFLAGS@" CACHE STRING "X11 extra flags.") SET (CMAKE_HAS_X @CMAKE_HAS_X@ CACHE INTERNAL - "Is X11 around".) + "Is X11 around.") SET (CMAKE_NO_ANSI_STREAM_HEADERS @CMAKE_NO_ANSI_STREAM_HEADERS@ CACHE INTERNAL "Does the compiler support headers like iostream.") diff --git a/Templates/CMakeWindowsBorlandConfig2.cmake b/Templates/CMakeWindowsBorlandConfig2.cmake index 73f016837e..c83ce7f95e 100644 --- a/Templates/CMakeWindowsBorlandConfig2.cmake +++ b/Templates/CMakeWindowsBorlandConfig2.cmake @@ -51,6 +51,20 @@ SET (CMAKE_STANDARD_WINDOWS_LIBRARIES "import32.lib" CACHE STRING SET (CMAKE_SHLIB_SUFFIX ".dll" CACHE STRING "Shared library suffix.") +SET (CMAKE_MODULE_SUFFIX ".dll" CACHE STRING + "Module library suffix.") +SET (CMAKE_OBJECT_FILE_SUFFIX ".obj" CACHE STRING + "Object file suffix.") + +SET (CMAKE_EXECUTABLE_SUFFIX ".exe" CACHE STRING + "Executable suffix.") + +SET (CMAKE_STATICLIB_SUFFIX ".lib" CACHE STRING + "Static library suffix.") + +SET (CMAKE_SHLIB_SUFFIX ".dll" CACHE STRING + "Shared library suffix.") + SET (CMAKE_MODULE_SUFFIX ".dll" CACHE STRING "Module library suffix.")