[cmake]add_compile_definitions vs target_compile_definitions

来源: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)

猜你喜欢

转载自www.cnblogs.com/ConfuciusPei/p/12427589.html