[Cmake] CMake patches?

Amitha Perera perera at cs.rpi.edu
Mon May 28 23:39:24 EDT 2001


Is there a standard mechanism for submitting patches to CMake? In
particular, I have a modified cmUnixMakefileGenerator::OutputDependencies
that ensures that each dependency is only output once. I'd like to
incorporate into the standard CMake. I've included my modified version
of the function below. (I could submit a patch if necessary.)

If it is considered worthy, I'd appreciate someone adding it into the
repository.

Thanks,
Amitha.


void cmUnixMakefileGenerator::OutputDependencies(std::ostream& fout)
{
  // Each dependency should only be emitted once.
  std::map< std::string, bool > emitted;

  fout << "CMAKE_DEPEND_LIBS = ";
  cmTarget::LinkLibraries& libs = m_Makefile->GetLinkLibraries();
  cmTarget::LinkLibraries::const_iterator lib2;

  for(lib2 = libs.begin(); lib2 != libs.end(); ++lib2)
    {
    emitted[lib2->first] = false;
    }

  // Search the list of libraries that will be linked into
  // the executable
  for(lib2 = libs.begin(); lib2 != libs.end(); ++lib2)
    {
    // loop over the list of directories that the libraries might
    // be in, looking for an ADD_LIBRARY(lib...) line. This would
    // be stored in the cache
    if (emitted[lib2->first]) continue;
    emitted[lib2->first] = true;

    const char* cacheValue
      =
      cmCacheManager::GetInstance()->GetCacheValue(lib2->first.c_str());
    if(cacheValue)
      {
      std::string libpath = cacheValue;
      libpath += "/lib";
      libpath += lib2->first; 
      bool dll =
      cmCacheManager::GetInstance()->IsOn("BUILD_SHARED_LIBS");
      if(dll)
        {
        libpath += m_Makefile->GetDefinition("CMAKE_SHLIB_SUFFIX");
        }
      else
        {
        libpath += ".a";
        }
      fout << libpath << " ";
      }
    }
  fout << "\n\n";

  for(lib2 = libs.begin(); lib2 != libs.end(); ++lib2)
    {
    emitted[lib2->first] = false;
    }
  for(lib2 = libs.begin(); lib2 != libs.end(); ++lib2)
    {
    // loop over the list of directories that the libraries might
    // be in, looking for an ADD_LIBRARY(lib...) line. This would
    // be stored in the cache
    if (emitted[lib2->first]) continue;
    emitted[lib2->first] = true;

    const char* cacheValue
      =
      cmCacheManager::GetInstance()->GetCacheValue(lib2->first.c_str());
    if(cacheValue)
      {
      std::string library = "lib";
      library += lib2->first; 
      bool dll =
      cmCacheManager::GetInstance()->IsOn("BUILD_SHARED_LIBS");
      if(dll)
        {
        library += m_Makefile->GetDefinition("CMAKE_SHLIB_SUFFIX");
        }
      else
        {
        library += ".a";
        }
      std::string libpath = cacheValue;
      libpath += "/";
      libpath += library;
      // put out a rule to build the library if it does not exist
      fout << libpath.c_str()
           << ":\n\tcd " << cacheValue 
           << "; make " << library.c_str() << "\n\n";
      }
    }

  std::vector<std::string>& utils = m_Makefile->GetUtilities();
  std::vector<std::string>& utildirs =
  m_Makefile->GetUtilityDirectories();
  std::vector<std::string>::iterator dir, util;
  // Search the list of utilities that may be used to generate code
  for
  // this project.
  for(util = utils.begin(); util != utils.end(); ++util)
    {
    bool found = false;
    // loop over the list of directories that the utilities might
    // be in, looking for an ADD_EXECUTABLE(util ...) line.
    for(dir = utildirs.begin(); dir != utildirs.end() && !found;
    ++dir)
      {
      std::string expression = "TARGETS =.*";
      expression += util->c_str();
      if(cmSystemTools::Grep(dir->c_str(), "Makefile",
                             expression.c_str()))
        {
        fout << *util << " ";
        found = true;
        }
      }
    }
  fout << "\n";
}




More information about the CMake mailing list