cmFindPackageCommand.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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() { return true; }
  40. /**
  41. * The name of the command as specified in CMakeList.txt.
  42. */
  43. virtual const char* GetName() { return "find_package";}
  44. /**
  45. * Succinct documentation.
  46. */
  47. virtual const char* GetTerseDocumentation()
  48. {
  49. return "Load settings for an external project.";
  50. }
  51. /**
  52. * More documentation.
  53. */
  54. virtual const char* GetFullDocumentation();
  55. cmTypeMacro(cmFindPackageCommand, cmFindCommon);
  56. private:
  57. void AppendSuccessInformation();
  58. void AppendToProperty(const char* propertyName);
  59. void SetModuleVariables(const std::string& components);
  60. bool FindModule(bool& found);
  61. void AddFindDefinition(const char* var, const char* val);
  62. void RestoreFindDefinitions();
  63. bool HandlePackageMode();
  64. bool FindConfig();
  65. bool FindPrefixedConfig();
  66. bool FindFrameworkConfig();
  67. bool FindAppBundleConfig();
  68. enum PolicyScopeRule { NoPolicyScope, DoPolicyScope };
  69. bool ReadListFile(const char* f, PolicyScopeRule psr);
  70. void StoreVersionFound();
  71. void ComputePrefixes();
  72. void AddPrefixesCMakeEnvironment();
  73. void AddPrefixesCMakeVariable();
  74. void AddPrefixesSystemEnvironment();
  75. void AddPrefixesRegistry();
  76. void AddPrefixesBuilds();
  77. void AddPrefixesCMakeSystemVariable();
  78. void AddPrefixesUserGuess();
  79. void AddPrefixesUserHints();
  80. void ComputeFinalPrefixes();
  81. void LoadPackageRegistryDir(std::string const& dir);
  82. void LoadPackageRegistryWin();
  83. bool CheckPackageRegistryEntry(std::istream& is);
  84. bool SearchDirectory(std::string const& dir);
  85. bool CheckDirectory(std::string const& dir);
  86. bool FindConfigFile(std::string const& dir, std::string& file);
  87. bool CheckVersion(std::string const& config_file);
  88. bool CheckVersionFile(std::string const& version_file,
  89. std::string& result_version);
  90. bool SearchPrefix(std::string const& prefix);
  91. bool SearchFrameworkPrefix(std::string const& prefix_in);
  92. bool SearchAppBundlePrefix(std::string const& prefix_in);
  93. friend class cmFindPackageFileList;
  94. struct OriginalDef { bool exists; std::string value; };
  95. std::map<cmStdString, OriginalDef> OriginalDefs;
  96. std::string CommandDocumentation;
  97. cmStdString Name;
  98. cmStdString Variable;
  99. cmStdString Version;
  100. unsigned int VersionMajor;
  101. unsigned int VersionMinor;
  102. unsigned int VersionPatch;
  103. unsigned int VersionTweak;
  104. unsigned int VersionCount;
  105. bool VersionExact;
  106. cmStdString FileFound;
  107. cmStdString VersionFound;
  108. unsigned int VersionFoundMajor;
  109. unsigned int VersionFoundMinor;
  110. unsigned int VersionFoundPatch;
  111. unsigned int VersionFoundTweak;
  112. unsigned int VersionFoundCount;
  113. bool Quiet;
  114. bool Required;
  115. bool Compatibility_1_6;
  116. bool NoModule;
  117. bool NoRegistry;
  118. bool NoBuilds;
  119. bool DebugMode;
  120. bool UseLib64Paths;
  121. bool PolicyScope;
  122. std::vector<std::string> Names;
  123. std::vector<std::string> Configs;
  124. std::set<std::string> IgnoredPaths;
  125. struct ConfigFileInfo { std::string filename; std::string version; };
  126. std::vector<ConfigFileInfo> ConsideredConfigs;
  127. };
  128. #endif