From 0d3eefb1f1602bb39319ff2173b94cd1874e1c29 Mon Sep 17 00:00:00 2001 From: Bill Hoffman Date: Fri, 30 Nov 2001 16:48:52 -0500 Subject: new borland generator moved into place --- Source/CMakeLib.dsp | 10 +- Source/CMakeLists.txt | 5 +- Source/Makefile.borland | 4 - Source/Makefile.in | 1 + Source/cmBorlandMakefileGenerator.cxx | 489 ++++++++++++++++++++++++ Source/cmBorlandMakefileGenerator.h | 114 ++++++ Source/cmBorlandMakefileGenerator2.cxx | 489 ------------------------ Source/cmBorlandMakefileGenerator2.h | 114 ------ Source/cmForEachCommand.cxx | 2 +- Source/cmake.cxx | 2 - Source/cmakemain.cxx | 24 +- Source/cmakewizard.cxx | 69 ++-- Templates/CMakeBorlandWindowsSystemConfig.cmake | 71 ++++ Templates/CMakeWindowsBorlandConfig.cmake | 97 ----- Templates/CMakeWindowsBorlandConfig2.cmake | 71 ---- 15 files changed, 742 insertions(+), 820 deletions(-) create mode 100644 Source/cmBorlandMakefileGenerator.cxx create mode 100644 Source/cmBorlandMakefileGenerator.h delete mode 100644 Source/cmBorlandMakefileGenerator2.cxx delete mode 100644 Source/cmBorlandMakefileGenerator2.h create mode 100644 Templates/CMakeBorlandWindowsSystemConfig.cmake delete mode 100644 Templates/CMakeWindowsBorlandConfig.cmake delete mode 100644 Templates/CMakeWindowsBorlandConfig2.cmake diff --git a/Source/CMakeLib.dsp b/Source/CMakeLib.dsp index 53628cd..58ea7c0 100644 --- a/Source/CMakeLib.dsp +++ b/Source/CMakeLib.dsp @@ -95,11 +95,7 @@ SOURCE=.\cmNMakeMakefileGenerator.cxx # End Source File # Begin Source File -SOURCE=.\cmBorlandMakefileGenerator.cpp -# End Source File -# Begin Source File - -SOURCE=.\cmBorlandMakefileGenerator2.cxx +SOURCE=.\cmBorlandMakefileGenerator.cxx # End Source File # Begin Source File @@ -119,6 +115,10 @@ SOURCE=.\cmCustomCommand.cxx # End Source File # Begin Source File +SOURCE=.\cmakewizard.cxx +# End Source File +# Begin Source File + SOURCE=.\cmDirectory.cxx # End Source File # Begin Source File diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 8a94d6c..b0c7861 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -10,6 +10,7 @@ ENDIF(FLTK_LIBRARY) SOURCE_FILES(SRCS cmake.cxx +cmakewizard.cxx cmMakeDepend.cxx cmMakefile.cxx cmMakefileGenerator.cxx @@ -37,8 +38,7 @@ ADD_DEFINITIONS(-DCMAKE_BUILD_WITH_CMAKE) IF (WIN32) SOURCE_FILES(SRCS cmDSWWriter.cxx cmDSPWriter.cxx cmMSProjectGenerator.cxx) - SOURCE_FILES(SRCS cmBorlandMakefileGenerator2.cxx) - SOURCE_FILES(SRCS cmBorlandMakefileGenerator.cpp) + SOURCE_FILES(SRCS cmBorlandMakefileGenerator.cxx) SOURCE_FILES(SRCS cmNMakeMakefileGenerator.cxx) IF(NOT UNIX) IF( NOT BORLAND ) @@ -67,7 +67,6 @@ LINK_LIBRARIES(CMakeLib) LINK_DIRECTORIES(${CMake_BINARY_DIR}/Source) ADD_EXECUTABLE(cmake cmakemain) -ADD_EXECUTABLE(cmakewizard cmakewizard) ADD_EXECUTABLE(DumpDocumentation cmDumpDocumentation) ADD_EXECUTABLE(ctest ctest.cxx cmSystemTools.cxx cmRegularExpression.cxx) diff --git a/Source/Makefile.borland b/Source/Makefile.borland index 64c0cc2..0f689b5 100644 --- a/Source/Makefile.borland +++ b/Source/Makefile.borland @@ -9,9 +9,6 @@ .cxx.obj: bcc32 -Pcxx -c -DCMAKE_ROOT_DIR='"."' {$< } -.cpp.obj: - bcc32 -Pcxx -c -DCMAKE_ROOT_DIR='"."' {$< } - OBJS = \ cmake.obj \ @@ -28,7 +25,6 @@ cmMSProjectGenerator.obj \ cmDSPWriter.obj \ cmDSWWriter.obj \ cmNMakeMakefileGenerator.obj \ -cmBorlandMakefileGenerator2.obj \ cmBorlandMakefileGenerator.obj \ cmCommands.obj \ cmTarget.obj \ diff --git a/Source/Makefile.in b/Source/Makefile.in index 4bb195a..28325a8 100644 --- a/Source/Makefile.in +++ b/Source/Makefile.in @@ -15,6 +15,7 @@ all: cmake OBJS = \ cmake.o \ +cmakewizard.o \ cmakemain.o \ cmMakeDepend.o \ cmMakefile.o \ diff --git a/Source/cmBorlandMakefileGenerator.cxx b/Source/cmBorlandMakefileGenerator.cxx new file mode 100644 index 0000000..91fc6d5 --- /dev/null +++ b/Source/cmBorlandMakefileGenerator.cxx @@ -0,0 +1,489 @@ +/*========================================================================= + + Program: Insight Segmentation & Registration Toolkit + Module: $RCSfile$ + Language: C++ + Date: $Date$ + Version: $Revision$ + +Copyright (c) 2001 Insight Consortium +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + * The name of the Insight Consortium, nor the names of any consortium members, + nor of any contributors, may be used to endorse or promote products derived + from this software without specific prior written permission. + + * Modified source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS ``AS IS'' +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +=========================================================================*/ +#include "cmBorlandMakefileGenerator.h" +#include "cmMakefile.h" +#include "cmStandardIncludes.h" +#include "cmSystemTools.h" +#include "cmSourceFile.h" +#include "cmMakeDepend.h" +#include "cmCacheManager.h" +#include "cmGeneratedFileStream.h" +#include "windows.h" + + +cmBorlandMakefileGenerator::cmBorlandMakefileGenerator() +{ + this->SetLibraryPathOption("-L"); + this->SetLibraryLinkOption(""); +} + +cmBorlandMakefileGenerator::~cmBorlandMakefileGenerator() +{ +} + + +void cmBorlandMakefileGenerator::ComputeSystemInfo() +{ + // now load the settings + if(!m_Makefile->GetDefinition("CMAKE_ROOT")) + { + cmSystemTools::Error( + "CMAKE_ROOT has not been defined, bad GUI or driver program"); + return; + } + std::string fpath = + m_Makefile->GetDefinition("CMAKE_ROOT"); + fpath += "/Templates/CMakeBorlandWindowsSystemConfig.cmake"; + m_Makefile->ReadListFile(NULL,fpath.c_str()); +} + + + +void cmBorlandMakefileGenerator::OutputMakeVariables(std::ostream& fout) +{ + fout << "# NMake Makefile generated by cmake\n"; + const char* variables = + "# general varibles used in the makefile\n" + "\n" + "CMAKE_STANDARD_WINDOWS_LIBRARIES = @CMAKE_STANDARD_WINDOWS_LIBRARIES@\n" + "CMAKE_C_FLAGS = @CMAKE_C_FLAGS@ @BUILD_FLAGS@\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_CXX_FLAGS = -P @CMAKE_CXX_FLAGS@ @BUILD_FLAGS@\n"; + std::string buildType = "CMAKE_CXX_FLAGS_"; + buildType += m_Makefile->GetDefinition("CMAKE_BUILD_TYPE"); + buildType = cmSystemTools::UpperCase(buildType); + m_Makefile->AddDefinition("BUILD_FLAGS", + m_Makefile->GetDefinition( + 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() ) + << "\n"; + fout << "CMAKE_CURRENT_BINARY = " + << ShortPath(m_Makefile->GetStartOutputDirectory()) + << "\n"; + fout << "CMAKE_SOURCE_DIR = " + << ShortPath(m_Makefile->GetHomeDirectory()) << "\n"; + fout << "CMAKE_BINARY_DIR = " + << ShortPath(m_Makefile->GetHomeOutputDirectory() ) + << "\n"; + // Output Include paths + fout << "INCLUDE_FLAGS = "; + std::vector& includes = m_Makefile->GetIncludeDirectories(); + std::vector::iterator i; + fout << "-I" << cmSystemTools::EscapeSpaces(m_Makefile->GetStartDirectory()) << " "; + for(i = includes.begin(); i != includes.end(); ++i) + { + std::string include = *i; + // Don't output a -I for the standard include path "/usr/include". + // This can cause problems with certain standard library + // implementations because the wrong headers may be found first. + if(include != "/usr/include") + { + fout << "-I" << cmSystemTools::EscapeSpaces(i->c_str()).c_str() << " "; + } + } + fout << m_Makefile->GetDefineFlags(); + fout << "\n\n"; +} + + +void cmBorlandMakefileGenerator::BuildInSubDirectory(std::ostream& fout, + const char* directory, + const char* target1, + const char* target2) +{ + if(target1) + { + std::string dir = directory; + cmSystemTools::ConvertToWindowsSlashes(dir); + fout << "\tif not exist " << cmSystemTools::EscapeSpaces(dir.c_str()) + << " " + << "$(MAKE) rebuild_cache\n" + << "\tcd .\\" << directory << "\n" + << "\t$(MAKE) -$(MAKEFLAGS) " << target1 << "\n"; + } + if(target2) + { + fout << "\t$(MAKE) -$(MAKEFLAGS) " << target2 << "\n"; + } + std::string currentDir = m_Makefile->GetCurrentOutputDirectory(); + cmSystemTools::ConvertToWindowsSlashes(currentDir); + fout << "\tcd " << cmSystemTools::EscapeSpaces(currentDir.c_str()) << "\n"; +} + + + + +// This needs to be overriden because nmake requires commands to be quoted +// if the are full paths to the executable???? + +void cmBorlandMakefileGenerator::OutputMakeRule(std::ostream& fout, + const char* comment, + const char* target, + const char* depends, + const char* command, + const char* command2, + const char* command3, + const char* command4) +{ + if(!target) + { + cmSystemTools::Error("no target for OutputMakeRule"); + return; + } + + std::string replace; + if(comment) + { + replace = comment; + m_Makefile->ExpandVariablesInString(replace); + fout << "#---------------------------------------------------------\n"; + fout << "# " << comment; + fout << "\n#\n"; + } + fout << "\n"; + replace = target; + m_Makefile->ExpandVariablesInString(replace); + replace = cmSystemTools::EscapeSpaces(replace.c_str()); + fout << replace.c_str() << ": "; + if(depends) + { + replace = depends; + m_Makefile->ExpandVariablesInString(replace); + fout << replace.c_str(); + } + fout << "\n"; + const char* startCommand = "\t"; + const char* endCommand = "\n"; + if(command) + { + replace = ShortPathCommand(command); + m_Makefile->ExpandVariablesInString(replace); + fout << startCommand << replace.c_str() << endCommand; + } + if(command2) + { + replace = ShortPathCommand(command2); + m_Makefile->ExpandVariablesInString(replace); + fout << startCommand << replace.c_str() << endCommand; + } + if(command3) + { + replace = ShortPathCommand(command3); + m_Makefile->ExpandVariablesInString(replace); + fout << startCommand << replace.c_str() << endCommand; + } + if(command4) + { + replace = ShortPathCommand(command4); + m_Makefile->ExpandVariablesInString(replace); + fout << startCommand << replace.c_str() << endCommand; + } + fout << "\n"; + // reset m_QuoteNextCommand, as the default should be to quote the + // commands. We need the quotes when the command has a full path + // to an executable. However, the quotes break things like the + // linker command. + m_QuoteNextCommand = true; +} + +void +cmBorlandMakefileGenerator:: +OutputBuildObjectFromSource(std::ostream& fout, + const char* shortName, + const cmSourceFile& source, + const char* extraCompileFlags, + bool shared) +{ + std::string comment = "Build "; + std::string objectFile = std::string(shortName) + + this->GetOutputExtension(source.GetSourceExtension().c_str()); + cmSystemTools::ConvertToWindowsSlashes(objectFile); + comment += objectFile + " From "; + comment += source.GetFullPath(); + std::string compileCommand; + std::string ext = source.GetSourceExtension(); + if(ext == "c" ) + { + compileCommand = "$(CMAKE_C_COMPILER) $(CMAKE_C_FLAGS) "; + compileCommand += extraCompileFlags; + if(shared) + { + compileCommand += "$(CMAKE_SHLIB_CFLAGS) "; + } + compileCommand += " -o"; + compileCommand += objectFile; + compileCommand += " $(INCLUDE_FLAGS) -c "; + compileCommand += + cmSystemTools::EscapeSpaces(source.GetFullPath().c_str()); + } + else if (ext == "rc") + { + compileCommand = "$(RC) -o\""; + compileCommand += objectFile; + compileCommand += "\" "; + compileCommand += + cmSystemTools::EscapeSpaces(source.GetFullPath().c_str()); + } + else if (ext == "def") + { + // no rule to output for this one + return; + } + // assume c++ if not c rc or def + else + { + compileCommand = "$(CMAKE_CXX_COMPILER) $(CMAKE_CXX_FLAGS) "; + compileCommand += extraCompileFlags; + if(shared) + { + compileCommand += "$(CMAKE_SHLIB_CFLAGS) "; + } + compileCommand += " -o"; + compileCommand += objectFile; + compileCommand += " $(INCLUDE_FLAGS) -c "; + compileCommand += + cmSystemTools::EscapeSpaces(source.GetFullPath().c_str()); + } + m_QuoteNextCommand = false; + this->OutputMakeRule(fout, + comment.c_str(), + objectFile.c_str(), + cmSystemTools::EscapeSpaces( + source.GetFullPath().c_str()).c_str(), + compileCommand.c_str()); +} + +void cmBorlandMakefileGenerator::OutputSharedLibraryRule(std::ostream& fout, + const char* name, + const cmTarget &t) +{ + 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"; + // must be executable name + command += "-e"; + command += target; + command += " "; + std::strstream linklibs; + this->OutputLinkLibraries(linklibs, name, t); + linklibs << std::ends; + // then the linker options -L and libraries (any other order will fail!) + command += linklibs.str(); + delete [] linklibs.str(); + // then list of object files + command += " $(" + std::string(name) + "_SRC_OBJS) "; + std::string command2 = "implib -w "; + command2 += libpath + " " + target; + const std::vector& sources = t.GetSourceFiles(); + for(std::vector::const_iterator i = sources.begin(); + i != sources.end(); ++i) + { + if(i->GetSourceExtension() == "def") + { + command += ""; + command += i->GetFullPath(); + } + } + command += "\n|\n"; + m_QuoteNextCommand = false; + + this->OutputMakeRule(fout, "rules for a shared library", + target.c_str(), + depend.c_str(), + command.c_str(), + command2.c_str()); +} + +void cmBorlandMakefileGenerator::OutputModuleLibraryRule(std::ostream& fout, + const char* name, + const cmTarget &target) +{ + this->OutputSharedLibraryRule(fout, name, target); +} + +void cmBorlandMakefileGenerator::OutputStaticLibraryRule(std::ostream& fout, + const char* name, + 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 "; + command += target; + std::string deleteCommand = "if exist "; + deleteCommand += target; + deleteCommand += " del "; + deleteCommand += target; + command += " $("; + command += std::string(name) + "_SRC_OBJS)"; + command += "\n|\n"; + std::string comment = "rule to build static library: "; + comment += name; + m_QuoteNextCommand = false; + this->OutputMakeRule(fout, + comment.c_str(), + target.c_str(), + depend.c_str(), + deleteCommand.c_str(), + command.c_str()); +} + +void cmBorlandMakefileGenerator::OutputExecutableRule(std::ostream& fout, + const char* name, + const cmTarget &t) +{ + 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) "; + command += " -e" + target; + if(t.GetType() == cmTarget::WIN32_EXECUTABLE) + { + command += " -tWM "; + } + else + { + command += " -tWC "; + } + std::strstream linklibs; + this->OutputLinkLibraries(linklibs, 0, t); + linklibs << std::ends; + command += linklibs.str(); + delete [] linklibs.str(); + command += " $(" + std::string(name) + "_SRC_OBJS) "; + + std::string comment = "rule to build executable: "; + comment += name; + m_QuoteNextCommand = false; + this->OutputMakeRule(fout, + comment.c_str(), + target.c_str(), + depend.c_str(), + command.c_str()); +} + + + + +std::string cmBorlandMakefileGenerator::GetOutputExtension(const char* s) +{ + std::string sourceExtension = s; + if(sourceExtension == "def") + { + return ""; + } + if(sourceExtension == "ico" || sourceExtension == "rc2") + { + return ""; + } + if(sourceExtension == "rc") + { + return ".res"; + } + return ".obj"; +} + + + +bool cmBorlandMakefileGenerator::SamePath(const char* path1, const char* path2) +{ + // first check to see if they are the same anyway + if (strcmp(path1, path2) == 0) + { + return true; + } + // next short path and lower case both of them for the compare + return + cmSystemTools::LowerCase(ShortPath(path1)) == + cmSystemTools::LowerCase(ShortPath(path2)); +} + +void cmBorlandMakefileGenerator::OutputBuildLibraryInDir(std::ostream& fout, + const char* path, + const char* s, + const char* fullpath) +{ + cmNMakeMakefileGenerator::OutputBuildLibraryInDir(fout, path, s, fullpath); +} + + +std::string cmBorlandMakefileGenerator::ConvertToNativePath(const char* s) +{ + std::string ret = s; + cmSystemTools::ConvertToWindowsSlashes(ret); + return ret; +} + diff --git a/Source/cmBorlandMakefileGenerator.h b/Source/cmBorlandMakefileGenerator.h new file mode 100644 index 0000000..aa22c39 --- /dev/null +++ b/Source/cmBorlandMakefileGenerator.h @@ -0,0 +1,114 @@ +/*========================================================================= + + Program: Insight Segmentation & Registration Toolkit + Module: $RCSfile$ + Language: C++ + Date: $Date$ + Version: $Revision$ + +Copyright (c) 2001 Insight Consortium +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + * The name of the Insight Consortium, nor the names of any consortium members, + nor of any contributors, may be used to endorse or promote products derived + from this software without specific prior written permission. + + * Modified source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS ``AS IS'' +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +=========================================================================*/ +#ifndef cmBorlandMakefileGenerator_h +#define cmBorlandMakefileGenerator_h + +#include "cmNMakeMakefileGenerator.h" + +/** \class cmBorlandMakefileGenerator + * \brief Write an NMake makefile. + * + * cmBorlandMakefileGenerator produces a Unix makefile from its + * member m_Makefile. + */ +class cmBorlandMakefileGenerator : public cmNMakeMakefileGenerator +{ +public: + ///! Set cache only and recurse to false by default. + cmBorlandMakefileGenerator(); + + virtual ~cmBorlandMakefileGenerator(); + + ///! Get the name for the generator. + virtual const char* GetName() {return "Borland Makefiles";} + + ///! virtual copy constructor + virtual cmMakefileGenerator* CreateObject() + { return new cmBorlandMakefileGenerator;} + + ///! figure out about the current system information + virtual void ComputeSystemInfo(); +protected: + virtual void OutputMakeVariables(std::ostream&); + virtual void BuildInSubDirectory(std::ostream& fout, + const char* directory, + const char* target1, + const char* target2); + void OutputMakeRule(std::ostream& fout, + const char* comment, + const char* target, + const char* depends, + const char* command, + const char* command2=0, + const char* command3=0, + const char* command4=0); + + + virtual void OutputBuildObjectFromSource(std::ostream& fout, + const char* shortName, + const cmSourceFile& source, + const char* extraCompileFlags, + bool sharedTarget); + virtual void OutputSharedLibraryRule(std::ostream&, const char* name, + const cmTarget &); + virtual void OutputModuleLibraryRule(std::ostream&, const char* name, + const cmTarget &); + virtual void OutputStaticLibraryRule(std::ostream&, const char* name, + const cmTarget &); + virtual void OutputExecutableRule(std::ostream&, const char* name, + const cmTarget &); + virtual std::string GetOutputExtension(const char* sourceExtension); + virtual void OutputBuildLibraryInDir(std::ostream& fout, + const char* path, + const char* library, + const char* fullpath); + ///! return true if the two paths are the same (checks short paths) + virtual bool SamePath(const char* path1, const char* path2); + virtual std::string ConvertToNativePath(const char* s); + +private: + bool m_QuoteNextCommand; // if this is true, OutputMakeRule + // will not quote the next commands + // it is reset to false after each + // call to OutputMakeRule +}; + +#endif diff --git a/Source/cmBorlandMakefileGenerator2.cxx b/Source/cmBorlandMakefileGenerator2.cxx deleted file mode 100644 index 26d7afc..0000000 --- a/Source/cmBorlandMakefileGenerator2.cxx +++ /dev/null @@ -1,489 +0,0 @@ -/*========================================================================= - - Program: Insight Segmentation & Registration Toolkit - Module: $RCSfile$ - Language: C++ - Date: $Date$ - Version: $Revision$ - -Copyright (c) 2001 Insight Consortium -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - - * The name of the Insight Consortium, nor the names of any consortium members, - nor of any contributors, may be used to endorse or promote products derived - from this software without specific prior written permission. - - * Modified source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS ``AS IS'' -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -=========================================================================*/ -#include "cmBorlandMakefileGenerator2.h" -#include "cmMakefile.h" -#include "cmStandardIncludes.h" -#include "cmSystemTools.h" -#include "cmSourceFile.h" -#include "cmMakeDepend.h" -#include "cmCacheManager.h" -#include "cmGeneratedFileStream.h" -#include "windows.h" - - -cmBorlandMakefileGenerator2::cmBorlandMakefileGenerator2() -{ - this->SetLibraryPathOption("-L"); - this->SetLibraryLinkOption(""); -} - -cmBorlandMakefileGenerator2::~cmBorlandMakefileGenerator2() -{ -} - - -void cmBorlandMakefileGenerator2::ComputeSystemInfo() -{ - // now load the settings - if(!m_Makefile->GetDefinition("CMAKE_ROOT")) - { - cmSystemTools::Error( - "CMAKE_ROOT has not been defined, bad GUI or driver program"); - return; - } - std::string fpath = - m_Makefile->GetDefinition("CMAKE_ROOT"); - fpath += "/Templates/CMakeWindowsBorlandConfig2.cmake"; - m_Makefile->ReadListFile(NULL,fpath.c_str()); -} - - - -void cmBorlandMakefileGenerator2::OutputMakeVariables(std::ostream& fout) -{ - fout << "# NMake Makefile generated by cmake\n"; - const char* variables = - "# general varibles used in the makefile\n" - "\n" - "CMAKE_STANDARD_WINDOWS_LIBRARIES = @CMAKE_STANDARD_WINDOWS_LIBRARIES@\n" - "CMAKE_C_FLAGS = @CMAKE_C_FLAGS@ @BUILD_FLAGS@\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_CXX_FLAGS = -P @CMAKE_CXX_FLAGS@ @BUILD_FLAGS@\n"; - std::string buildType = "CMAKE_CXX_FLAGS_"; - buildType += m_Makefile->GetDefinition("CMAKE_BUILD_TYPE"); - buildType = cmSystemTools::UpperCase(buildType); - m_Makefile->AddDefinition("BUILD_FLAGS", - m_Makefile->GetDefinition( - 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() ) - << "\n"; - fout << "CMAKE_CURRENT_BINARY = " - << ShortPath(m_Makefile->GetStartOutputDirectory()) - << "\n"; - fout << "CMAKE_SOURCE_DIR = " - << ShortPath(m_Makefile->GetHomeDirectory()) << "\n"; - fout << "CMAKE_BINARY_DIR = " - << ShortPath(m_Makefile->GetHomeOutputDirectory() ) - << "\n"; - // Output Include paths - fout << "INCLUDE_FLAGS = "; - std::vector& includes = m_Makefile->GetIncludeDirectories(); - std::vector::iterator i; - fout << "-I" << cmSystemTools::EscapeSpaces(m_Makefile->GetStartDirectory()) << " "; - for(i = includes.begin(); i != includes.end(); ++i) - { - std::string include = *i; - // Don't output a -I for the standard include path "/usr/include". - // This can cause problems with certain standard library - // implementations because the wrong headers may be found first. - if(include != "/usr/include") - { - fout << "-I" << cmSystemTools::EscapeSpaces(i->c_str()).c_str() << " "; - } - } - fout << m_Makefile->GetDefineFlags(); - fout << "\n\n"; -} - - -void cmBorlandMakefileGenerator2::BuildInSubDirectory(std::ostream& fout, - const char* directory, - const char* target1, - const char* target2) -{ - if(target1) - { - std::string dir = directory; - cmSystemTools::ConvertToWindowsSlashes(dir); - fout << "\tif not exist " << cmSystemTools::EscapeSpaces(dir.c_str()) - << " " - << "$(MAKE) rebuild_cache\n" - << "\tcd .\\" << directory << "\n" - << "\t$(MAKE) -$(MAKEFLAGS) " << target1 << "\n"; - } - if(target2) - { - fout << "\t$(MAKE) -$(MAKEFLAGS) " << target2 << "\n"; - } - std::string currentDir = m_Makefile->GetCurrentOutputDirectory(); - cmSystemTools::ConvertToWindowsSlashes(currentDir); - fout << "\tcd " << cmSystemTools::EscapeSpaces(currentDir.c_str()) << "\n"; -} - - - - -// This needs to be overriden because nmake requires commands to be quoted -// if the are full paths to the executable???? - -void cmBorlandMakefileGenerator2::OutputMakeRule(std::ostream& fout, - const char* comment, - const char* target, - const char* depends, - const char* command, - const char* command2, - const char* command3, - const char* command4) -{ - if(!target) - { - cmSystemTools::Error("no target for OutputMakeRule"); - return; - } - - std::string replace; - if(comment) - { - replace = comment; - m_Makefile->ExpandVariablesInString(replace); - fout << "#---------------------------------------------------------\n"; - fout << "# " << comment; - fout << "\n#\n"; - } - fout << "\n"; - replace = target; - m_Makefile->ExpandVariablesInString(replace); - replace = cmSystemTools::EscapeSpaces(replace.c_str()); - fout << replace.c_str() << ": "; - if(depends) - { - replace = depends; - m_Makefile->ExpandVariablesInString(replace); - fout << replace.c_str(); - } - fout << "\n"; - const char* startCommand = "\t"; - const char* endCommand = "\n"; - if(command) - { - replace = ShortPathCommand(command); - m_Makefile->ExpandVariablesInString(replace); - fout << startCommand << replace.c_str() << endCommand; - } - if(command2) - { - replace = ShortPathCommand(command2); - m_Makefile->ExpandVariablesInString(replace); - fout << startCommand << replace.c_str() << endCommand; - } - if(command3) - { - replace = ShortPathCommand(command3); - m_Makefile->ExpandVariablesInString(replace); - fout << startCommand << replace.c_str() << endCommand; - } - if(command4) - { - replace = ShortPathCommand(command4); - m_Makefile->ExpandVariablesInString(replace); - fout << startCommand << replace.c_str() << endCommand; - } - fout << "\n"; - // reset m_QuoteNextCommand, as the default should be to quote the - // commands. We need the quotes when the command has a full path - // to an executable. However, the quotes break things like the - // linker command. - m_QuoteNextCommand = true; -} - -void -cmBorlandMakefileGenerator2:: -OutputBuildObjectFromSource(std::ostream& fout, - const char* shortName, - const cmSourceFile& source, - const char* extraCompileFlags, - bool shared) -{ - std::string comment = "Build "; - std::string objectFile = std::string(shortName) + - this->GetOutputExtension(source.GetSourceExtension().c_str()); - cmSystemTools::ConvertToWindowsSlashes(objectFile); - comment += objectFile + " From "; - comment += source.GetFullPath(); - std::string compileCommand; - std::string ext = source.GetSourceExtension(); - if(ext == "c" ) - { - compileCommand = "$(CMAKE_C_COMPILER) $(CMAKE_C_FLAGS) "; - compileCommand += extraCompileFlags; - if(shared) - { - compileCommand += "$(CMAKE_SHLIB_CFLAGS) "; - } - compileCommand += " -o"; - compileCommand += objectFile; - compileCommand += " $(INCLUDE_FLAGS) -c "; - compileCommand += - cmSystemTools::EscapeSpaces(source.GetFullPath().c_str()); - } - else if (ext == "rc") - { - compileCommand = "$(RC) -o\""; - compileCommand += objectFile; - compileCommand += "\" "; - compileCommand += - cmSystemTools::EscapeSpaces(source.GetFullPath().c_str()); - } - else if (ext == "def") - { - // no rule to output for this one - return; - } - // assume c++ if not c rc or def - else - { - compileCommand = "$(CMAKE_CXX_COMPILER) $(CMAKE_CXX_FLAGS) "; - compileCommand += extraCompileFlags; - if(shared) - { - compileCommand += "$(CMAKE_SHLIB_CFLAGS) "; - } - compileCommand += " -o"; - compileCommand += objectFile; - compileCommand += " $(INCLUDE_FLAGS) -c "; - compileCommand += - cmSystemTools::EscapeSpaces(source.GetFullPath().c_str()); - } - m_QuoteNextCommand = false; - this->OutputMakeRule(fout, - comment.c_str(), - objectFile.c_str(), - cmSystemTools::EscapeSpaces( - source.GetFullPath().c_str()).c_str(), - compileCommand.c_str()); -} - -void cmBorlandMakefileGenerator2::OutputSharedLibraryRule(std::ostream& fout, - const char* name, - const cmTarget &t) -{ - 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"; - // must be executable name - command += "-e"; - command += target; - command += " "; - std::strstream linklibs; - this->OutputLinkLibraries(linklibs, name, t); - linklibs << std::ends; - // then the linker options -L and libraries (any other order will fail!) - command += linklibs.str(); - delete [] linklibs.str(); - // then list of object files - command += " $(" + std::string(name) + "_SRC_OBJS) "; - std::string command2 = "implib -w "; - command2 += libpath + " " + target; - const std::vector& sources = t.GetSourceFiles(); - for(std::vector::const_iterator i = sources.begin(); - i != sources.end(); ++i) - { - if(i->GetSourceExtension() == "def") - { - command += ""; - command += i->GetFullPath(); - } - } - command += "\n|\n"; - m_QuoteNextCommand = false; - - this->OutputMakeRule(fout, "rules for a shared library", - target.c_str(), - depend.c_str(), - command.c_str(), - command2.c_str()); -} - -void cmBorlandMakefileGenerator2::OutputModuleLibraryRule(std::ostream& fout, - const char* name, - const cmTarget &target) -{ - this->OutputSharedLibraryRule(fout, name, target); -} - -void cmBorlandMakefileGenerator2::OutputStaticLibraryRule(std::ostream& fout, - const char* name, - 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 "; - command += target; - std::string deleteCommand = "if exist "; - deleteCommand += target; - deleteCommand += " del "; - deleteCommand += target; - command += " $("; - command += std::string(name) + "_SRC_OBJS)"; - command += "\n|\n"; - std::string comment = "rule to build static library: "; - comment += name; - m_QuoteNextCommand = false; - this->OutputMakeRule(fout, - comment.c_str(), - target.c_str(), - depend.c_str(), - deleteCommand.c_str(), - command.c_str()); -} - -void cmBorlandMakefileGenerator2::OutputExecutableRule(std::ostream& fout, - const char* name, - const cmTarget &t) -{ - 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) "; - command += " -e" + target; - if(t.GetType() == cmTarget::WIN32_EXECUTABLE) - { - command += " -tWM "; - } - else - { - command += " -tWC "; - } - std::strstream linklibs; - this->OutputLinkLibraries(linklibs, 0, t); - linklibs << std::ends; - command += linklibs.str(); - delete [] linklibs.str(); - command += " $(" + std::string(name) + "_SRC_OBJS) "; - - std::string comment = "rule to build executable: "; - comment += name; - m_QuoteNextCommand = false; - this->OutputMakeRule(fout, - comment.c_str(), - target.c_str(), - depend.c_str(), - command.c_str()); -} - - - - -std::string cmBorlandMakefileGenerator2::GetOutputExtension(const char* s) -{ - std::string sourceExtension = s; - if(sourceExtension == "def") - { - return ""; - } - if(sourceExtension == "ico" || sourceExtension == "rc2") - { - return ""; - } - if(sourceExtension == "rc") - { - return ".res"; - } - return ".obj"; -} - - - -bool cmBorlandMakefileGenerator2::SamePath(const char* path1, const char* path2) -{ - // first check to see if they are the same anyway - if (strcmp(path1, path2) == 0) - { - return true; - } - // next short path and lower case both of them for the compare - return - cmSystemTools::LowerCase(ShortPath(path1)) == - cmSystemTools::LowerCase(ShortPath(path2)); -} - -void cmBorlandMakefileGenerator2::OutputBuildLibraryInDir(std::ostream& fout, - const char* path, - const char* s, - const char* fullpath) -{ - cmNMakeMakefileGenerator::OutputBuildLibraryInDir(fout, path, s, fullpath); -} - - -std::string cmBorlandMakefileGenerator2::ConvertToNativePath(const char* s) -{ - std::string ret = s; - cmSystemTools::ConvertToWindowsSlashes(ret); - return ret; -} - diff --git a/Source/cmBorlandMakefileGenerator2.h b/Source/cmBorlandMakefileGenerator2.h deleted file mode 100644 index f8440fa..0000000 --- a/Source/cmBorlandMakefileGenerator2.h +++ /dev/null @@ -1,114 +0,0 @@ -/*========================================================================= - - Program: Insight Segmentation & Registration Toolkit - Module: $RCSfile$ - Language: C++ - Date: $Date$ - Version: $Revision$ - -Copyright (c) 2001 Insight Consortium -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - - * The name of the Insight Consortium, nor the names of any consortium members, - nor of any contributors, may be used to endorse or promote products derived - from this software without specific prior written permission. - - * Modified source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS ``AS IS'' -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -=========================================================================*/ -#ifndef cmBorlandMakefileGenerator2_h -#define cmBorlandMakefileGenerator2_h - -#include "cmNMakeMakefileGenerator.h" - -/** \class cmBorlandMakefileGenerator2 - * \brief Write an NMake makefile. - * - * cmBorlandMakefileGenerator2 produces a Unix makefile from its - * member m_Makefile. - */ -class cmBorlandMakefileGenerator2 : public cmNMakeMakefileGenerator -{ -public: - ///! Set cache only and recurse to false by default. - cmBorlandMakefileGenerator2(); - - virtual ~cmBorlandMakefileGenerator2(); - - ///! Get the name for the generator. - virtual const char* GetName() {return "Borland Makefiles2";} - - ///! virtual copy constructor - virtual cmMakefileGenerator* CreateObject() - { return new cmBorlandMakefileGenerator2;} - - ///! figure out about the current system information - virtual void ComputeSystemInfo(); -protected: - virtual void OutputMakeVariables(std::ostream&); - virtual void BuildInSubDirectory(std::ostream& fout, - const char* directory, - const char* target1, - const char* target2); - void OutputMakeRule(std::ostream& fout, - const char* comment, - const char* target, - const char* depends, - const char* command, - const char* command2=0, - const char* command3=0, - const char* command4=0); - - - virtual void OutputBuildObjectFromSource(std::ostream& fout, - const char* shortName, - const cmSourceFile& source, - const char* extraCompileFlags, - bool sharedTarget); - virtual void OutputSharedLibraryRule(std::ostream&, const char* name, - const cmTarget &); - virtual void OutputModuleLibraryRule(std::ostream&, const char* name, - const cmTarget &); - virtual void OutputStaticLibraryRule(std::ostream&, const char* name, - const cmTarget &); - virtual void OutputExecutableRule(std::ostream&, const char* name, - const cmTarget &); - virtual std::string GetOutputExtension(const char* sourceExtension); - virtual void OutputBuildLibraryInDir(std::ostream& fout, - const char* path, - const char* library, - const char* fullpath); - ///! return true if the two paths are the same (checks short paths) - virtual bool SamePath(const char* path1, const char* path2); - virtual std::string ConvertToNativePath(const char* s); - -private: - bool m_QuoteNextCommand; // if this is true, OutputMakeRule - // will not quote the next commands - // it is reset to false after each - // call to OutputMakeRule -}; - -#endif diff --git a/Source/cmForEachCommand.cxx b/Source/cmForEachCommand.cxx index c36d11b..ba9ba51 100644 --- a/Source/cmForEachCommand.cxx +++ b/Source/cmForEachCommand.cxx @@ -93,7 +93,7 @@ IsFunctionBlocked(const char *name, const std::vector &args, bool cmForEachFunctionBlocker:: ShouldRemove(const char *name, const std::vector &args, - cmMakefile &mf) + cmMakefile &) { if (!strcmp(name,"ENDFOREACH") && args[0] == m_Args[0]) { diff --git a/Source/cmake.cxx b/Source/cmake.cxx index d2c1f02..8b15357 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -45,7 +45,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #if defined(_WIN32) && !defined(__CYGWIN__) #include "cmMSProjectGenerator.h" #include "cmBorlandMakefileGenerator.h" -#include "cmBorlandMakefileGenerator2.h" #include "cmNMakeMakefileGenerator.h" #else #include "cmUnixMakefileGenerator.h" @@ -58,7 +57,6 @@ cmake::cmake() cmMakefileGenerator::RegisterGenerator(new cmMSProjectGenerator); cmMakefileGenerator::RegisterGenerator(new cmNMakeMakefileGenerator); cmMakefileGenerator::RegisterGenerator(new cmBorlandMakefileGenerator); - cmMakefileGenerator::RegisterGenerator(new cmBorlandMakefileGenerator2); #else cmMakefileGenerator::RegisterGenerator(new cmUnixMakefileGenerator); #endif diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx index 3df3d64..ad8cb68 100644 --- a/Source/cmakemain.cxx +++ b/Source/cmakemain.cxx @@ -1,15 +1,31 @@ +#include "cmakewizard.h" #include "cmake.h" #include "cmMakefileGenerator.h" int main(int ac, char** av) { - cmake cm; + bool wiz = false; std::vector args; for(int i =0; i < ac; ++i) { - args.push_back(av[i]); + if(strcmp(av[i], "-i") == 0) + { + wiz = true; + } + else + { + args.push_back(av[i]); + } } - int ret = cm.Generate(args); + if(!wiz) + { + cmake cm; + int ret = cm.Generate(args); + cmMakefileGenerator::UnRegisterGenerators(); + return ret; + } + cmakewizard wizard; + wizard.RunWizard(args); cmMakefileGenerator::UnRegisterGenerators(); - return ret; + return 0; } diff --git a/Source/cmakewizard.cxx b/Source/cmakewizard.cxx index 52cf726..50a75ba 100644 --- a/Source/cmakewizard.cxx +++ b/Source/cmakewizard.cxx @@ -1,18 +1,15 @@ -#include "cmCacheManager.h" +#include "cmakewizard.h" #include "cmake.h" +#include "cmCacheManager.h" -bool advanced = false; - -void Ask(const char* key, cmCacheManager::CacheEntry & entry) +cmakewizard::cmakewizard() { - if(!advanced) - { - if(cmCacheManager::GetInstance()->IsAdvanced(key)) - { - return; - } - } + m_ShowAdvanced = false; +} + +void cmakewizard::AskUser(const char* key, cmCacheManager::CacheEntry & entry) +{ std::cout << "Variable Name: " << key << "\n"; std::cout << "Description: " << entry.m_HelpString << "\n"; std::cout << "Current Value: " << entry.m_Value.c_str() << "\n"; @@ -36,15 +33,8 @@ void Ask(const char* key, cmCacheManager::CacheEntry & entry) std::cout << "\n"; } - -int main(int ac, char** av) +bool cmakewizard::AskAdvanced() { - std::vector args; - for(int j=0; j < ac; ++j) - { - args.push_back(av[j]); - } - cmSystemTools::DisableRunCommandOutput(); std::cout << "Would you like to see advanced options? [No]:"; char buffer[4096]; buffer[0] = 0; @@ -53,9 +43,24 @@ int main(int ac, char** av) { if(buffer[0] == 'y' || buffer[0] == 'Y') { - advanced = true; + return true; } } + return false; +} + + +void cmakewizard::ShowMessage(const char* m) +{ + std::cout << m << "\n"; +} + + + +void cmakewizard::RunWizard(std::vector const& args) +{ + m_ShowAdvanced = this->AskAdvanced(); + cmSystemTools::DisableRunCommandOutput(); cmake make; cmCacheManager::CacheEntryMap askedCache; bool asked = false; @@ -64,9 +69,9 @@ int main(int ac, char** av) { asked = false; // run cmake - std::cout << "Please wait while cmake processes CMakeLists.txt files....\n"; + this->ShowMessage("Please wait while cmake processes CMakeLists.txt files....\n"); make.Generate(args); - std::cout << "\n"; + this->ShowMessage("\n"); // load the cache from disk cmCacheManager::GetInstance()-> LoadCache(cmSystemTools::GetCurrentWorkingDirectory().c_str()); @@ -88,22 +93,26 @@ int main(int ac, char** av) cmCacheManager::CacheEntry& e = askedCache.find(key)->second; if(e.m_Value != ce.m_Value) { - Ask(key.c_str(), ce); - asked = true; + if(m_ShowAdvanced || !cmCacheManager::GetInstance()->IsAdvanced(key.c_str())) + { + this->AskUser(key.c_str(), ce); + asked = true; + } } } else - { - Ask(key.c_str(), ce); - asked = true; + { + if(m_ShowAdvanced || !cmCacheManager::GetInstance()->IsAdvanced(key.c_str())) + { + this->AskUser(key.c_str(), ce); + asked = true; + } } askedCache[key] = i->second; } cmCacheManager::GetInstance()-> SaveCache(cmSystemTools::GetCurrentWorkingDirectory().c_str()); - } while(asked); - std::cout << "CMake complete, run make to build project.\n"; - return 0; + this->ShowMessage("CMake complete, run make to build project.\n"); } diff --git a/Templates/CMakeBorlandWindowsSystemConfig.cmake b/Templates/CMakeBorlandWindowsSystemConfig.cmake new file mode 100644 index 0000000..c83ce7f --- /dev/null +++ b/Templates/CMakeBorlandWindowsSystemConfig.cmake @@ -0,0 +1,71 @@ +# microsoft specific config file + +FIND_PATH(BCB_BIN_PATH bcc32.exe + "C:/Program Files/Borland/CBuilder5/Bin" + "C:/Borland/Bcc55/Bin" + "/Borland/Bcc55/Bin" + [HKEY_LOCAL_MACHINE/SOFTWARE/Borland/C++Builder/5.0/RootDir]/Bin +) + +SET (BORLAND 1) + +SET (WORDS_BIGENDIAN ) + +SET (HAVE_LIMITS_H 1) + +SET (HAVE_UNISTD_H 1) + +SET (CMAKE_C_COMPILER ${BCB_BIN_PATH}/bcc32 CACHE FILEPATH + "Name of C compiler used.") + +SET (CMAKE_C_FLAGS "-w- -whid -waus -wpar" CACHE STRING + "Flags for C compiler.") + +SET (CMAKE_BUILD_TYPE Debug CACHE STRING + "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel.") + +SET (CMAKE_CXX_COMPILER "${BCB_BIN_PATH}/bcc32" CACHE FILEPATH + "Name of C++ compiler used.") + +SET (CMAKE_CXX_FLAGS_RELEASE "-O2" CACHE STRING + "Flags used by the compiler during release builds.") + +SET (CMAKE_CXX_FLAGS_RELWITHDEBINFO "-Od" CACHE STRING + "Flags used by the compiler during Release with Debug Info builds.") + +SET (CMAKE_CXX_FLAGS_MINSIZEREL "-O1" CACHE STRING + "Flags used by the compiler during release minsize builds.") + +SET (CMAKE_CXX_FLAGS_DEBUG "-Od" CACHE STRING + "Flags used by the compiler during debug builds.") + +SET (CMAKE_CXX_FLAGS "-w- -whid -waus -wpar" CACHE STRING + "Flags used by the compiler during all build types, /GX /GR are for exceptions and rtti in VC++, /Zm1000 increases the compiler's memory allocation to support ANSI C++/stdlib.") + +SET (CMAKE_USE_WIN32_THREADS 1 CACHE BOOL + "Use the win32 thread library.") + +SET (CMAKE_STANDARD_WINDOWS_LIBRARIES "import32.lib" CACHE STRING + "Libraries linked by defalut with all applications.") + +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.") + +FIND_PROGRAM(CMAKE_MAKE_PROGRAM make ${BCB_BIN_PATH}) diff --git a/Templates/CMakeWindowsBorlandConfig.cmake b/Templates/CMakeWindowsBorlandConfig.cmake deleted file mode 100644 index 86e8ca8d..0000000 --- a/Templates/CMakeWindowsBorlandConfig.cmake +++ /dev/null @@ -1,97 +0,0 @@ -# -# Borland configuration. -# Note that this is valid for Borland C++Builder 5 with patch #1 -# - -SET (WORDS_BIGENDIAN ) - -SET (CMAKE_CXX_COMPILER "Borland_BCB_5.5.1" CACHE STRING "C++ compiler used.") - -# -# We need the Borland compiler path -# - -FIND_PATH(BCB_BIN_PATH bcc32.exe - "C:/Program Files/Borland/CBuilder5/Bin" - "C:/Borland/Bcc55/Bin" - "/Borland/Bcc55/Bin" - [HKEY_LOCAL_MACHINE/SOFTWARE/Borland/C++Builder/5.0/RootDir]/Bin -) - -# -# override opengl library as it is bound to import32.lib already -# - -IF (OPENGL_LIBRARY) - SET (OPENGL_LIBRARY import32 CACHE STRING "OpenGL library linked by Borland's import32.lib") -ENDIF (OPENGL_LIBRARY) - -# -# Set debug compile flags if not already set/edited by user -# - -IF (NOT FLAGS_CPP_DEBUG) - SET (FLAGS_CPP_DEBUG "-a8 -c -d -tWM -tWR -Ve -Vx -k -Od -r- -v -vi- -y" CACHE STRING "Flags used by CPP compiler in DEBUG mode") -ENDIF (NOT FLAGS_CPP_DEBUG) - -# -# Set release compile flags if not already set/edited by user -# - -IF (NOT FLAGS_CPP_RELEASE) - SET (FLAGS_CPP_RELEASE "-a8 -c -d -tWM -tWR -Ve -Vx -k- -O2 -r -v-" CACHE STRING "Flags used by CPP compiler in RELEASE mode") -ENDIF (NOT FLAGS_CPP_RELEASE) - -# -# Set compiler warning flags if not already set/edited by user -# - -IF (NOT FLAGS_CPP_WARNING) - SET (FLAGS_CPP_WARNING "-w- -whid -waus -wpar" CACHE STRING "Flags used to control compiler warnings") -ENDIF (NOT FLAGS_CPP_WARNING) - -# -# Set link flags if not already set/edited by user -# - -IF (NOT FLAGS_LINK_DLL) - SET (FLAGS_LINK_DLL "-aa -Tpd -x -Gn -Gl" CACHE STRING "Flags used by Linker for DLL") -ENDIF (NOT FLAGS_LINK_DLL) - -IF (NOT FLAGS_LINK_BPL) - SET (FLAGS_LINK_BPL "-aa -Tpp -x -Gn -Gi" CACHE STRING "Flags used by Linker for BPL") -ENDIF (NOT FLAGS_LINK_BPL) - -IF (NOT FLAGS_LINK_LIB) - SET (FLAGS_LINK_LIB "-aa -x -Gn -Gl -P128" CACHE STRING "Flags used by Linker for LIB") -ENDIF (NOT FLAGS_LINK_LIB) - -IF (NOT FLAGS_LINK_EXE) - SET (FLAGS_LINK_EXE "-aa -Tpe -x -Gn" CACHE STRING "Flags used by Linker for EXE") -ENDIF (NOT FLAGS_LINK_EXE) - -IF (NOT FLAGS_LINK_DEBUG) - SET (FLAGS_LINK_DEBUG "-v" CACHE STRING "Flags used by Linker in DEBUG mode") -ENDIF (NOT FLAGS_LINK_DEBUG) - -IF (NOT FLAGS_LINK_STATIC) - SET (FLAGS_LINK_STATIC "/P128" CACHE STRING "Set default Page size to 128 for static libraries") -ENDIF (NOT FLAGS_LINK_STATIC) - -# -# Set User Conditional Defines to Defaults -# - -IF (NOT DEFS_USER) - SET (DEFS_USER "" CACHE STRING "Compiler conditional defines set by the user") -ENDIF (NOT DEFS_USER) - -# -# Set SYS Conditional Defines to Defaults -# - -IF (NOT DEFS_SYS) - SET (DEFS_SYS "-DWIN32;WIN32_LEAN_AND_MEAN;STRICT;_RTLDLL;USEPACKAGES" CACHE STRING "Compiler conditional defines required for correct compilation") -ENDIF (NOT DEFS_SYS) - -FIND_PROGRAM(CMAKE_MAKE_PROGRAM make ${BCB_BIN_PATH} ) diff --git a/Templates/CMakeWindowsBorlandConfig2.cmake b/Templates/CMakeWindowsBorlandConfig2.cmake deleted file mode 100644 index c83ce7f..0000000 --- a/Templates/CMakeWindowsBorlandConfig2.cmake +++ /dev/null @@ -1,71 +0,0 @@ -# microsoft specific config file - -FIND_PATH(BCB_BIN_PATH bcc32.exe - "C:/Program Files/Borland/CBuilder5/Bin" - "C:/Borland/Bcc55/Bin" - "/Borland/Bcc55/Bin" - [HKEY_LOCAL_MACHINE/SOFTWARE/Borland/C++Builder/5.0/RootDir]/Bin -) - -SET (BORLAND 1) - -SET (WORDS_BIGENDIAN ) - -SET (HAVE_LIMITS_H 1) - -SET (HAVE_UNISTD_H 1) - -SET (CMAKE_C_COMPILER ${BCB_BIN_PATH}/bcc32 CACHE FILEPATH - "Name of C compiler used.") - -SET (CMAKE_C_FLAGS "-w- -whid -waus -wpar" CACHE STRING - "Flags for C compiler.") - -SET (CMAKE_BUILD_TYPE Debug CACHE STRING - "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel.") - -SET (CMAKE_CXX_COMPILER "${BCB_BIN_PATH}/bcc32" CACHE FILEPATH - "Name of C++ compiler used.") - -SET (CMAKE_CXX_FLAGS_RELEASE "-O2" CACHE STRING - "Flags used by the compiler during release builds.") - -SET (CMAKE_CXX_FLAGS_RELWITHDEBINFO "-Od" CACHE STRING - "Flags used by the compiler during Release with Debug Info builds.") - -SET (CMAKE_CXX_FLAGS_MINSIZEREL "-O1" CACHE STRING - "Flags used by the compiler during release minsize builds.") - -SET (CMAKE_CXX_FLAGS_DEBUG "-Od" CACHE STRING - "Flags used by the compiler during debug builds.") - -SET (CMAKE_CXX_FLAGS "-w- -whid -waus -wpar" CACHE STRING - "Flags used by the compiler during all build types, /GX /GR are for exceptions and rtti in VC++, /Zm1000 increases the compiler's memory allocation to support ANSI C++/stdlib.") - -SET (CMAKE_USE_WIN32_THREADS 1 CACHE BOOL - "Use the win32 thread library.") - -SET (CMAKE_STANDARD_WINDOWS_LIBRARIES "import32.lib" CACHE STRING - "Libraries linked by defalut with all applications.") - -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.") - -FIND_PROGRAM(CMAKE_MAKE_PROGRAM make ${BCB_BIN_PATH}) -- cgit v0.12