cmFindPackageCommand.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  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() { return new cmFindPackageCommand; }
  27. /**
  28. * This is called when the command is first encountered in
  29. * the CMakeLists.txt file.
  30. */
  31. virtual bool InitialPass(std::vector<std::string> const& args,
  32. cmExecutionStatus& status);
  33. /**
  34. * This determines if the command is invoked when in script mode.
  35. */
  36. virtual bool IsScriptable() const { return true; }
  37. /**
  38. * The name of the command as specified in CMakeList.txt.
  39. */
  40. virtual std::string GetName() const { return "find_package"; }
  41. cmTypeMacro(cmFindPackageCommand, cmFindCommon);
  42. private:
  43. class PathLabel : public cmFindCommon::PathLabel
  44. {
  45. protected:
  46. PathLabel();
  47. public:
  48. PathLabel(const std::string& label)
  49. : cmFindCommon::PathLabel(label)
  50. {
  51. }
  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
  71. {
  72. NoPolicyScope,
  73. DoPolicyScope
  74. };
  75. bool ReadListFile(const char* f, PolicyScopeRule psr);
  76. void StoreVersionFound();
  77. void ComputePrefixes();
  78. void FillPrefixesCMakeEnvironment();
  79. void FillPrefixesCMakeVariable();
  80. void FillPrefixesSystemEnvironment();
  81. void FillPrefixesUserRegistry();
  82. void FillPrefixesSystemRegistry();
  83. void FillPrefixesCMakeSystemVariable();
  84. void FillPrefixesUserGuess();
  85. void FillPrefixesUserHints();
  86. void LoadPackageRegistryDir(std::string const& dir, cmSearchPath& outPaths);
  87. void LoadPackageRegistryWinUser();
  88. void LoadPackageRegistryWinSystem();
  89. void LoadPackageRegistryWin(bool user, unsigned int view,
  90. cmSearchPath& outPaths);
  91. bool CheckPackageRegistryEntry(const std::string& fname,
  92. cmSearchPath& outPaths);
  93. bool SearchDirectory(std::string const& dir);
  94. bool CheckDirectory(std::string const& dir);
  95. bool FindConfigFile(std::string const& dir, std::string& file);
  96. bool CheckVersion(std::string const& config_file);
  97. bool CheckVersionFile(std::string const& version_file,
  98. std::string& result_version);
  99. bool SearchPrefix(std::string const& prefix);
  100. bool SearchFrameworkPrefix(std::string const& prefix_in);
  101. bool SearchAppBundlePrefix(std::string const& prefix_in);
  102. friend class cmFindPackageFileList;
  103. struct OriginalDef
  104. {
  105. bool exists;
  106. std::string value;
  107. };
  108. std::map<std::string, OriginalDef> OriginalDefs;
  109. std::string Name;
  110. std::string Variable;
  111. std::string Version;
  112. unsigned int VersionMajor;
  113. unsigned int VersionMinor;
  114. unsigned int VersionPatch;
  115. unsigned int VersionTweak;
  116. unsigned int VersionCount;
  117. bool VersionExact;
  118. std::string FileFound;
  119. std::string VersionFound;
  120. unsigned int VersionFoundMajor;
  121. unsigned int VersionFoundMinor;
  122. unsigned int VersionFoundPatch;
  123. unsigned int VersionFoundTweak;
  124. unsigned int VersionFoundCount;
  125. KWIML_INT_uint64_t RequiredCMakeVersion;
  126. bool Quiet;
  127. bool Required;
  128. bool UseConfigFiles;
  129. bool UseFindModules;
  130. bool NoUserRegistry;
  131. bool NoSystemRegistry;
  132. bool DebugMode;
  133. bool UseLib32Paths;
  134. bool UseLib64Paths;
  135. bool PolicyScope;
  136. std::string LibraryArchitecture;
  137. std::vector<std::string> Names;
  138. std::vector<std::string> Configs;
  139. std::set<std::string> IgnoredPaths;
  140. struct ConfigFileInfo
  141. {
  142. std::string filename;
  143. std::string version;
  144. bool operator<(ConfigFileInfo const& rhs) const
  145. {
  146. return this->filename < rhs.filename;
  147. }
  148. bool operator==(ConfigFileInfo const& rhs) const
  149. {
  150. return this->filename == rhs.filename;
  151. }
  152. bool operator!=(ConfigFileInfo const& rhs) const
  153. {
  154. return !(*this == rhs);
  155. }
  156. };
  157. std::vector<ConfigFileInfo> ConsideredConfigs;
  158. };
  159. #endif