Browse Source

bug fixes

Ken Martin 24 years ago
parent
commit
30ad61805b

+ 15 - 0
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>

+ 100 - 0
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

+ 2 - 0
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<cmCommand*>& 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);

+ 37 - 31
Source/cmDSPMakefile.cxx

@@ -51,28 +51,6 @@ void cmDSPMakefile::OutputDSPFile()
     m_IncludeOptions += *i;
     m_IncludeOptions += "\" ";
     }
-  std::vector<std::string>& libs = m_Makefile->GetLinkLibraries();
-  for(i = libs.begin(); i != libs.end(); ++i)
-    {
-    m_LibraryOptions += " ";
-    m_LibraryOptions += *i;
-    m_LibraryOptions += ".lib ";
-    }
-  std::vector<std::string>& libswin32 = m_Makefile->GetLinkLibrariesWin32();
-  for(i = libswin32.begin(); i != libswin32.end(); ++i)
-    {
-    m_LibraryOptions += " ";
-    m_LibraryOptions += *i;
-    m_LibraryOptions += ".lib ";
-    }
-  std::vector<std::string>& 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<std::string>& 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<std::string>& 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<cmSourceGroup> 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;
     }

+ 6 - 5
Source/cmDSPMakefile.h

@@ -67,14 +67,16 @@ private:
   std::string m_DSPFooterTemplate;
   std::vector<std::string> 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<std::string>& outputs);
 
   std::string m_IncludeOptions;
-  std::string m_LibraryOptions;
   cmMakefile* m_Makefile;
   BuildType m_LibraryBuildType;
   std::vector<std::string> m_Configurations;

+ 37 - 31
Source/cmDSPWriter.cxx

@@ -51,28 +51,6 @@ void cmDSPMakefile::OutputDSPFile()
     m_IncludeOptions += *i;
     m_IncludeOptions += "\" ";
     }
-  std::vector<std::string>& libs = m_Makefile->GetLinkLibraries();
-  for(i = libs.begin(); i != libs.end(); ++i)
-    {
-    m_LibraryOptions += " ";
-    m_LibraryOptions += *i;
-    m_LibraryOptions += ".lib ";
-    }
-  std::vector<std::string>& libswin32 = m_Makefile->GetLinkLibrariesWin32();
-  for(i = libswin32.begin(); i != libswin32.end(); ++i)
-    {
-    m_LibraryOptions += " ";
-    m_LibraryOptions += *i;
-    m_LibraryOptions += ".lib ";
-    }
-  std::vector<std::string>& 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<std::string>& 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<std::string>& 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<cmSourceGroup> 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;
     }

+ 6 - 5
Source/cmDSPWriter.h

@@ -67,14 +67,16 @@ private:
   std::string m_DSPFooterTemplate;
   std::vector<std::string> 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<std::string>& outputs);
 
   std::string m_IncludeOptions;
-  std::string m_LibraryOptions;
   cmMakefile* m_Makefile;
   BuildType m_LibraryBuildType;
   std::vector<std::string> m_Configurations;

+ 4 - 1
Source/cmFindFileCommand.cxx

@@ -38,7 +38,10 @@ bool cmFindFileCommand::Invoke(std::vector<std::string>& 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

+ 19 - 3
Source/cmFindIncludeCommand.cxx

@@ -34,11 +34,20 @@ bool cmFindIncludeCommand::Invoke(std::vector<std::string>& 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<std::string> 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<std::string>& 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";

+ 3 - 1
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);

+ 32 - 3
Source/cmFindLibraryCommand.cxx

@@ -19,7 +19,7 @@
 // cmFindLibraryCommand
 bool cmFindLibraryCommand::Invoke(std::vector<std::string>& 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<std::string>& args)
       }
     return true;
     }
+
   std::vector<std::string> path;
   // add any user specified paths
   for (unsigned int j = 2; j < args.size(); j++)
@@ -53,8 +54,36 @@ bool cmFindLibraryCommand::Invoke(std::vector<std::string>& 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(),

+ 2 - 1
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);

+ 74 - 0
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<std::string>& 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<std::string> 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;
+}
+

+ 81 - 0
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<std::string>& 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

+ 0 - 2
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);
 }

+ 0 - 18
Source/cmMakefile.h

@@ -340,22 +340,6 @@ public:
     return m_LinkLibraries;
     }
 
-  /**
-   * Get a list of Win32 link libraries in the build.
-   */
-  std::vector<std::string>& GetLinkLibrariesWin32()
-    { 
-    return m_LinkLibrariesWin32;
-    }
-  
-  /**
-   * Get a list of Unix link libraries in the build.
-   */
-  std::vector<std::string>& GetLinkLibrariesUnix()
-    { 
-    return m_LinkLibrariesUnix;
-    }
-
   /**
    * Return a list of source files in this makefile.
    */
@@ -463,8 +447,6 @@ protected:
   std::vector<std::string> m_Utilities;
   std::vector<std::string> m_UtilityDirectories;
   std::vector<std::string> m_LinkLibraries;
-  std::vector<std::string> m_LinkLibrariesWin32;
-  std::vector<std::string> m_LinkLibrariesUnix;
   std::string m_IncludeFileRegularExpression;
   std::string m_DefineFlags;
   std::vector<cmSourceGroup> m_SourceGroups;

+ 0 - 7
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<std::string>& libsUnix = m_Makefile->GetLinkLibrariesUnix();
-  for(j = libsUnix.begin(); j != libsUnix.end(); ++j)
-    {
-    linkLibs += *j;
-    linkLibs += " ";
-    }
   linkLibs += " ${LOCAL_LINK_FLAGS} ";
   fout << linkLibs;
 }