cmSetTargetPropertiesCommand.h 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  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 cmSetTargetsPropertiesCommand_h
  14. #define cmSetTargetsPropertiesCommand_h
  15. #include "cmCommand.h"
  16. class cmSetTargetPropertiesCommand : public cmCommand
  17. {
  18. public:
  19. virtual cmCommand* Clone()
  20. {
  21. return new cmSetTargetPropertiesCommand;
  22. }
  23. /**
  24. * This is called when the command is first encountered in
  25. * the input file.
  26. */
  27. virtual bool InitialPass(std::vector<std::string> const& args);
  28. /**
  29. * The name of the command as specified in CMakeList.txt.
  30. */
  31. virtual const char* GetName() { return "SET_TARGET_PROPERTIES";}
  32. /**
  33. * Succinct documentation.
  34. */
  35. virtual const char* GetTerseDocumentation()
  36. {
  37. return "Targets can have properties that affect how they are built.";
  38. }
  39. /**
  40. * Longer documentation.
  41. */
  42. virtual const char* GetFullDocumentation()
  43. {
  44. return
  45. " SET_TARGET_PROPERTIES(target1 target2 ...\n"
  46. " PROPERTIES prop1 value1\n"
  47. " prop2 value2 ...)\n"
  48. "Set properties on a target. The syntax for the command is to "
  49. "list all the files you want "
  50. "to change, and then provide the values you want to set next. "
  51. "You can use any prop value pair you want and "
  52. "extract it later with the GET_TARGET_PROPERTY command.\n"
  53. "Properties that affect the name of a target's output file are "
  54. "as follows. "
  55. "The PREFIX and SUFFIX properties override the default target name "
  56. "prefix (such as \"lib\") and suffix (such as \".so\"). "
  57. "IMPORT_PREFIX and IMPORT_SUFFIX are the equivalent properties for "
  58. "the import library corresponding to a DLL "
  59. "(for SHARED library targets). "
  60. "OUTPUT_NAME sets the real name of a target when it is built and "
  61. "can be used to help create two targets of the same name even though "
  62. "CMake requires unique logical target names. There is also a "
  63. "<CONFIG>_OUTPUT_NAME that can set the output name on a "
  64. "per-configuration basis. "
  65. "<CONFIG>_POSTFIX sets a postfix for the real name of the target "
  66. "when it is built under the configuration named by <CONFIG> "
  67. "(in upper-case, such as \"DEBUG_POSTFIX\"). The value of "
  68. "this property is initialized when the target is created to the "
  69. "value of the variable CMAKE_<CONFIG>_POSTFIX (except for executable "
  70. "targets because earlier CMake versions which did not use this "
  71. "variable for executables)."
  72. "\n"
  73. "The LINK_FLAGS property can be used to add extra flags to the "
  74. "link step of a target. LINK_FLAGS_<CONFIG> will add to the "
  75. "configuration <CONFIG>, "
  76. "for example, DEBUG, RELEASE, MINSIZEREL, RELWITHDEBINFO. "
  77. "DEFINE_SYMBOL sets the name of the preprocessor symbol defined when "
  78. "compiling sources in a shared library. "
  79. "If not set here then it is set to target_EXPORTS by default "
  80. "(with some substitutions if the target is not a valid C "
  81. "identifier). This is useful for headers to know whether they are "
  82. "being included from inside their library our outside to properly "
  83. "setup dllexport/dllimport decorations. "
  84. "The COMPILE_FLAGS property sets additional compiler flags used "
  85. "to build sources within the target. It may also be used to pass "
  86. "additional preprocessor definitions."
  87. "\n"
  88. "The LINKER_LANGUAGE property is used to change the tool "
  89. "used to link an executable or shared library. The default is "
  90. "set the language to match the files in the library. CXX and C "
  91. "are common values for this property."
  92. "\n"
  93. "For shared libraries VERSION and SOVERSION can be used to specify "
  94. "the build version and api version respectively. When building or "
  95. "installing appropriate symlinks are created if the platform "
  96. "supports symlinks and the linker supports so-names. "
  97. "If only one of both is specified the missing is assumed to have "
  98. "the same version number. "
  99. "For executables VERSION can be used to specify the build version. "
  100. "When building or installing appropriate symlinks are created if "
  101. "the platform supports symlinks. "
  102. "For shared libraries and executables on Windows the VERSION "
  103. "attribute is parsed to extract a \"major.minor\" version number. "
  104. "These numbers are used as the image version of the binary. "
  105. "\n"
  106. "There are a few properties used to specify RPATH rules. "
  107. "INSTALL_RPATH is a semicolon-separated list specifying the rpath "
  108. "to use in installed targets (for platforms that support it). "
  109. "INSTALL_RPATH_USE_LINK_PATH is a boolean that if set to true will "
  110. "append directories in the linker search path and outside the "
  111. "project to the INSTALL_RPATH. "
  112. "SKIP_BUILD_RPATH is a boolean specifying whether to skip automatic "
  113. "generation of an rpath allowing the target to run from the "
  114. "build tree. "
  115. "BUILD_WITH_INSTALL_RPATH is a boolean specifying whether to link "
  116. "the target in the build tree with the INSTALL_RPATH. This takes "
  117. "precedence over SKIP_BUILD_RPATH and avoids the need for relinking "
  118. "before installation. INSTALL_NAME_DIR is a string specifying the "
  119. "directory portion of the \"install_name\" field of shared libraries "
  120. "on Mac OSX to use in the installed targets. "
  121. "When the target is created the values of "
  122. "the variables CMAKE_INSTALL_RPATH, "
  123. "CMAKE_INSTALL_RPATH_USE_LINK_PATH, CMAKE_SKIP_BUILD_RPATH, "
  124. "CMAKE_BUILD_WITH_INSTALL_RPATH, and CMAKE_INSTALL_NAME_DIR "
  125. "are used to initialize these properties.\n"
  126. "PROJECT_LABEL can be used to change the name of "
  127. "the target in an IDE like visual studio. VS_KEYWORD can be set "
  128. "to change the visual studio keyword, for example QT integration "
  129. "works better if this is set to Qt4VSv1.0.\n"
  130. "When a library is built CMake by default generates code to remove "
  131. "any existing library using all possible names. This is needed "
  132. "to support libraries that switch between STATIC and SHARED by "
  133. "a user option. However when using OUTPUT_NAME to build a static "
  134. "and shared library of the same name using different logical target "
  135. "names the two targets will remove each other's files. This can be "
  136. "prevented by setting the CLEAN_DIRECT_OUTPUT property to 1.\n"
  137. "The PRE_INSTALL_SCRIPT and POST_INSTALL_SCRIPT properties are the "
  138. "old way to specify CMake scripts to run before and after "
  139. "installing a target. They are used only when the old "
  140. "INSTALL_TARGETS command is used to install the target. Use the "
  141. "INSTALL command instead."
  142. ;
  143. }
  144. cmTypeMacro(cmSetTargetPropertiesCommand, cmCommand);
  145. };
  146. #endif