cmFindPackageCommand.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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 "cmCommand.h"
  16. /** \class cmFindPackageCommand
  17. * \brief Load settings from an external project.
  18. *
  19. * cmFindPackageCommand
  20. */
  21. class cmFindPackageCommand : public cmCommand
  22. {
  23. public:
  24. /**
  25. * This is a virtual constructor for the command.
  26. */
  27. virtual cmCommand* Clone()
  28. {
  29. return new cmFindPackageCommand;
  30. }
  31. /**
  32. * This is called when the command is first encountered in
  33. * the CMakeLists.txt file.
  34. */
  35. virtual bool InitialPass(std::vector<std::string> const& args);
  36. /**
  37. * The name of the command as specified in CMakeList.txt.
  38. */
  39. virtual const char* GetName() { return "FIND_PACKAGE";}
  40. /**
  41. * Succinct documentation.
  42. */
  43. virtual const char* GetTerseDocumentation()
  44. {
  45. return "Load settings for an external project.";
  46. }
  47. /**
  48. * More documentation.
  49. */
  50. virtual const char* GetFullDocumentation()
  51. {
  52. return
  53. " FIND_PACKAGE(<name> [major.minor] [QUIET] [REQUIRED])\n"
  54. "Finds and loads settings from an external project. <name>_FOUND will "
  55. "be set to indicate whether the package was found. Settings that "
  56. "can be used when <name>_FOUND is true are package-specific. The "
  57. "package is found through several steps. "
  58. "Directories listed in CMAKE_MODULE_PATH are searched for files called "
  59. "\"Find<name>.cmake\". If such a file is found, it is read and "
  60. "processed by CMake, and is responsible for finding the package. "
  61. "If no such file is found, it is expected that the package is another "
  62. "project built by CMake that has a \"<name>Config.cmake\" file. "
  63. "A cache entry called <name>_DIR is created and is expected to be set "
  64. "to the directory containing this file. If the file is found, it is "
  65. "read and processed by CMake to load the settings of the package. If "
  66. "<name>_DIR has not been set during a configure step, the command "
  67. "will generate an error describing the problem unless the QUIET "
  68. "argument is specified. If <name>_DIR has been set to a directory "
  69. "not containing a \"<name>Config.cmake\" file, an error is always "
  70. "generated. If REQUIRED is specified and the package is not found, "
  71. "a FATAL_ERROR is generated and the configure step stops executing.";
  72. }
  73. cmTypeMacro(cmFindPackageCommand, cmCommand);
  74. private:
  75. bool FindModule(bool& found, bool quiet, bool required);
  76. bool FindConfig();
  77. std::string SearchForConfig() const;
  78. bool ReadListFile(const char* f);
  79. cmStdString Name;
  80. cmStdString Variable;
  81. cmStdString Config;
  82. std::vector<cmStdString> Builds;
  83. std::vector<cmStdString> Prefixes;
  84. std::vector<cmStdString> Relatives;
  85. };
  86. #endif