cmFindCommon.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. /*============================================================================
  2. CMake - Cross Platform Makefile Generator
  3. Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
  4. Distributed under the OSI-approved BSD License (the "License");
  5. see accompanying file Copyright.txt for details.
  6. This software is distributed WITHOUT ANY WARRANTY; without even the
  7. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  8. See the License for more information.
  9. ============================================================================*/
  10. #ifndef cmFindCommon_h
  11. #define cmFindCommon_h
  12. #include "cmCommand.h"
  13. #include "cmSearchPath.h"
  14. #include "cmPathLabel.h"
  15. /** \class cmFindCommon
  16. * \brief Base class for FIND_XXX implementations.
  17. *
  18. * cmFindCommon is a parent class for cmFindBase,
  19. * cmFindProgramCommand, cmFindPathCommand, cmFindLibraryCommand,
  20. * cmFindFileCommand, and cmFindPackageCommand.
  21. */
  22. class cmFindCommon : public cmCommand
  23. {
  24. public:
  25. cmFindCommon();
  26. ~cmFindCommon();
  27. cmTypeMacro(cmFindCommon, cmCommand);
  28. protected:
  29. friend class cmSearchPath;
  30. /* VS6 is broken and can't pass protected class definitions to child classes */
  31. #if defined(_MSC_VER) && (_MSC_VER < 1300)
  32. public:
  33. #endif
  34. /** Used to define groups of path labels */
  35. class PathGroup : public cmPathLabel
  36. {
  37. protected:
  38. PathGroup();
  39. public:
  40. PathGroup(const std::string& label) : cmPathLabel(label) { }
  41. static PathGroup All;
  42. };
  43. /* Individual path types */
  44. class PathLabel : public cmPathLabel
  45. {
  46. protected:
  47. PathLabel();
  48. public:
  49. PathLabel(const std::string& label) : cmPathLabel(label) { }
  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. #if defined(_MSC_VER) && (_MSC_VER < 1300)
  58. protected:
  59. #endif
  60. enum RootPathMode { RootPathModeNever,
  61. RootPathModeOnly,
  62. RootPathModeBoth };
  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