cmFindPackageCommand.h 3.3 KB

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