来源:https://stackoverflow.com/questions/9017573/define-preprocessor-macro-through-cmake
add_compile_definitions
Adds preprocessor definitions to the compiler command line for targets in the current directory and below (whether added before or after this command is invoked).
add_compile_definitions(OPENCV_VERSION=${OpenCV_VERSION})
add_compile_definitions(WITH_OPENCV2)
target_compile_definitions
Specifies compile definitions to use when compiling a given
target_compile_definitions(my_target PRIVATE FOO=1 BAR=1)