cmFindCommon.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. file Copyright.txt or https://cmake.org/licensing for details. */
  3. #ifndef cmFindCommon_h
  4. #define cmFindCommon_h
  5. #include "cmCommand.h"
  6. #include "cmPathLabel.h"
  7. #include "cmSearchPath.h"
  8. /** \class cmFindCommon
  9. * \brief Base class for FIND_XXX implementations.
  10. *
  11. * cmFindCommon is a parent class for cmFindBase,
  12. * cmFindProgramCommand, cmFindPathCommand, cmFindLibraryCommand,
  13. * cmFindFileCommand, and cmFindPackageCommand.
  14. */
  15. class cmFindCommon : public cmCommand
  16. {
  17. public:
  18. cmFindCommon();
  19. ~cmFindCommon() CM_OVERRIDE;
  20. cmTypeMacro(cmFindCommon, cmCommand);
  21. protected:
  22. friend class cmSearchPath;
  23. /** Used to define groups of path labels */
  24. class PathGroup : public cmPathLabel
  25. {
  26. protected:
  27. PathGroup();
  28. public:
  29. PathGroup(const std::string& label)
  30. : cmPathLabel(label)
  31. {
  32. }
  33. static PathGroup All;
  34. };
  35. /* Individual path types */
  36. class PathLabel : public cmPathLabel
  37. {
  38. protected:
  39. PathLabel();
  40. public:
  41. PathLabel(const std::string& label)
  42. : cmPathLabel(label)
  43. {
  44. }
  45. static PathLabel CMake;
  46. static PathLabel CMakeEnvironment;
  47. static PathLabel Hints;
  48. static PathLabel SystemEnvironment;
  49. static PathLabel CMakeSystem;
  50. static PathLabel Guess;
  51. };
  52. enum RootPathMode
  53. {
  54. RootPathModeNever,
  55. RootPathModeOnly,
  56. RootPathModeBoth
  57. };
  58. /** Construct the various path groups and labels */
  59. void InitializeSearchPathGroups();
  60. /** Place a set of search paths under the search roots. */
  61. void RerootPaths(std::vector<std::string>& paths);
  62. /** Get ignored paths from CMAKE_[SYSTEM_]IGNORE_path variables. */
  63. void GetIgnoredPaths(std::vector<std::string>& ignore);
  64. void GetIgnoredPaths(std::set<std::string>& ignore);
  65. /** Remove paths in the ignore set from the supplied vector. */
  66. void FilterPaths(const std::vector<std::string>& inPaths,
  67. const std::set<std::string>& ignore,
  68. std::vector<std::string>& outPaths);
  69. /** Compute final search path list (reroot + trailing slash). */
  70. void ComputeFinalPaths();
  71. /** Compute the current default root path mode. */
  72. void SelectDefaultRootPathMode();
  73. /** Compute the current default bundle/framework search policy. */
  74. void SelectDefaultMacMode();
  75. // Path arguments prior to path manipulation routines
  76. std::vector<std::string> UserHintsArgs;
  77. std::vector<std::string> UserGuessArgs;
  78. std::string CMakePathName;
  79. RootPathMode FindRootPathMode;
  80. bool CheckCommonArgument(std::string const& arg);
  81. void AddPathSuffix(std::string const& arg);
  82. void SetMakefile(cmMakefile* makefile);
  83. bool NoDefaultPath;
  84. bool NoCMakePath;
  85. bool NoCMakeEnvironmentPath;
  86. bool NoSystemEnvironmentPath;
  87. bool NoCMakeSystemPath;
  88. std::vector<std::string> SearchPathSuffixes;
  89. std::map<PathGroup, std::vector<PathLabel> > PathGroupLabelMap;
  90. std::vector<PathGroup> PathGroupOrder;
  91. std::map<std::string, PathLabel> PathLabelStringMap;
  92. std::map<PathLabel, cmSearchPath> LabeledPaths;
  93. std::vector<std::string> SearchPaths;
  94. std::set<std::string> SearchPathsEmitted;
  95. bool SearchFrameworkFirst;
  96. bool SearchFrameworkOnly;
  97. bool SearchFrameworkLast;
  98. bool SearchAppBundleFirst;
  99. bool SearchAppBundleOnly;
  100. bool SearchAppBundleLast;
  101. };
  102. #endif