cmFindPackageCommand.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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. * 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. {
  56. return
  57. " FIND_PACKAGE(<name> [major.minor] [QUIET]\n"
  58. " [REQUIRED [componets...]])\n"
  59. "Finds and loads settings from an external project. <name>_FOUND will "
  60. "be set to indicate whether the package was found. Settings that "
  61. "can be used when <name>_FOUND is true are package-specific. The "
  62. "package is found through several steps. "
  63. "Directories listed in CMAKE_MODULE_PATH are searched for files called "
  64. "\"Find<name>.cmake\". If such a file is found, it is read and "
  65. "processed by CMake, and is responsible for finding the package. "
  66. "If no such file is found, it is expected that the package is another "
  67. "project built by CMake that has a \"<name>Config.cmake\" file. "
  68. "A cache entry called <name>_DIR is created and is expected to be set "
  69. "to the directory containing this file. If the file is found, it is "
  70. "read and processed by CMake to load the settings of the package. If "
  71. "<name>_DIR has not been set during a configure step, the command "
  72. "will generate an error describing the problem unless the QUIET "
  73. "argument is specified. If <name>_DIR has been set to a directory "
  74. "not containing a \"<name>Config.cmake\" file, an error is always "
  75. "generated. If REQUIRED is specified and the package is not found, "
  76. "a FATAL_ERROR is generated and the configure step stops executing."
  77. " A package-specific list of components may be listed after the "
  78. "REQUIRED option.";
  79. }
  80. cmTypeMacro(cmFindPackageCommand, cmCommand);
  81. private:
  82. bool FindModule(bool& found, bool quiet, bool required);
  83. bool FindConfig();
  84. std::string SearchForConfig() const;
  85. bool ReadListFile(const char* f);
  86. cmStdString Name;
  87. cmStdString Variable;
  88. cmStdString Config;
  89. std::vector<cmStdString> Builds;
  90. std::vector<cmStdString> Prefixes;
  91. std::vector<cmStdString> Relatives;
  92. };
  93. #endif