cmFindCommon.h 3.2 KB

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