cmFindPackageCommand.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  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. void AppendSuccessInformation();
  47. void AppendToFoundProperty(bool found);
  48. void SetModuleVariables(const std::string& components);
  49. bool FindModule(bool& found);
  50. void AddFindDefinition(const std::string& var, const char* val);
  51. void RestoreFindDefinitions();
  52. bool HandlePackageMode();
  53. bool FindConfig();
  54. bool FindPrefixedConfig();
  55. bool FindFrameworkConfig();
  56. bool FindAppBundleConfig();
  57. enum PolicyScopeRule { NoPolicyScope, DoPolicyScope };
  58. bool ReadListFile(const char* f, PolicyScopeRule psr);
  59. void StoreVersionFound();
  60. void ComputePrefixes();
  61. void FillPrefixesCMakeEnvironment();
  62. void FillPrefixesCMakeVariable();
  63. void FillPrefixesSystemEnvironment();
  64. void FillPrefixesUserRegistry();
  65. void FillPrefixesSystemRegistry();
  66. void FillPrefixesBuilds();
  67. void FillPrefixesCMakeSystemVariable();
  68. void FillPrefixesUserGuess();
  69. void FillPrefixesUserHints();
  70. void LoadPackageRegistryDir(std::string const& dir, cmSearchPath& outPaths);
  71. void LoadPackageRegistryWinUser();
  72. void LoadPackageRegistryWinSystem();
  73. void LoadPackageRegistryWin(bool user, unsigned int view,
  74. cmSearchPath& outPaths);
  75. bool CheckPackageRegistryEntry(const std::string& fname,
  76. cmSearchPath& outPaths);
  77. bool SearchDirectory(std::string const& dir);
  78. bool CheckDirectory(std::string const& dir);
  79. bool FindConfigFile(std::string const& dir, std::string& file);
  80. bool CheckVersion(std::string const& config_file);
  81. bool CheckVersionFile(std::string const& version_file,
  82. std::string& result_version);
  83. bool SearchPrefix(std::string const& prefix);
  84. bool SearchFrameworkPrefix(std::string const& prefix_in);
  85. bool SearchAppBundlePrefix(std::string const& prefix_in);
  86. friend class cmFindPackageFileList;
  87. struct OriginalDef { bool exists; std::string value; };
  88. std::map<std::string, OriginalDef> OriginalDefs;
  89. std::string Name;
  90. std::string Variable;
  91. std::string Version;
  92. unsigned int VersionMajor;
  93. unsigned int VersionMinor;
  94. unsigned int VersionPatch;
  95. unsigned int VersionTweak;
  96. unsigned int VersionCount;
  97. bool VersionExact;
  98. std::string FileFound;
  99. std::string VersionFound;
  100. unsigned int VersionFoundMajor;
  101. unsigned int VersionFoundMinor;
  102. unsigned int VersionFoundPatch;
  103. unsigned int VersionFoundTweak;
  104. unsigned int VersionFoundCount;
  105. cmIML_INT_uint64_t RequiredCMakeVersion;
  106. bool Quiet;
  107. bool Required;
  108. bool UseConfigFiles;
  109. bool UseFindModules;
  110. bool NoUserRegistry;
  111. bool NoSystemRegistry;
  112. bool NoBuilds;
  113. bool DebugMode;
  114. bool UseLib64Paths;
  115. bool PolicyScope;
  116. std::string LibraryArchitecture;
  117. std::vector<std::string> Names;
  118. std::vector<std::string> Configs;
  119. std::set<std::string> IgnoredPaths;
  120. struct ConfigFileInfo { std::string filename; std::string version; };
  121. std::vector<ConfigFileInfo> ConsideredConfigs;
  122. };
  123. #endif