add_definitions.rst 1.1 KB

123456789101112131415161718192021222324252627
  1. add_definitions
  2. ---------------
  3. Adds -D define flags to the compilation of source files.
  4. ::
  5. add_definitions(-DFOO -DBAR ...)
  6. Adds definitions to the compiler command line for targets in the current
  7. directory and below (whether added before or after this command is invoked).
  8. This command can be used to add any flags, but it is intended to add
  9. preprocessor definitions (see the :command:`add_compile_options` command
  10. to add other flags).
  11. Flags beginning in -D or /D that look like preprocessor definitions are
  12. automatically added to the :prop_dir:`COMPILE_DEFINITIONS` directory
  13. property for the current directory. Definitions with non-trivial values
  14. may be left in the set of flags instead of being converted for reasons of
  15. backwards compatibility. See documentation of the
  16. :prop_dir:`directory <COMPILE_DEFINITIONS>`,
  17. :prop_tgt:`target <COMPILE_DEFINITIONS>`,
  18. :prop_sf:`source file <COMPILE_DEFINITIONS>` ``COMPILE_DEFINITIONS``
  19. properties for details on adding preprocessor definitions to specific
  20. scopes and configurations.
  21. See the :manual:`cmake-buildsystem(7)` manual for more on defining
  22. buildsystem properties.