cmFindCommon.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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>
  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 cmMakefile;
  14. /** \class cmFindCommon
  15. * \brief Base class for FIND_XXX implementations.
  16. *
  17. * cmFindCommon is a parent class for cmFindBase,
  18. * cmFindProgramCommand, cmFindPathCommand, cmFindLibraryCommand,
  19. * cmFindFileCommand, and cmFindPackageCommand.
  20. */
  21. class cmFindCommon : public cmCommand
  22. {
  23. public:
  24. cmFindCommon();
  25. ~cmFindCommon() CM_OVERRIDE;
  26. protected:
  27. friend class cmSearchPath;
  28. /** Used to define groups of path labels */
  29. class PathGroup : public cmPathLabel
  30. {
  31. protected:
  32. PathGroup();
  33. public:
  34. PathGroup(const std::string& label)
  35. : cmPathLabel(label)
  36. {
  37. }
  38. static PathGroup All;
  39. };
  40. /* Individual path types */
  41. class PathLabel : public cmPathLabel
  42. {
  43. protected:
  44. PathLabel();
  45. public:
  46. PathLabel(const std::string& label)
  47. : cmPathLabel(label)
  48. {
  49. }
  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. /** Remove paths in the ignore set from the supplied vector. */
  71. void FilterPaths(const std::vector<std::string>& inPaths,
  72. const std::set<std::string>& ignore,
  73. std::vector<std::string>& outPaths);
  74. /** Compute final search path list (reroot + trailing slash). */
  75. void ComputeFinalPaths();
  76. /** Compute the current default root path mode. */
  77. void SelectDefaultRootPathMode();
  78. /** Compute the current default bundle/framework search policy. */
  79. void SelectDefaultMacMode();
  80. // Path arguments prior to path manipulation routines
  81. std::vector<std::string> UserHintsArgs;
  82. std::vector<std::string> UserGuessArgs;
  83. std::string CMakePathName;
  84. RootPathMode FindRootPathMode;
  85. bool CheckCommonArgument(std::string const& arg);
  86. void AddPathSuffix(std::string const& arg);
  87. void SetMakefile(cmMakefile* makefile);
  88. bool NoDefaultPath;
  89. bool NoCMakePath;
  90. bool NoCMakeEnvironmentPath;
  91. bool NoSystemEnvironmentPath;
  92. bool NoCMakeSystemPath;
  93. std::vector<std::string> SearchPathSuffixes;
  94. std::map<PathGroup, std::vector<PathLabel> > PathGroupLabelMap;
  95. std::vector<PathGroup> PathGroupOrder;
  96. std::map<std::string, PathLabel> PathLabelStringMap;
  97. std::map<PathLabel, cmSearchPath> LabeledPaths;
  98. std::vector<std::string> SearchPaths;
  99. std::set<std::string> SearchPathsEmitted;
  100. bool SearchFrameworkFirst;
  101. bool SearchFrameworkOnly;
  102. bool SearchFrameworkLast;
  103. bool SearchAppBundleFirst;
  104. bool SearchAppBundleOnly;
  105. bool SearchAppBundleLast;
  106. };
  107. #endif