0

I have seen some reference to CMake's target_compile_definitions. After reading it and some other references it is not clear to me. What exactly are definitions as applied to C++ compilation using CMake?

Amani
  • 16,245
  • 29
  • 103
  • 153

1 Answers1

1

It's for setting preprocessor macros that are passed to the compilers preprocessor on the command-line.

For example

target_compile_definitions(some_target PRIVATE FOO=123)

will on GCC cause the option -DFOO=123 to be passed, which defines the macro FOO with the body 123 (i.e. all instances of FOO in the source is replaced by 123).

Some programmer dude
  • 400,186
  • 35
  • 402
  • 621
  • Asked this following a comment from my other question (https://stackoverflow.com/questions/44737859/generating-visual-studio-2017-projects-with-cmake). It is not clear to me what the comment meant as applied to my posted code. – Amani Jun 24 '17 at 17:35