add_definitions.rst 1.2 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 sources in the current
  7. directory and below. This command can be used to add any flags, but
  8. it is intended to add preprocessor definitions. Flags
  9. beginning in -D or /D that look like preprocessor definitions are
  10. automatically added to the :prop_dir:`COMPILE_DEFINITIONS` directory
  11. property for the current directory. Definitions with non-trivial values
  12. may be left in the set of flags instead of being converted for reasons of
  13. backwards compatibility. See documentation of the
  14. :prop_dir:`directory <COMPILE_DEFINITIONS>`,
  15. :prop_tgt:`target <COMPILE_DEFINITIONS>`,
  16. :prop_sf:`source file <COMPILE_DEFINITIONS>` ``COMPILE_DEFINITIONS``
  17. properties for details on adding preprocessor definitions to specific
  18. scopes and configurations.
  19. Arguments to ``add_definitions`` may use "generator expressions" with
  20. the syntax "$<...>". See the :manual:`cmake-generator-expressions(7)`
  21. manual for available expressions. See the :manual:`cmake-buildsystem(7)`
  22. manual for more on defining buildsystem properties.