add_custom_target.rst 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. add_custom_target
  2. -----------------
  3. Add a target with no output so it will always be built.
  4. ::
  5. add_custom_target(Name [ALL] [command1 [args1...]]
  6. [COMMAND command2 [args2...] ...]
  7. [DEPENDS depend depend depend ... ]
  8. [WORKING_DIRECTORY dir]
  9. [COMMENT comment] [VERBATIM]
  10. [SOURCES src1 [src2...]])
  11. Adds a target with the given name that executes the given commands.
  12. The target has no output file and is ALWAYS CONSIDERED OUT OF DATE
  13. even if the commands try to create a file with the name of the target.
  14. Use ADD_CUSTOM_COMMAND to generate a file with dependencies. By
  15. default nothing depends on the custom target. Use ADD_DEPENDENCIES to
  16. add dependencies to or from other targets. If the ALL option is
  17. specified it indicates that this target should be added to the default
  18. build target so that it will be run every time (the command cannot be
  19. called ALL). The command and arguments are optional and if not
  20. specified an empty target will be created. If WORKING_DIRECTORY is
  21. set, then the command will be run in that directory. If it is a
  22. relative path it will be interpreted relative to the build tree
  23. directory corresponding to the current source directory. If COMMENT
  24. is set, the value will be displayed as a message before the commands
  25. are executed at build time. Dependencies listed with the DEPENDS
  26. argument may reference files and outputs of custom commands created
  27. with add_custom_command() in the same directory (CMakeLists.txt file).
  28. If VERBATIM is given then all arguments to the commands will be
  29. escaped properly for the build tool so that the invoked command
  30. receives each argument unchanged. Note that one level of escapes is
  31. still used by the CMake language processor before add_custom_target
  32. even sees the arguments. Use of VERBATIM is recommended as it enables
  33. correct behavior. When VERBATIM is not given the behavior is platform
  34. specific because there is no protection of tool-specific special
  35. characters.
  36. The SOURCES option specifies additional source files to be included in
  37. the custom target. Specified source files will be added to IDE
  38. project files for convenience in editing even if they have not build
  39. rules.