通过cmake定义预处理器宏 [英] Define preprocessor macro through cmake
本文介绍了通过cmake定义预处理器宏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
问题很简单,我希望答案也。如何通过cmake定义预处理器变量?
The Question is simple and I hope the answer also. How do I define a preprocessor variable through cmake?
等效代码为 #define foo
。
任何帮助将非常感激。
推荐答案
CMake有 add_definitions
命令。示例:
CMake has the add_definitions
command for this purpose. An example:
add_definitions(-DOPENCV_VERSION=${OpenCV_VERSION})
add_definitions(-DWITH_OPENCV2)
虽然它看起来非常适合编译器,但它的工作是跨平台的,因为我们都知道并喜欢CMake。
Although it looks very compiler-specific, it works cross-platform due to some trickery we all know and love from CMake. CMake is such a shabby system.
有关命令的更多说明: https://cmake.org/cmake/help/latest/command/add_definitions.html
More explanation on the command here: https://cmake.org/cmake/help/latest/command/add_definitions.html
这篇关于通过cmake定义预处理器宏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文