如何在C++中创建自己的编译密钥
How to create your own compilation key in C++
您有自己的cmake c++项目,您需要创建一个编译密钥并在代码中获取有关它的信息。
我需要这样的东西。
在CmakeLists.txt中:
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -myTest")
在*.cpp 中
if(KEY == "myTest"){
// testing code.
}
在CMakeLists.txt 中
add_compile_definitions(TESTING)
add_compile_options(-Wall)
在*.cpp 中
#ifdef TESTING
std::cout << "testing" << std::endl;
#else
#endif
相关文章:
- 没有为自己的结构调用列表推回方法
- Qt5:使用QCommandLineParser类时出现奇怪的编译错误
- 要与"if constexpr"一起使用的编译时消息(在预处理器之后)
- 在他自己的方法中,有可能将一个对象取消引用到另一个对象吗
- 在c++中为我自己的基于指针的数组分配内存的正确方法
- 基于编译器选项的编译二进制路径
- C++常量数组的编译时间较长
- 第三方 API 中的编译错误 - Visual Studio
- 如何使用我构建的库,而不会从源代码出错,但不为我自己的项目编译?
- 如何在C++中创建自己的编译密钥
- 编译自己的 FFMPEG 过滤器
- 在命名空间中使用自己的类比较 std::vector 不会编译
- 如何编译自己的C代码作为ModemManager的一部分
- 无法编译.头文件.包含自己的对象定义
- 使用 OpenCV 编译头文件.自己的类定义
- 使用自己的库编译Qt GUI时发生链接器错误
- 我该如何编写一个通过从shell运行来编译自己的c++程序
- 编写我自己的字符串类"reference to ‘string’ is ambiguous"但出现编译错误
- 在编译我自己的代码时拒绝许可
- Visual Studio 2010 - C++ 如何在编译时创建我自己的警告