cmAddLibraryCommand.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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 cmLibrarysCommand_h
  11. #define cmLibrarysCommand_h
  12. #include "cmCommand.h"
  13. /** \class cmLibrarysCommand
  14. * \brief Defines a list of executables to build.
  15. *
  16. * cmLibrarysCommand defines a list of executable (i.e., test)
  17. * programs to create.
  18. */
  19. class cmAddLibraryCommand : public cmCommand
  20. {
  21. public:
  22. /**
  23. * This is a virtual constructor for the command.
  24. */
  25. virtual cmCommand* Clone()
  26. {
  27. return new cmAddLibraryCommand;
  28. }
  29. /**
  30. * This is called when the command is first encountered in
  31. * the CMakeLists.txt file.
  32. */
  33. virtual bool InitialPass(std::vector<std::string> const& args,
  34. cmExecutionStatus &status);
  35. /**
  36. * The name of the command as specified in CMakeList.txt.
  37. */
  38. virtual const char* GetName() const { return "add_library";}
  39. /**
  40. * Succinct documentation.
  41. */
  42. virtual const char* GetTerseDocumentation() const
  43. {
  44. return "Add a library to the project using the specified source files.";
  45. }
  46. /**
  47. * More documentation.
  48. */
  49. virtual const char* GetFullDocumentation() const
  50. {
  51. return
  52. " add_library(<name> [STATIC | SHARED | MODULE]\n"
  53. " [EXCLUDE_FROM_ALL]\n"
  54. " source1 source2 ... sourceN)\n"
  55. "Adds a library target called <name> to be built from the "
  56. "source files listed in the command invocation. "
  57. "The <name> corresponds to the logical target name and must be "
  58. "globally unique within a project. "
  59. "The actual file name of the library built is constructed based on "
  60. "conventions of the native platform "
  61. "(such as lib<name>.a or <name>.lib)."
  62. "\n"
  63. "STATIC, SHARED, or MODULE may be given to specify the type of library "
  64. "to be created. "
  65. "STATIC libraries are archives of object files for use when linking "
  66. "other targets. "
  67. "SHARED libraries are linked dynamically and loaded at runtime. "
  68. "MODULE libraries are plugins that are not linked into other targets "
  69. "but may be loaded dynamically at runtime using dlopen-like "
  70. "functionality. "
  71. "If no type is given explicitly the type is STATIC or SHARED based "
  72. "on whether the current value of the variable BUILD_SHARED_LIBS is "
  73. "true."
  74. "\n"
  75. "By default the library file will be created in the build tree "
  76. "directory corresponding to the source tree directory in which "
  77. "the command was invoked. "
  78. "See documentation of the ARCHIVE_OUTPUT_DIRECTORY, "
  79. "LIBRARY_OUTPUT_DIRECTORY, and RUNTIME_OUTPUT_DIRECTORY "
  80. "target properties to change this location. "
  81. "See documentation of the OUTPUT_NAME target property to change "
  82. "the <name> part of the final file name. "
  83. "\n"
  84. "If EXCLUDE_FROM_ALL is given the corresponding property will be "
  85. "set on the created target. "
  86. "See documentation of the EXCLUDE_FROM_ALL target property for "
  87. "details."
  88. "\n"
  89. "The add_library command can also create IMPORTED library "
  90. "targets using this signature:\n"
  91. " add_library(<name> <SHARED|STATIC|MODULE|UNKNOWN> IMPORTED\n"
  92. " [GLOBAL])\n"
  93. "An IMPORTED library target references a library file located "
  94. "outside the project. "
  95. "No rules are generated to build it. "
  96. "The target name has scope in the directory in which it is created "
  97. "and below, but the GLOBAL option extends visibility. "
  98. "It may be referenced like any target built within the project. "
  99. "IMPORTED libraries are useful for convenient reference from "
  100. "commands like target_link_libraries. "
  101. "Details about the imported library are specified by setting "
  102. "properties whose names begin in \"IMPORTED_\". "
  103. "The most important such property is IMPORTED_LOCATION "
  104. "(and its per-configuration version IMPORTED_LOCATION_<CONFIG>) "
  105. "which specifies the location of the main library file on disk. "
  106. "See documentation of the IMPORTED_* properties for more information."
  107. ;
  108. }
  109. cmTypeMacro(cmAddLibraryCommand, cmCommand);
  110. };
  111. #endif