1
0

cmFindPackageCommand.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /*=========================================================================
  2. Program: CMake - Cross-Platform Makefile Generator
  3. Module: $RCSfile$
  4. Language: C++
  5. Date: $Date$
  6. Version: $Revision$
  7. Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
  8. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
  9. This software is distributed WITHOUT ANY WARRANTY; without even
  10. the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  11. PURPOSE. See the above copyright notices for more information.
  12. =========================================================================*/
  13. #ifndef cmFindPackageCommand_h
  14. #define cmFindPackageCommand_h
  15. #include "cmStandardIncludes.h"
  16. #include "cmCommand.h"
  17. /** \class cmFindPackageCommand
  18. * \brief Load settings from an external project.
  19. *
  20. * cmFindPackageCommand
  21. */
  22. class cmFindPackageCommand : public cmCommand
  23. {
  24. public:
  25. /**
  26. * This is a virtual constructor for the command.
  27. */
  28. virtual cmCommand* Clone()
  29. {
  30. return new cmFindPackageCommand;
  31. }
  32. /** This command is inherited. */
  33. virtual bool IsInherited() {return true;}
  34. /**
  35. * This is called when the command is first encountered in
  36. * the CMakeLists.txt file.
  37. */
  38. virtual bool InitialPass(std::vector<std::string> const& args);
  39. /**
  40. * The name of the command as specified in CMakeList.txt.
  41. */
  42. virtual const char* GetName() { return "FIND_PACKAGE";}
  43. /**
  44. * Succinct documentation.
  45. */
  46. virtual const char* GetTerseDocumentation()
  47. {
  48. return "Load settings for an external project.";
  49. }
  50. /**
  51. * More documentation.
  52. */
  53. virtual const char* GetFullDocumentation()
  54. {
  55. return
  56. " FIND_PACKAGE(<name> [major.minor])\n"
  57. "Finds and loads settings from an external project. <name>_FOUND will "
  58. "be set to indicate whether the package was found. Settings that "
  59. "can be used when <name>_FOUND is true are package-specific. The "
  60. "package is found through several steps. "
  61. "Directories listed in CMAKE_MODULE_PATH are searched for files called "
  62. "\"Find<name>.cmake\". If such a file is found, it is read and "
  63. "processed by CMake, and is responsible for finding the package. "
  64. "If no such file is found, it is expected that the package is another "
  65. "project built by CMake that has a \"<name>Config.cmake\" file. "
  66. "A cache entry called <name>_DIR is created and is expected to be set "
  67. "to the directory containing this file. If the file is found, it is "
  68. "read and processed by CMake to load the settings of the package.";
  69. }
  70. cmTypeMacro(cmFindPackageCommand, cmCommand);
  71. private:
  72. bool FindModule(bool& found);
  73. bool FindConfig();
  74. std::string SearchForConfig() const;
  75. bool ReadListFile(const char* f);
  76. cmStdString Name;
  77. cmStdString UpperName;
  78. cmStdString Variable;
  79. cmStdString Config;
  80. std::vector<cmStdString> Builds;
  81. std::vector<cmStdString> Prefixes;
  82. std::vector<cmStdString> Relatives;
  83. };
  84. #endif