I'm currently learning CMake and don't want to get bad habits since there is always 2 ways to do something in CMake (old way and modern way from what I have seen)
After reading some documentation about preprocessor in CMake and checking this post: Define preprocessor macro through cmake
I've come to the conclusion that I could either define a preprocessor as :
add_compile_definitions(FOO)
target_compile_definitions(myTarget PRIVATE FOO)
add_definitions(-DFOO)
and after some test they does actually all works as intended and define FOO
But now my question is what's the most "modern" way that I should use and what is really the difference between each functions, the only difference I noticed is that if I use target_compile_definitions(myTarget PUBLIC FOO)
it then define FOO
in parent target.