cmTargetLinkLibrariesCommand.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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 cmTargetLinkLibrariesCommand_h
  14. #define cmTargetLinkLibrariesCommand_h
  15. #include "cmCommand.h"
  16. /** \class cmTargetLinkLibrariesCommand
  17. * \brief Specify a list of libraries to link into executables.
  18. *
  19. * cmTargetLinkLibrariesCommand is used to specify a list of libraries to link
  20. * into executable(s) or shared objects. The names of the libraries
  21. * should be those defined by the LIBRARY(library) command(s).
  22. */
  23. class cmTargetLinkLibrariesCommand : public cmCommand
  24. {
  25. public:
  26. /**
  27. * This is a virtual constructor for the command.
  28. */
  29. virtual cmCommand* Clone()
  30. {
  31. return new cmTargetLinkLibrariesCommand;
  32. }
  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. cmExecutionStatus &status);
  39. /**
  40. * The name of the command as specified in CMakeList.txt.
  41. */
  42. virtual const char* GetName() { return "target_link_libraries";}
  43. /**
  44. * Succinct documentation.
  45. */
  46. virtual const char* GetTerseDocumentation()
  47. {
  48. return
  49. "Link a target to given libraries.";
  50. }
  51. /**
  52. * More documentation.
  53. */
  54. virtual const char* GetFullDocumentation()
  55. {
  56. return
  57. " target_link_libraries(<target> [lib1 [lib2 [...]]]\n"
  58. " [[debug|optimized|general] <lib>] ...)\n"
  59. "Specify a list of libraries to be linked into the specified target. "
  60. "If any library name matches that of a target in the current project "
  61. "a dependency will automatically be added in the build system to make "
  62. "sure the library being linked is up-to-date before the target links."
  63. "\n"
  64. "A \"debug\", \"optimized\", or \"general\" keyword indicates that "
  65. "the library immediately following it is to be used only for the "
  66. "corresponding build configuration. "
  67. "The \"debug\" keyword corresponds to the Debug configuration "
  68. "(or to configurations named in the DEBUG_CONFIGURATIONS global "
  69. "property if it is set). "
  70. "The \"optimized\" keyword corresponds to all other configurations. "
  71. "The \"general\" keyword corresponds to all configurations, and is "
  72. "purely optional (assumed if omitted). "
  73. "Higher granularity may be achieved for per-configuration rules "
  74. "by creating and linking to IMPORTED library targets. "
  75. "See the IMPORTED mode of the add_library command for more "
  76. "information. "
  77. "\n"
  78. "Library dependencies are transitive by default. "
  79. "When this target is linked into another target then the libraries "
  80. "linked to this target will appear on the link line for the other "
  81. "target too. "
  82. "See the LINK_INTERFACE_LIBRARIES target property to override the "
  83. "set of transitive link dependencies for a target."
  84. "\n"
  85. " target_link_libraries(<target> LINK_INTERFACE_LIBRARIES\n"
  86. " [[debug|optimized|general] <lib>] ...)\n"
  87. "The LINK_INTERFACE_LIBRARIES mode appends the libraries "
  88. "to the LINK_INTERFACE_LIBRARIES and its per-configuration equivalent "
  89. "target properties instead of using them for linking. "
  90. "Libraries specified as \"debug\" are appended to the "
  91. "the LINK_INTERFACE_LIBRARIES_DEBUG property (or to the properties "
  92. "corresponding to configurations listed in the DEBUG_CONFIGURATIONS "
  93. "global property if it is set). "
  94. "Libraries specified as \"optimized\" are appended to the "
  95. "the LINK_INTERFACE_LIBRARIES property. "
  96. "Libraries specified as \"general\" (or without any keyword) are "
  97. "treated as if specified for both \"debug\" and \"optimized\"."
  98. ;
  99. }
  100. cmTypeMacro(cmTargetLinkLibrariesCommand, cmCommand);
  101. private:
  102. void LinkLibraryTypeSpecifierWarning(int left, int right);
  103. static const char* LinkLibraryTypeNames[3];
  104. cmTarget* Target;
  105. bool DoingInterface;
  106. void HandleLibrary(const char* lib, cmTarget::LinkLibraryType llt);
  107. };
  108. #endif