add_compile_definitions.rst 1.0 KB

12345678910111213141516171819202122232425
  1. add_compile_definitions
  2. -----------------------
  3. Add preprocessor definitions to the compilation of source files.
  4. .. code-block:: cmake
  5. add_compile_definitions(<definition> ...)
  6. Adds preprocessor definitions to the compiler command line.
  7. The preprocessor definitions are added to the :prop_dir:`COMPILE_DEFINITIONS`
  8. directory property for the current ``CMakeLists`` file. They are also added to
  9. the :prop_tgt:`COMPILE_DEFINITIONS` target property for each target in the
  10. current ``CMakeLists`` file.
  11. Definitions are specified using the syntax ``VAR`` or ``VAR=value``.
  12. Function-style definitions are not supported. CMake will automatically
  13. escape the value correctly for the native build system (note that CMake
  14. language syntax may require escapes to specify some values).
  15. Arguments to ``add_compile_definitions`` may use "generator expressions" with
  16. the syntax ``$<...>``. See the :manual:`cmake-generator-expressions(7)`
  17. manual for available expressions. See the :manual:`cmake-buildsystem(7)`
  18. manual for more on defining buildsystem properties.