cmFindPackageCommand.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  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 const char* GetName() const { return "find_package";}
  44. /**
  45. * Succinct documentation.
  46. */
  47. virtual const char* GetTerseDocumentation() const
  48. {
  49. return "Load settings for an external project.";
  50. }
  51. /**
  52. * More documentation.
  53. */
  54. virtual const char* GetFullDocumentation() const;
  55. cmTypeMacro(cmFindPackageCommand, cmFindCommon);
  56. protected:
  57. virtual void GenerateDocumentation();
  58. private:
  59. void AppendSuccessInformation();
  60. void AppendToFoundProperty(bool found);
  61. void SetModuleVariables(const std::string& components);
  62. bool FindModule(bool& found);
  63. void AddFindDefinition(const char* 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 AddPrefixesCMakeEnvironment();
  75. void AddPrefixesCMakeVariable();
  76. void AddPrefixesSystemEnvironment();
  77. void AddPrefixesUserRegistry();
  78. void AddPrefixesSystemRegistry();
  79. void AddPrefixesBuilds();
  80. void AddPrefixesCMakeSystemVariable();
  81. void AddPrefixesUserGuess();
  82. void AddPrefixesUserHints();
  83. void LoadPackageRegistryDir(std::string const& dir);
  84. void LoadPackageRegistryWinUser();
  85. void LoadPackageRegistryWinSystem();
  86. void LoadPackageRegistryWin(bool user, unsigned int view);
  87. bool CheckPackageRegistryEntry(std::istream& is);
  88. bool SearchDirectory(std::string const& dir);
  89. bool CheckDirectory(std::string const& dir);
  90. bool FindConfigFile(std::string const& dir, std::string& file);
  91. bool CheckVersion(std::string const& config_file);
  92. bool CheckVersionFile(std::string const& version_file,
  93. std::string& result_version);
  94. bool SearchPrefix(std::string const& prefix);
  95. bool SearchFrameworkPrefix(std::string const& prefix_in);
  96. bool SearchAppBundlePrefix(std::string const& prefix_in);
  97. friend class cmFindPackageFileList;
  98. struct OriginalDef { bool exists; std::string value; };
  99. std::map<cmStdString, OriginalDef> OriginalDefs;
  100. std::string CommandDocumentation;
  101. cmStdString Name;
  102. cmStdString Variable;
  103. cmStdString 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. cmStdString FileFound;
  111. cmStdString VersionFound;
  112. unsigned int VersionFoundMajor;
  113. unsigned int VersionFoundMinor;
  114. unsigned int VersionFoundPatch;
  115. unsigned int VersionFoundTweak;
  116. unsigned int VersionFoundCount;
  117. unsigned int RequiredCMakeVersion;
  118. bool Quiet;
  119. bool Required;
  120. bool Compatibility_1_6;
  121. bool UseConfigFiles;
  122. bool UseFindModules;
  123. bool NoUserRegistry;
  124. bool NoSystemRegistry;
  125. bool NoBuilds;
  126. bool DebugMode;
  127. bool UseLib64Paths;
  128. bool PolicyScope;
  129. std::string LibraryArchitecture;
  130. std::vector<std::string> Names;
  131. std::vector<std::string> Configs;
  132. std::set<std::string> IgnoredPaths;
  133. struct ConfigFileInfo { std::string filename; std::string version; };
  134. std::vector<ConfigFileInfo> ConsideredConfigs;
  135. };
  136. #endif