From 30ad61805bbb5b34e2bf17cb36ce2e9601ed0f25 Mon Sep 17 00:00:00 2001 From: Ken Martin Date: Thu, 26 Apr 2001 09:38:31 -0400 Subject: [PATCH] bug fixes --- Source/CMakeSetup.dsw | 15 +++++ Source/DumpDocumentation.dsp | 100 +++++++++++++++++++++++++++++ Source/cmCommands.cxx | 2 + Source/cmDSPMakefile.cxx | 68 +++++++++++--------- Source/cmDSPMakefile.h | 11 ++-- Source/cmDSPWriter.cxx | 68 +++++++++++--------- Source/cmDSPWriter.h | 11 ++-- Source/cmFindFileCommand.cxx | 5 +- Source/cmFindIncludeCommand.cxx | 22 ++++++- Source/cmFindIncludeCommand.h | 4 +- Source/cmFindLibraryCommand.cxx | 35 +++++++++- Source/cmFindLibraryCommand.h | 3 +- Source/cmFindPathCommand.cxx | 74 +++++++++++++++++++++ Source/cmFindPathCommand.h | 81 +++++++++++++++++++++++ Source/cmMakefile.cxx | 2 - Source/cmMakefile.h | 18 ------ Source/cmUnixMakefileGenerator.cxx | 7 -- 17 files changed, 418 insertions(+), 108 deletions(-) create mode 100644 Source/DumpDocumentation.dsp create mode 100644 Source/cmFindPathCommand.cxx create mode 100644 Source/cmFindPathCommand.h diff --git a/Source/CMakeSetup.dsw b/Source/CMakeSetup.dsw index 5b3a458f5..d734315a6 100644 --- a/Source/CMakeSetup.dsw +++ b/Source/CMakeSetup.dsw @@ -48,6 +48,21 @@ Package=<4> ############################################################################### +Project: "DumpDocumentation"=.\DumpDocumentation.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ + Begin Project Dependency + Project_Dep_Name CMakeLib + End Project Dependency +}}} + +############################################################################### + Global: Package=<5> diff --git a/Source/DumpDocumentation.dsp b/Source/DumpDocumentation.dsp new file mode 100644 index 000000000..fcbe87098 --- /dev/null +++ b/Source/DumpDocumentation.dsp @@ -0,0 +1,100 @@ +# Microsoft Developer Studio Project File - Name="DumpDocumentation" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=DumpDocumentation - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "DumpDocumentation.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "DumpDocumentation.mak" CFG="DumpDocumentation - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "DumpDocumentation - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "DumpDocumentation - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "DumpDocumentation - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 + +!ELSEIF "$(CFG)" == "DumpDocumentation - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "DumpDocumentation___Win32_Debug" +# PROP BASE Intermediate_Dir "DumpDocumentation___Win32_Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "DumpDocumentation___Win32_Debug" +# PROP Intermediate_Dir "DumpDocumentation___Win32_Debug" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept + +!ENDIF + +# Begin Target + +# Name "DumpDocumentation - Win32 Release" +# Name "DumpDocumentation - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\cmDumpDocumentation.cxx +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# End Target +# End Project diff --git a/Source/cmCommands.cxx b/Source/cmCommands.cxx index c9cf0fbac..71d2ae5f5 100644 --- a/Source/cmCommands.cxx +++ b/Source/cmCommands.cxx @@ -37,6 +37,7 @@ #include "cmCableInstantiateCommand.cxx" #include "cmCableInstantiateClassCommand.cxx" #include "cmFindFileCommand.cxx" +#include "cmFindPathCommand.cxx" #include "cmWrapExcludeFilesCommand.cxx" #include "cmVTKWrapPythonCommand.cxx" #include "cmVTKWrapTclCommand.cxx" @@ -83,6 +84,7 @@ void GetPredefinedCommands(std::list& commands) commands.push_back(new cmCableInstantiateCommand); commands.push_back(new cmCableInstantiateClassCommand); commands.push_back(new cmFindFileCommand); + commands.push_back(new cmFindPathCommand); commands.push_back(new cmWrapExcludeFilesCommand); commands.push_back(new cmVTKWrapPythonCommand); commands.push_back(new cmVTKWrapTclCommand); diff --git a/Source/cmDSPMakefile.cxx b/Source/cmDSPMakefile.cxx index 74513fc85..22dc79851 100644 --- a/Source/cmDSPMakefile.cxx +++ b/Source/cmDSPMakefile.cxx @@ -51,28 +51,6 @@ void cmDSPMakefile::OutputDSPFile() m_IncludeOptions += *i; m_IncludeOptions += "\" "; } - std::vector& libs = m_Makefile->GetLinkLibraries(); - for(i = libs.begin(); i != libs.end(); ++i) - { - m_LibraryOptions += " "; - m_LibraryOptions += *i; - m_LibraryOptions += ".lib "; - } - std::vector& libswin32 = m_Makefile->GetLinkLibrariesWin32(); - for(i = libswin32.begin(); i != libswin32.end(); ++i) - { - m_LibraryOptions += " "; - m_LibraryOptions += *i; - m_LibraryOptions += ".lib "; - } - std::vector& libdirs = m_Makefile->GetLinkDirectories(); - for(i = libdirs.begin(); i != libdirs.end(); ++i) - { - m_LibraryOptions += " /LIBPATH:\""; - m_LibraryOptions += *i; - m_LibraryOptions += "/$(OUTDIR)\" "; - } - m_LibraryOptions += "/STACK:10000000 "; // Create the DSP or set of DSP's for libraries and executables const char* cacheValue @@ -91,6 +69,30 @@ void cmDSPMakefile::OutputDSPFile() for(cmTargets::iterator l = tgts.begin(); l != tgts.end(); l++) { + std::string libOptions; + std::vector& libdirs = m_Makefile->GetLinkDirectories(); + for(i = libdirs.begin(); i != libdirs.end(); ++i) + { + libOptions += " /LIBPATH:\""; + libOptions += *i; + libOptions += "/$(OUTDIR)\" "; + libOptions += " /LIBPATH:\""; + libOptions += *i; + libOptions += "\" "; + } + std::vector& libs = m_Makefile->GetLinkLibraries(); + for(i = libs.begin(); i != libs.end(); ++i) + { + // add libraries to executables and dlls (but never include + // a library in a library, bad recursion) + if (!l->second.IsALibrary() || + (m_LibraryBuildType == DLL && l->first.c_str() != *i)) + { + libOptions += " "; + libOptions += *i; + libOptions += ".lib "; + } + } if (l->second.IsALibrary()) { this->SetBuildType(m_LibraryBuildType, l->first.c_str()); @@ -99,11 +101,13 @@ void cmDSPMakefile::OutputDSPFile() { this->SetBuildType(EXECUTABLE,l->first.c_str()); } - this->CreateSingleDSP(l->first.c_str(),l->second); + libOptions += "/STACK:10000000 "; + this->CreateSingleDSP(l->first.c_str(),l->second, libOptions); } } -void cmDSPMakefile::CreateSingleDSP(const char *lname, cmTarget &target) +void cmDSPMakefile::CreateSingleDSP(const char *lname, cmTarget &target, + const std::string &libOptions) { std::string fname; fname = m_Makefile->GetStartOutputDirectory(); @@ -117,7 +121,7 @@ void cmDSPMakefile::CreateSingleDSP(const char *lname, cmTarget &target) { cmSystemTools::Error("Error Writing ", fname.c_str()); } - this->WriteDSPFile(fout,lname,target); + this->WriteDSPFile(fout,lname,target, libOptions); } void cmDSPMakefile::WriteDSPBuildRule(std::ostream& fout) @@ -185,10 +189,11 @@ void cmDSPMakefile::AddDSPBuildRule(cmSourceGroup& sourceGroup) void cmDSPMakefile::WriteDSPFile(std::ostream& fout, const char *libName, - cmTarget &target) + cmTarget &target, + const std::string &libOptions) { // Write the DSP file's header. - this->WriteDSPHeader(fout, libName); + this->WriteDSPHeader(fout, libName, libOptions); // We may be modifying the source groups temporarily, so make a copy. std::vector sourceGroups = m_Makefile->GetSourceGroups(); @@ -399,7 +404,8 @@ void cmDSPMakefile::SetBuildType(BuildType b, const char *libName) } } -void cmDSPMakefile::WriteDSPHeader(std::ostream& fout, const char *libName) +void cmDSPMakefile::WriteDSPHeader(std::ostream& fout, const char *libName, + const std::string &libOptions) { std::ifstream fin(m_DSPHeaderTemplate.c_str()); if(!fin) @@ -413,12 +419,12 @@ void cmDSPMakefile::WriteDSPHeader(std::ostream& fout, const char *libName) fin.getline(buffer, 2048); std::string line = buffer; cmSystemTools::ReplaceString(line, "CM_LIBRARIES", - m_LibraryOptions.c_str()); + libOptions.c_str()); cmSystemTools::ReplaceString(line, "BUILD_INCLUDES", - m_IncludeOptions.c_str()); + m_IncludeOptions.c_str()); cmSystemTools::ReplaceString(line, "OUTPUT_LIBNAME",libName); cmSystemTools::ReplaceString(line, - "EXTRA_DEFINES", + "EXTRA_DEFINES", m_Makefile->GetDefineFlags()); fout << line.c_str() << std::endl; } diff --git a/Source/cmDSPMakefile.h b/Source/cmDSPMakefile.h index 4aac519f0..d231d161f 100644 --- a/Source/cmDSPMakefile.h +++ b/Source/cmDSPMakefile.h @@ -67,14 +67,16 @@ private: std::string m_DSPFooterTemplate; std::vector m_CreatedProjectNames; - void CreateSingleDSP(const char *lname, cmTarget &tgt); - void WriteDSPFile(std::ostream& fout, - const char *libName, cmTarget &tgt); + void CreateSingleDSP(const char *lname, cmTarget &tgt, + const std::string &libs); + void WriteDSPFile(std::ostream& fout, const char *libName, + cmTarget &tgt, const std::string &libs); void WriteDSPBeginGroup(std::ostream& fout, const char* group, const char* filter); void WriteDSPEndGroup(std::ostream& fout); - void WriteDSPHeader(std::ostream& fout, const char *libName); + void WriteDSPHeader(std::ostream& fout, const char *libName, + const std::string &libs); void WriteDSPBuildRule(std::ostream& fout, const char*); void WriteDSPBuildRule(std::ostream& fout); void WriteDSPFooter(std::ostream& fout); @@ -85,7 +87,6 @@ private: const std::set& outputs); std::string m_IncludeOptions; - std::string m_LibraryOptions; cmMakefile* m_Makefile; BuildType m_LibraryBuildType; std::vector m_Configurations; diff --git a/Source/cmDSPWriter.cxx b/Source/cmDSPWriter.cxx index 74513fc85..22dc79851 100644 --- a/Source/cmDSPWriter.cxx +++ b/Source/cmDSPWriter.cxx @@ -51,28 +51,6 @@ void cmDSPMakefile::OutputDSPFile() m_IncludeOptions += *i; m_IncludeOptions += "\" "; } - std::vector& libs = m_Makefile->GetLinkLibraries(); - for(i = libs.begin(); i != libs.end(); ++i) - { - m_LibraryOptions += " "; - m_LibraryOptions += *i; - m_LibraryOptions += ".lib "; - } - std::vector& libswin32 = m_Makefile->GetLinkLibrariesWin32(); - for(i = libswin32.begin(); i != libswin32.end(); ++i) - { - m_LibraryOptions += " "; - m_LibraryOptions += *i; - m_LibraryOptions += ".lib "; - } - std::vector& libdirs = m_Makefile->GetLinkDirectories(); - for(i = libdirs.begin(); i != libdirs.end(); ++i) - { - m_LibraryOptions += " /LIBPATH:\""; - m_LibraryOptions += *i; - m_LibraryOptions += "/$(OUTDIR)\" "; - } - m_LibraryOptions += "/STACK:10000000 "; // Create the DSP or set of DSP's for libraries and executables const char* cacheValue @@ -91,6 +69,30 @@ void cmDSPMakefile::OutputDSPFile() for(cmTargets::iterator l = tgts.begin(); l != tgts.end(); l++) { + std::string libOptions; + std::vector& libdirs = m_Makefile->GetLinkDirectories(); + for(i = libdirs.begin(); i != libdirs.end(); ++i) + { + libOptions += " /LIBPATH:\""; + libOptions += *i; + libOptions += "/$(OUTDIR)\" "; + libOptions += " /LIBPATH:\""; + libOptions += *i; + libOptions += "\" "; + } + std::vector& libs = m_Makefile->GetLinkLibraries(); + for(i = libs.begin(); i != libs.end(); ++i) + { + // add libraries to executables and dlls (but never include + // a library in a library, bad recursion) + if (!l->second.IsALibrary() || + (m_LibraryBuildType == DLL && l->first.c_str() != *i)) + { + libOptions += " "; + libOptions += *i; + libOptions += ".lib "; + } + } if (l->second.IsALibrary()) { this->SetBuildType(m_LibraryBuildType, l->first.c_str()); @@ -99,11 +101,13 @@ void cmDSPMakefile::OutputDSPFile() { this->SetBuildType(EXECUTABLE,l->first.c_str()); } - this->CreateSingleDSP(l->first.c_str(),l->second); + libOptions += "/STACK:10000000 "; + this->CreateSingleDSP(l->first.c_str(),l->second, libOptions); } } -void cmDSPMakefile::CreateSingleDSP(const char *lname, cmTarget &target) +void cmDSPMakefile::CreateSingleDSP(const char *lname, cmTarget &target, + const std::string &libOptions) { std::string fname; fname = m_Makefile->GetStartOutputDirectory(); @@ -117,7 +121,7 @@ void cmDSPMakefile::CreateSingleDSP(const char *lname, cmTarget &target) { cmSystemTools::Error("Error Writing ", fname.c_str()); } - this->WriteDSPFile(fout,lname,target); + this->WriteDSPFile(fout,lname,target, libOptions); } void cmDSPMakefile::WriteDSPBuildRule(std::ostream& fout) @@ -185,10 +189,11 @@ void cmDSPMakefile::AddDSPBuildRule(cmSourceGroup& sourceGroup) void cmDSPMakefile::WriteDSPFile(std::ostream& fout, const char *libName, - cmTarget &target) + cmTarget &target, + const std::string &libOptions) { // Write the DSP file's header. - this->WriteDSPHeader(fout, libName); + this->WriteDSPHeader(fout, libName, libOptions); // We may be modifying the source groups temporarily, so make a copy. std::vector sourceGroups = m_Makefile->GetSourceGroups(); @@ -399,7 +404,8 @@ void cmDSPMakefile::SetBuildType(BuildType b, const char *libName) } } -void cmDSPMakefile::WriteDSPHeader(std::ostream& fout, const char *libName) +void cmDSPMakefile::WriteDSPHeader(std::ostream& fout, const char *libName, + const std::string &libOptions) { std::ifstream fin(m_DSPHeaderTemplate.c_str()); if(!fin) @@ -413,12 +419,12 @@ void cmDSPMakefile::WriteDSPHeader(std::ostream& fout, const char *libName) fin.getline(buffer, 2048); std::string line = buffer; cmSystemTools::ReplaceString(line, "CM_LIBRARIES", - m_LibraryOptions.c_str()); + libOptions.c_str()); cmSystemTools::ReplaceString(line, "BUILD_INCLUDES", - m_IncludeOptions.c_str()); + m_IncludeOptions.c_str()); cmSystemTools::ReplaceString(line, "OUTPUT_LIBNAME",libName); cmSystemTools::ReplaceString(line, - "EXTRA_DEFINES", + "EXTRA_DEFINES", m_Makefile->GetDefineFlags()); fout << line.c_str() << std::endl; } diff --git a/Source/cmDSPWriter.h b/Source/cmDSPWriter.h index 4aac519f0..d231d161f 100644 --- a/Source/cmDSPWriter.h +++ b/Source/cmDSPWriter.h @@ -67,14 +67,16 @@ private: std::string m_DSPFooterTemplate; std::vector m_CreatedProjectNames; - void CreateSingleDSP(const char *lname, cmTarget &tgt); - void WriteDSPFile(std::ostream& fout, - const char *libName, cmTarget &tgt); + void CreateSingleDSP(const char *lname, cmTarget &tgt, + const std::string &libs); + void WriteDSPFile(std::ostream& fout, const char *libName, + cmTarget &tgt, const std::string &libs); void WriteDSPBeginGroup(std::ostream& fout, const char* group, const char* filter); void WriteDSPEndGroup(std::ostream& fout); - void WriteDSPHeader(std::ostream& fout, const char *libName); + void WriteDSPHeader(std::ostream& fout, const char *libName, + const std::string &libs); void WriteDSPBuildRule(std::ostream& fout, const char*); void WriteDSPBuildRule(std::ostream& fout); void WriteDSPFooter(std::ostream& fout); @@ -85,7 +87,6 @@ private: const std::set& outputs); std::string m_IncludeOptions; - std::string m_LibraryOptions; cmMakefile* m_Makefile; BuildType m_LibraryBuildType; std::vector m_Configurations; diff --git a/Source/cmFindFileCommand.cxx b/Source/cmFindFileCommand.cxx index 39f1371f7..a5a679ad3 100644 --- a/Source/cmFindFileCommand.cxx +++ b/Source/cmFindFileCommand.cxx @@ -38,7 +38,10 @@ bool cmFindFileCommand::Invoke(std::vector& args) = cmCacheManager::GetInstance()->GetCacheValue(define); if(cacheValue) { - m_Makefile->AddDefinition(define, cacheValue); + if(strcmp(cacheValue, "NOTFOUND") != 0) + { + m_Makefile->AddDefinition(define, cacheValue); + } return true; } // if it is not in the cache, then search the system path diff --git a/Source/cmFindIncludeCommand.cxx b/Source/cmFindIncludeCommand.cxx index 645ed0d61..7ffd4c9f8 100644 --- a/Source/cmFindIncludeCommand.cxx +++ b/Source/cmFindIncludeCommand.cxx @@ -34,11 +34,20 @@ bool cmFindIncludeCommand::Invoke(std::vector& args) { m_Makefile->AddDefinition(args[0].c_str(), cacheValue); } + cacheValue + = cmCacheManager::GetInstance()->GetCacheValue(args[1].c_str()); + if(cacheValue) + { + if(strcmp(cacheValue, "NOTFOUND") != 0) + { + m_Makefile->AddDefinition(args[1].c_str(), cacheValue); + } + } return true; } std::vector path; // add any user specified paths - for (unsigned int j = 2; j < args.size(); j++) + for (unsigned int j = 3; j < args.size(); j++) { // expand variables std::string exp = args[j]; @@ -53,20 +62,27 @@ bool cmFindIncludeCommand::Invoke(std::vector& args) { std::string tryPath = path[k]; tryPath += "/"; - tryPath += args[1]; + tryPath += args[2]; if(cmSystemTools::FileExists(tryPath.c_str())) { - m_Makefile->AddDefinition(args[0].c_str(), path[k].c_str()); // Save the value in the cache + m_Makefile->AddDefinition(args[0].c_str(), path[k].c_str()); cmCacheManager::GetInstance()->AddCacheEntry(args[0].c_str(), path[k].c_str(), cmCacheManager::PATH); + m_Makefile->AddDefinition(args[1].c_str(), args[2].c_str()); + cmCacheManager::GetInstance()->AddCacheEntry(args[1].c_str(), + args[2].c_str(), + cmCacheManager::PATH); return true; } } cmCacheManager::GetInstance()->AddCacheEntry(args[0].c_str(), "NOTFOUND", cmCacheManager::PATH); + cmCacheManager::GetInstance()->AddCacheEntry(args[1].c_str(), + "NOTFOUND", + cmCacheManager::PATH); std::string message = "Include not found: "; message += args[1]; message += "\n"; diff --git a/Source/cmFindIncludeCommand.h b/Source/cmFindIncludeCommand.h index f3f6dcfec..3c48922c1 100644 --- a/Source/cmFindIncludeCommand.h +++ b/Source/cmFindIncludeCommand.h @@ -68,7 +68,9 @@ public: virtual const char* GetFullDocumentation() { return - "FIND_INCLUDE(DEFINE include extraPath1 extraPath2 ...)"; + "FIND_INCLUDE(DEFINE_PATH DEFINE_INCLUDE includeName extraPath1 extraPath2 ...)\n" + "If the include file is found, then DEFINE_PATH is set to the path\n" + "where it was found and DEFINE_NAME is set to includeName"; } cmTypeMacro(cmFindIncludeCommand, cmCommand); diff --git a/Source/cmFindLibraryCommand.cxx b/Source/cmFindLibraryCommand.cxx index 1504af685..6587f0683 100644 --- a/Source/cmFindLibraryCommand.cxx +++ b/Source/cmFindLibraryCommand.cxx @@ -19,7 +19,7 @@ // cmFindLibraryCommand bool cmFindLibraryCommand::Invoke(std::vector& args) { - if(args.size() < 2 ) + if(args.size() < 2) { this->SetError("called with incorrect number of arguments"); return false; @@ -36,6 +36,7 @@ bool cmFindLibraryCommand::Invoke(std::vector& args) } return true; } + std::vector path; // add any user specified paths for (unsigned int j = 2; j < args.size(); j++) @@ -53,8 +54,36 @@ bool cmFindLibraryCommand::Invoke(std::vector& args) { std::string tryPath = path[k]; tryPath += "/"; - tryPath += args[1]; - if(cmSystemTools::FileExists(tryPath.c_str())) + std::string testF; + testF = tryPath + args[1] + ".lib"; + if(cmSystemTools::FileExists(testF.c_str())) + { + m_Makefile->AddDefinition(args[0].c_str(), path[k].c_str()); + cmCacheManager::GetInstance()->AddCacheEntry(args[0].c_str(), + path[k].c_str(), + cmCacheManager::PATH); + return true; + } + testF = tryPath + "lib" + args[1] + ".so"; + if(cmSystemTools::FileExists(testF.c_str())) + { + m_Makefile->AddDefinition(args[0].c_str(), path[k].c_str()); + cmCacheManager::GetInstance()->AddCacheEntry(args[0].c_str(), + path[k].c_str(), + cmCacheManager::PATH); + return true; + } + testF = tryPath + "lib" + args[1] + ".a"; + if(cmSystemTools::FileExists(testF.c_str())) + { + m_Makefile->AddDefinition(args[0].c_str(), path[k].c_str()); + cmCacheManager::GetInstance()->AddCacheEntry(args[0].c_str(), + path[k].c_str(), + cmCacheManager::PATH); + return true; + } + testF = tryPath + "lib" + args[1] + ".sl"; + if(cmSystemTools::FileExists(testF.c_str())) { m_Makefile->AddDefinition(args[0].c_str(), path[k].c_str()); cmCacheManager::GetInstance()->AddCacheEntry(args[0].c_str(), diff --git a/Source/cmFindLibraryCommand.h b/Source/cmFindLibraryCommand.h index f1e26a28e..6f01f62d1 100644 --- a/Source/cmFindLibraryCommand.h +++ b/Source/cmFindLibraryCommand.h @@ -69,7 +69,8 @@ public: virtual const char* GetFullDocumentation() { return - "FIND_LIBRARY(DEFINE libraryName path1 path2 path3...)"; + "FIND_LIBRARY(DEFINE_PATH libraryName path1 path2 path3...)\n" + "If the library is found, then DEFINE_PATH is set to the path where it was found"; } cmTypeMacro(cmFindLibraryCommand, cmCommand); diff --git a/Source/cmFindPathCommand.cxx b/Source/cmFindPathCommand.cxx new file mode 100644 index 000000000..5235ae2bd --- /dev/null +++ b/Source/cmFindPathCommand.cxx @@ -0,0 +1,74 @@ +/*========================================================================= + + Program: Insight Segmentation & Registration Toolkit + Module: $RCSfile$ + Language: C++ + Date: $Date$ + Version: $Revision$ + + + Copyright (c) 2000 National Path of Medicine + All rights reserved. + + See COPYRIGHT.txt for copyright details. + +=========================================================================*/ +#include "cmFindPathCommand.h" +#include "cmCacheManager.h" + +// cmFindPathCommand +bool cmFindPathCommand::Invoke(std::vector& args) +{ + if(args.size() < 2) + { + this->SetError("called with incorrect number of arguments"); + return false; + } + + // Now check and see if the value has been stored in the cache + // already, if so use that value and don't look for the program + const char* cacheValue + = cmCacheManager::GetInstance()->GetCacheValue(args[0].c_str()); + if(cacheValue) + { + if(strcmp(cacheValue, "NOTFOUND") != 0) + { + m_Makefile->AddDefinition(args[0].c_str(), cacheValue); + } + return true; + } + + std::vector path; + // add any user specified paths + for (unsigned int j = 2; j < args.size(); j++) + { + // expand variables + std::string exp = args[j]; + m_Makefile->ExpandVariablesInString(exp); + path.push_back(exp); + } + + // add the standard path + cmSystemTools::GetPath(path); + unsigned int k; + for(k=0; k < path.size(); k++) + { + std::string tryPath = path[k]; + tryPath += "/"; + tryPath += args[1]; + if(cmSystemTools::FileExists(tryPath.c_str())) + { + m_Makefile->AddDefinition(args[0].c_str(), path[k].c_str()); + cmCacheManager::GetInstance()->AddCacheEntry(args[0].c_str(), + path[k].c_str(), + cmCacheManager::PATH); + return true; + } + } + + cmCacheManager::GetInstance()->AddCacheEntry(args[0].c_str(), + "NOTFOUND", + cmCacheManager::PATH); + return true; +} + diff --git a/Source/cmFindPathCommand.h b/Source/cmFindPathCommand.h new file mode 100644 index 000000000..a01a4bb8d --- /dev/null +++ b/Source/cmFindPathCommand.h @@ -0,0 +1,81 @@ +/*========================================================================= + + Program: Insight Segmentation & Registration Toolkit + Module: $RCSfile$ + Language: C++ + Date: $Date$ + Version: $Revision$ + + + Copyright (c) 2000 National Path of Medicine + All rights reserved. + + See COPYRIGHT.txt for copyright details. + +=========================================================================*/ +#ifndef cmFindPathCommand_h +#define cmFindPathCommand_h + +#include "cmStandardIncludes.h" +#include "cmCommand.h" + + +/** \class cmFindPathCommand + * \brief Define a command to search for a library. + * + * cmFindPathCommand is used to define a CMake variable + * that specifies a library. The command searches for a given + * file in a list of directories. + */ +class cmFindPathCommand : public cmCommand +{ +public: + /** + * This is a virtual constructor for the command. + */ + virtual cmCommand* Clone() + { + return new cmFindPathCommand; + } + + /** + * This is called when the command is first encountered in + * the CMakeLists.txt file. + */ + virtual bool Invoke(std::vector& args); + + /** + * This determines if the command gets propagated down + * to makefiles located in subdirectories. + */ + virtual bool IsInherited() {return true;} + + /** + * The name of the command as specified in CMakeList.txt. + */ + virtual const char* GetName() {return "FIND_PATH";} + + /** + * Succinct documentation. + */ + virtual const char* GetTerseDocumentation() + { + return "Find a path for a file."; + } + + /** + * More documentation. + */ + virtual const char* GetFullDocumentation() + { + return + "FIND_PATH(PATH_DEFINE fileName path1 path2 path3...)\n" + "If the file is found, then PATH_DEFINE is set to the path where it was found"; + } + + cmTypeMacro(cmFindPathCommand, cmCommand); +}; + + + +#endif diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 41f167c1b..6446f985a 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -128,8 +128,6 @@ void cmMakefile::Print() const this->PrintStringVector("m_IncludeDirectories;", m_IncludeDirectories); this->PrintStringVector("m_LinkDirectories", m_LinkDirectories); this->PrintStringVector("m_LinkLibraries", m_LinkLibraries); - this->PrintStringVector("m_LinkLibrariesWin32", m_LinkLibrariesWin32); - this->PrintStringVector("m_LinkLibrariesUnix", m_LinkLibrariesUnix); this->PrintStringVector("m_Utilities", m_Utilities); this->PrintStringVector("m_UtilityDirectories", m_UtilityDirectories); } diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 221bd24f3..a8930b084 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -340,22 +340,6 @@ public: return m_LinkLibraries; } - /** - * Get a list of Win32 link libraries in the build. - */ - std::vector& GetLinkLibrariesWin32() - { - return m_LinkLibrariesWin32; - } - - /** - * Get a list of Unix link libraries in the build. - */ - std::vector& GetLinkLibrariesUnix() - { - return m_LinkLibrariesUnix; - } - /** * Return a list of source files in this makefile. */ @@ -463,8 +447,6 @@ protected: std::vector m_Utilities; std::vector m_UtilityDirectories; std::vector m_LinkLibraries; - std::vector m_LinkLibrariesWin32; - std::vector m_LinkLibrariesUnix; std::string m_IncludeFileRegularExpression; std::string m_DefineFlags; std::vector m_SourceGroups; diff --git a/Source/cmUnixMakefileGenerator.cxx b/Source/cmUnixMakefileGenerator.cxx index 589e4b14d..08392f2f4 100644 --- a/Source/cmUnixMakefileGenerator.cxx +++ b/Source/cmUnixMakefileGenerator.cxx @@ -154,13 +154,6 @@ void cmUnixMakefileGenerator::OutputLinkLibraries(std::ostream& fout, // For executables, add these a second time so order does not matter linkLibs += librariesLinked; } - - std::vector& libsUnix = m_Makefile->GetLinkLibrariesUnix(); - for(j = libsUnix.begin(); j != libsUnix.end(); ++j) - { - linkLibs += *j; - linkLibs += " "; - } linkLibs += " ${LOCAL_LINK_FLAGS} "; fout << linkLibs; }