c++ command line - Define preprocessor macro through cmake
To do this for a specific target, you can do the following:
target_compile_definitions(my_target PRIVATE FOO=1 BAR=1)
You should do this if you have more than one target that you're building and you don't want them all to use the same flags.
How do I define a preprocessor variable through cmake?
The equivalent code would be