cmFindPackageCommand.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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 cmFindPackageCommand_h
  11. #define cmFindPackageCommand_h
  12. #include "cmFindCommon.h"
  13. class cmFindPackageFileList;
  14. /** \class cmFindPackageCommand
  15. * \brief Load settings from an external project.
  16. *
  17. * cmFindPackageCommand
  18. */
  19. class cmFindPackageCommand : public cmFindCommon
  20. {
  21. public:
  22. cmFindPackageCommand();
  23. /**
  24. * This is a virtual constructor for the command.
  25. */
  26. virtual cmCommand* Clone()
  27. {
  28. return new cmFindPackageCommand;
  29. }
  30. /**
  31. * This is called when the command is first encountered in
  32. * the CMakeLists.txt file.
  33. */
  34. virtual bool InitialPass(std::vector<std::string> const& args,
  35. cmExecutionStatus &status);
  36. /**
  37. * This determines if the command is invoked when in script mode.
  38. */
  39. virtual bool IsScriptable() const { return true; }
  40. /**
  41. * The name of the command as specified in CMakeList.txt.
  42. */
  43. virtual std::string GetName() const { return "find_package";}
  44. cmTypeMacro(cmFindPackageCommand, cmFindCommon);
  45. private:
  46. class PathLabel : public cmFindCommon::PathLabel
  47. {
  48. protected:
  49. PathLabel();
  50. public:
  51. PathLabel(const std::string& label) : cmFindCommon::PathLabel(label) { }
  52. static PathLabel UserRegistry;
  53. static PathLabel Builds;
  54. static PathLabel SystemRegistry;
  55. };
  56. // Add additional search path labels and groups not present in the
  57. // parent class
  58. void AppendSearchPathGroups();
  59. void AppendSuccessInformation();
  60. void AppendToFoundProperty(bool found);
  61. void SetModuleVariables(const std::string& components);
  62. bool FindModule(bool& found);
  63. void AddFindDefinition(const std::string& var, const char* val);
  64. void RestoreFindDefinitions();
  65. bool HandlePackageMode();
  66. bool FindConfig();
  67. bool FindPrefixedConfig();
  68. bool FindFrameworkConfig();
  69. bool FindAppBundleConfig();
  70. enum PolicyScopeRule { NoPolicyScope, DoPolicyScope };
  71. bool ReadListFile(const char* f, PolicyScopeRule psr);
  72. void StoreVersionFound();
  73. void ComputePrefixes();
  74. void FillPrefixesCMakeEnvironment();
  75. void FillPrefixesCMakeVariable();
  76. void FillPrefixesSystemEnvironment();
  77. void FillPrefixesUserRegistry();
  78. void FillPrefixesSystemRegistry();
  79. void FillPrefixesCMakeSystemVariable();
  80. void FillPrefixesUserGuess();
  81. void FillPrefixesUserHints();
  82. void LoadPackageRegistryDir(std::string const& dir, cmSearchPath& outPaths);
  83. void LoadPackageRegistryWinUser();
  84. void LoadPackageRegistryWinSystem();
  85. void LoadPackageRegistryWin(bool user, unsigned int view,
  86. cmSearchPath& outPaths);
  87. bool CheckPackageRegistryEntry(const std::string& fname,
  88. cmSearchPath& outPaths);
  89. bool SearchDirectory(std::string const& dir);
  90. bool CheckDirectory(std::string const& dir);
  91. bool FindConfigFile(std::string const& dir, std::string& file);
  92. bool CheckVersion(std::string const& config_file);
  93. bool CheckVersionFile(std::string const& version_file,
  94. std::string& result_version);
  95. bool SearchPrefix(std::string const& prefix);
  96. bool SearchFrameworkPrefix(std::string const& prefix_in);
  97. bool SearchAppBundlePrefix(std::string const& prefix_in);
  98. friend class cmFindPackageFileList;
  99. struct OriginalDef { bool exists; std::string value; };
  100. std::map<std::string, OriginalDef> OriginalDefs;
  101. std::string Name;
  102. std::string Variable;
  103. std::string Version;
  104. unsigned int VersionMajor;
  105. unsigned int VersionMinor;
  106. unsigned int VersionPatch;
  107. unsigned int VersionTweak;
  108. unsigned int VersionCount;
  109. bool VersionExact;
  110. std::string FileFound;
  111. std::string VersionFound;
  112. unsigned int VersionFoundMajor;
  113. unsigned int VersionFoundMinor;
  114. unsigned int VersionFoundPatch;
  115. unsigned int VersionFoundTweak;
  116. unsigned int VersionFoundCount;
  117. cmIML_INT_uint64_t RequiredCMakeVersion;
  118. bool Quiet;
  119. bool Required;
  120. bool UseConfigFiles;
  121. bool UseFindModules;
  122. bool NoUserRegistry;
  123. bool NoSystemRegistry;
  124. bool DebugMode;
  125. bool UseLib64Paths;
  126. bool PolicyScope;
  127. std::string LibraryArchitecture;
  128. std::vector<std::string> Names;
  129. std::vector<std::string> Configs;
  130. std::set<std::string> IgnoredPaths;
  131. struct ConfigFileInfo { std::string filename; std::string version; };
  132. std::vector<ConfigFileInfo> ConsideredConfigs;
  133. };
  134. #endif