1
0

cmOrderRuntimeDirectories.h 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /*=========================================================================
  2. Program: CMake - Cross-Platform Makefile Generator
  3. Module: $RCSfile$
  4. Language: C++
  5. Date: $Date$
  6. Version: $Revision$
  7. Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
  8. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
  9. This software is distributed WITHOUT ANY WARRANTY; without even
  10. the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  11. PURPOSE. See the above copyright notices for more information.
  12. =========================================================================*/
  13. #ifndef cmOrderRuntimeDirectories_h
  14. #define cmOrderRuntimeDirectories_h
  15. #include "cmStandardIncludes.h"
  16. class cmGlobalGenerator;
  17. /** \class cmOrderRuntimeDirectories
  18. * \brief Compute a safe runtime path order for a set of shared libraries.
  19. */
  20. class cmOrderRuntimeDirectories
  21. {
  22. public:
  23. cmOrderRuntimeDirectories(cmGlobalGenerator* gg, const char* name,
  24. const char* purpose);
  25. void AddLibrary(std::string const& fullPath, const char* soname = 0);
  26. void AddDirectories(std::vector<std::string> const& extra);
  27. std::vector<std::string> const& GetRuntimePath();
  28. private:
  29. cmGlobalGenerator* GlobalGenerator;
  30. std::string Name;
  31. std::string Purpose;
  32. bool Computed;
  33. std::vector<std::string> RuntimeSearchPath;
  34. // Runtime path computation.
  35. struct LibraryRuntimeEntry
  36. {
  37. // The file name of the library.
  38. std::string FileName;
  39. // The soname of the shared library if it is known.
  40. std::string SOName;
  41. // The directory in which the library is supposed to be found.
  42. std::string Directory;
  43. // The index assigned to the directory.
  44. int DirectoryIndex;
  45. };
  46. bool RuntimeSearchPathComputed;
  47. std::vector<LibraryRuntimeEntry> LibraryRuntimeInfo;
  48. std::vector<std::string> UserDirectories;
  49. std::set<cmStdString> LibraryRuntimeInfoEmmitted;
  50. std::vector<std::string> RuntimeDirectories;
  51. std::map<cmStdString, int> RuntimeDirectoryIndex;
  52. std::vector<int> RuntimeDirectoryVisited;
  53. void CollectRuntimeDirectories();
  54. int AddRuntimeDirectory(std::string const& dir);
  55. void FindConflictingLibraries();
  56. void FindDirectoriesForLib(unsigned int lri);
  57. void OrderRuntimeSearchPath();
  58. void VisitRuntimeDirectory(unsigned int i);
  59. void DiagnoseCycle();
  60. bool CycleDiagnosed;
  61. int WalkId;
  62. // Adjacency-list representation of runtime path ordering graph.
  63. // This maps from directory to those that must come *before* it.
  64. // Each entry that must come before is a pair. The first element is
  65. // the index of the directory that must come first. The second
  66. // element is the index of the runtime library that added the
  67. // constraint.
  68. typedef std::pair<int, int> RuntimeConflictPair;
  69. struct RuntimeConflictList: public std::vector<RuntimeConflictPair> {};
  70. std::vector<RuntimeConflictList> RuntimeConflictGraph;
  71. };
  72. #endif