cmAddLibraryCommand.h 4.6 KB

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