ENH: borland generator 2 is working more or less

This commit is contained in:
Bill Hoffman 2001-11-28 18:07:27 -05:00
parent b29e3f11cb
commit e7bb895afd
8 changed files with 95 additions and 23 deletions

View File

@ -99,6 +99,10 @@ SOURCE=.\cmBorlandMakefileGenerator.cpp
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=.\cmBorlandMakefileGenerator2.cxx
# End Source File
# Begin Source File
SOURCE=.\cmCableClassSet.cxx SOURCE=.\cmCableClassSet.cxx
# End Source File # End Source File
# Begin Source File # Begin Source File

View File

@ -52,6 +52,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
cmBorlandMakefileGenerator2::cmBorlandMakefileGenerator2() cmBorlandMakefileGenerator2::cmBorlandMakefileGenerator2()
{ {
this->SetLibraryPathOption("-L"); this->SetLibraryPathOption("-L");
this->SetLibraryLinkOption("");
} }
cmBorlandMakefileGenerator2::~cmBorlandMakefileGenerator2() cmBorlandMakefileGenerator2::~cmBorlandMakefileGenerator2()
@ -85,9 +86,6 @@ void cmBorlandMakefileGenerator2::OutputMakeVariables(std::ostream& fout)
"# Path to cmake\n" "# Path to cmake\n"
"CMAKE_COMMAND = ${CMAKE_COMMAND}\n" "CMAKE_COMMAND = ${CMAKE_COMMAND}\n"
"CMAKE_STANDARD_WINDOWS_LIBRARIES = @CMAKE_STANDARD_WINDOWS_LIBRARIES@\n" "CMAKE_STANDARD_WINDOWS_LIBRARIES = @CMAKE_STANDARD_WINDOWS_LIBRARIES@\n"
"FLAGS_LINK_EXE = @FLAGS_LINK_EXE@ \n"
"FLAGS_LINK_LIB = @FLAGS_LINK_LIB@ \n"
"FLAGS_LINK_STATIC = @FLAGS_LINK_STATIC@ \n"
"CMAKE_C_COMPILER = @CMAKE_C_COMPILER@ \n" "CMAKE_C_COMPILER = @CMAKE_C_COMPILER@ \n"
"CMAKE_CFLAGS = @CMAKE_CFLAGS@ @BUILD_FLAGS@\n" "CMAKE_CFLAGS = @CMAKE_CFLAGS@ @BUILD_FLAGS@\n"
"CMAKE_CXX_COMPILER = @CMAKE_CXX_COMPILER@\n" "CMAKE_CXX_COMPILER = @CMAKE_CXX_COMPILER@\n"
@ -244,7 +242,7 @@ OutputBuildObjectFromSource(std::ostream& fout,
std::string comment = "Build "; std::string comment = "Build ";
std::string objectFile = std::string(shortName) + std::string objectFile = std::string(shortName) +
this->GetOutputExtension(source.GetSourceExtension().c_str()); this->GetOutputExtension(source.GetSourceExtension().c_str());
cmSystemTools::ConvertToWindowsSlashes(objectFile);
comment += objectFile + " From "; comment += objectFile + " From ";
comment += source.GetFullPath(); comment += source.GetFullPath();
std::string compileCommand; std::string compileCommand;
@ -257,15 +255,15 @@ OutputBuildObjectFromSource(std::ostream& fout,
{ {
compileCommand += "$(CMAKE_SHLIB_CFLAGS) "; compileCommand += "$(CMAKE_SHLIB_CFLAGS) ";
} }
compileCommand += "$(INCLUDE_FLAGS) -c "; compileCommand += " -o";
compileCommand += objectFile;
compileCommand += " $(INCLUDE_FLAGS) -c ";
compileCommand += compileCommand +=
cmSystemTools::EscapeSpaces(source.GetFullPath().c_str()); cmSystemTools::EscapeSpaces(source.GetFullPath().c_str());
compileCommand += " /Fo";
compileCommand += objectFile;
} }
else if (ext == "rc") else if (ext == "rc")
{ {
compileCommand = "$(RC) /fo\""; compileCommand = "$(RC) -o\"";
compileCommand += objectFile; compileCommand += objectFile;
compileCommand += "\" "; compileCommand += "\" ";
compileCommand += compileCommand +=
@ -285,11 +283,11 @@ OutputBuildObjectFromSource(std::ostream& fout,
{ {
compileCommand += "$(CMAKE_SHLIB_CFLAGS) "; compileCommand += "$(CMAKE_SHLIB_CFLAGS) ";
} }
compileCommand += "$(INCLUDE_FLAGS) -c "; compileCommand += " -o";
compileCommand += objectFile;
compileCommand += " $(INCLUDE_FLAGS) -c ";
compileCommand += compileCommand +=
cmSystemTools::EscapeSpaces(source.GetFullPath().c_str()); cmSystemTools::EscapeSpaces(source.GetFullPath().c_str());
compileCommand += " /Fo";
compileCommand += objectFile;
} }
m_QuoteNextCommand = false; m_QuoteNextCommand = false;
this->OutputMakeRule(fout, this->OutputMakeRule(fout,
@ -308,32 +306,43 @@ void cmBorlandMakefileGenerator2::OutputSharedLibraryRule(std::ostream& fout,
std::string depend = "$("; std::string depend = "$(";
depend += name; depend += name;
depend += "_SRC_OBJS) $(" + std::string(name) + "_DEPEND_LIBS)"; depend += "_SRC_OBJS) $(" + std::string(name) + "_DEPEND_LIBS)";
std::string command = "ilink32 /dll $(FLAGS_LINK_LIB) @&&|\n"; std::string command = "$(CMAKE_CXX_COMPILER) -tWD @&&|\n";
command += "$(" + std::string(name) + "_SRC_OBJS) /out:"; std::string dllpath = m_LibraryOutputPath + std::string(name);
std::string dllpath = m_LibraryOutputPath + std::string(name) + ".dll "; std::string libpath = dllpath + ".lib";
dllpath += ".dll";
cmSystemTools::ConvertToWindowsSlashes(dllpath); cmSystemTools::ConvertToWindowsSlashes(dllpath);
// must be executable name
command += "-e";
command += cmSystemTools::EscapeSpaces(dllpath.c_str()); command += cmSystemTools::EscapeSpaces(dllpath.c_str());
command += " ";
// then list of object files
command += " $(" + std::string(name) + "_SRC_OBJS) ";
std::strstream linklibs; std::strstream linklibs;
this->OutputLinkLibraries(linklibs, name, t); this->OutputLinkLibraries(linklibs, name, t);
linklibs << std::ends; linklibs << std::ends;
// then the linker options -L and libraries (any other order will fail!)
command += linklibs.str(); command += linklibs.str();
delete [] linklibs.str(); delete [] linklibs.str();
std::string command2 = "implib -w ";
command2 += libpath + " " + dllpath;
const std::vector<cmSourceFile>& sources = t.GetSourceFiles(); const std::vector<cmSourceFile>& sources = t.GetSourceFiles();
for(std::vector<cmSourceFile>::const_iterator i = sources.begin(); for(std::vector<cmSourceFile>::const_iterator i = sources.begin();
i != sources.end(); ++i) i != sources.end(); ++i)
{ {
if(i->GetSourceExtension() == "def") if(i->GetSourceExtension() == "def")
{ {
command += "/DEF:"; command += "";
command += i->GetFullPath(); command += i->GetFullPath();
} }
} }
command += "\n|\n"; command += "\n|\n";
m_QuoteNextCommand = false; m_QuoteNextCommand = false;
this->OutputMakeRule(fout, "rules for a shared library", this->OutputMakeRule(fout, "rules for a shared library",
target.c_str(), target.c_str(),
depend.c_str(), depend.c_str(),
command.c_str()); command.c_str(),
command2.c_str());
} }
void cmBorlandMakefileGenerator2::OutputModuleLibraryRule(std::ostream& fout, void cmBorlandMakefileGenerator2::OutputModuleLibraryRule(std::ostream& fout,
@ -350,12 +359,14 @@ void cmBorlandMakefileGenerator2::OutputStaticLibraryRule(std::ostream& fout,
std::string target = m_LibraryOutputPath + std::string(name) + ".lib"; std::string target = m_LibraryOutputPath + std::string(name) + ".lib";
std::string depend = "$("; std::string depend = "$(";
depend += std::string(name) + "_SRC_OBJS)"; depend += std::string(name) + "_SRC_OBJS)";
std::string command = "tlib $(FLAGS_LINK_STATIC) @&&|\n\t /u "; std::string command = "tlib @&&|\n\t /u ";
std::string deleteCommand = "del ";
deleteCommand += target;
std::string libpath = m_LibraryOutputPath + std::string(name) + ".lib"; std::string libpath = m_LibraryOutputPath + std::string(name) + ".lib";
cmSystemTools::ConvertToWindowsSlashes(libpath); cmSystemTools::ConvertToWindowsSlashes(libpath);
command += cmSystemTools::EscapeSpaces(libpath.c_str()); command += cmSystemTools::EscapeSpaces(libpath.c_str());
std::string deleteCommand = "if exist ";
deleteCommand += libpath;
deleteCommand += " del ";
deleteCommand += libpath;
command += " $("; command += " $(";
command += std::string(name) + "_SRC_OBJS)"; command += std::string(name) + "_SRC_OBJS)";
command += "\n|\n"; command += "\n|\n";
@ -380,7 +391,6 @@ void cmBorlandMakefileGenerator2::OutputExecutableRule(std::ostream& fout,
depend += std::string(name) + "_SRC_OBJS) $(" + std::string(name) + "_DEPEND_LIBS)"; depend += std::string(name) + "_SRC_OBJS) $(" + std::string(name) + "_DEPEND_LIBS)";
std::string command = std::string command =
"$(CMAKE_CXX_COMPILER) "; "$(CMAKE_CXX_COMPILER) ";
command += "$(" + std::string(name) + "_SRC_OBJS) ";
std::string path = m_ExecutableOutputPath + name + ".exe"; std::string path = m_ExecutableOutputPath + name + ".exe";
command += " -e" + command += " -e" +
cmSystemTools::EscapeSpaces(path.c_str()); cmSystemTools::EscapeSpaces(path.c_str());
@ -392,11 +402,13 @@ void cmBorlandMakefileGenerator2::OutputExecutableRule(std::ostream& fout,
{ {
command += " -tWC "; command += " -tWC ";
} }
std::strstream linklibs; std::strstream linklibs;
this->OutputLinkLibraries(linklibs, 0, t); this->OutputLinkLibraries(linklibs, 0, t);
linklibs << std::ends; linklibs << std::ends;
command += linklibs.str(); command += linklibs.str();
delete [] linklibs.str();
command += " $(" + std::string(name) + "_SRC_OBJS) ";
std::string comment = "rule to build executable: "; std::string comment = "rule to build executable: ";
comment += name; comment += name;
m_QuoteNextCommand = false; m_QuoteNextCommand = false;
@ -450,3 +462,12 @@ void cmBorlandMakefileGenerator2::OutputBuildLibraryInDir(std::ostream& fout,
{ {
cmNMakeMakefileGenerator::OutputBuildLibraryInDir(fout, path, s, fullpath); cmNMakeMakefileGenerator::OutputBuildLibraryInDir(fout, path, s, fullpath);
} }
std::string cmBorlandMakefileGenerator2::ConvertToNativePath(const char* s)
{
std::string ret = s;
cmSystemTools::ConvertToWindowsSlashes(ret);
return ret;
}

View File

@ -102,6 +102,8 @@ protected:
const char* fullpath); const char* fullpath);
///! return true if the two paths are the same (checks short paths) ///! return true if the two paths are the same (checks short paths)
virtual bool SamePath(const char* path1, const char* path2); virtual bool SamePath(const char* path1, const char* path2);
virtual std::string ConvertToNativePath(const char* s);
private: private:
bool m_QuoteNextCommand; // if this is true, OutputMakeRule bool m_QuoteNextCommand; // if this is true, OutputMakeRule
// will not quote the next commands // will not quote the next commands

View File

@ -482,6 +482,7 @@ void cmNMakeMakefileGenerator::OutputLinkLibraries(std::ostream& fout,
if(emitted.insert(libpath).second) if(emitted.insert(libpath).second)
{ {
linkLibs += m_LibraryPathOption; linkLibs += m_LibraryPathOption;
cmSystemTools::ConvertToWindowsSlashes(libpath);
linkLibs += libpath; linkLibs += libpath;
linkLibs += " "; linkLibs += " ";
} }
@ -514,6 +515,7 @@ void cmNMakeMakefileGenerator::OutputLinkLibraries(std::ostream& fout,
} }
else else
{ {
librariesLinked += m_LibraryLinkOption;
librariesLinked += lib->first; librariesLinked += lib->first;
librariesLinked += ".lib "; librariesLinked += ".lib ";
} }

View File

@ -109,12 +109,14 @@ protected:
///! return true if the two paths are the same (checks short paths) ///! return true if the two paths are the same (checks short paths)
virtual bool SamePath(const char* path1, const char* path2); virtual bool SamePath(const char* path1, const char* path2);
void SetLibraryPathOption(const char* lib){ m_LibraryPathOption = lib;} void SetLibraryPathOption(const char* lib){ m_LibraryPathOption = lib;}
void SetLibraryLinkOption(const char* lib){ m_LibraryLinkOption = lib;}
private: private:
bool m_QuoteNextCommand; // if this is true, OutputMakeRule bool m_QuoteNextCommand; // if this is true, OutputMakeRule
// will not quote the next commands // will not quote the next commands
// it is reset to false after each // it is reset to false after each
// call to OutputMakeRule // call to OutputMakeRule
std::string m_LibraryPathOption; std::string m_LibraryPathOption;// option to specifiy a link path -LIBPATH
std::string m_LibraryLinkOption; // option to specify a library (like -l, empty for nmake)
}; };
#endif #endif

View File

@ -367,7 +367,7 @@ void cmUnixMakefileGenerator::OutputTargetRules(std::ostream& fout)
std::string outExt(this->GetOutputExtension(i->GetSourceExtension().c_str())); std::string outExt(this->GetOutputExtension(i->GetSourceExtension().c_str()));
if(outExt.size()) if(outExt.size())
{ {
fout << "\\\n" << i->GetSourceName() fout << "\\\n" << this->ConvertToNativePath(i->GetSourceName().c_str())
<< outExt.c_str() << " "; << outExt.c_str() << " ";
} }
} }

View File

@ -164,6 +164,7 @@ protected:
void SetStaticLibraryExtension(const char* e) {m_StaticLibraryExtension = e;} void SetStaticLibraryExtension(const char* e) {m_StaticLibraryExtension = e;}
void SetSharedLibraryExtension(const char* e) {m_SharedLibraryExtension = e;} void SetSharedLibraryExtension(const char* e) {m_SharedLibraryExtension = e;}
void SetLibraryPrefix(const char* e) { m_LibraryPrefix = e;} void SetLibraryPrefix(const char* e) { m_LibraryPrefix = e;}
virtual std::string ConvertToNativePath(const char* s) { return s; }
protected: protected:
std::string m_ExecutableOutputPath; std::string m_ExecutableOutputPath;
std::string m_LibraryOutputPath; std::string m_LibraryOutputPath;

View File

@ -0,0 +1,40 @@
# 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 (WORDS_BIGENDIAN )
SET (HAVE_LIMITS_H 1)
SET (HAVE_UNISTD_H 1)
SET (CMAKE_CXX_COMPILER "${BCB_BIN_PATH}/bcc32" CACHE FILEPATH
"Name of C++ compiler used.")
SET (CMAKE_C_COMPILER ${BCB_BIN_PATH}/bcc32 CACHE FILEPATH
"Name of C compiler used.")
SET (CMAKE_CFLAGS "-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_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")
FIND_PROGRAM(CMAKE_MAKE_PROGRAM make ${BCB_BIN_PATH} )