如何将变量从 CMakeLists.txt 读取到 cpp 文件
how to read variables from CMakeLists.txt to cpp file
if (WITH_TEST)
add_subdirectory(test/unitTesting)
endif(WITH_TEST)
如何读取.cpp
文件中的with_test
变量?
解决方案可能是添加预处理器定义。
在您的 CMakeList 中:
add_definitions(-DWITH_TEST_VALUE ="${WITH_TEST}")
在你的源代码中,你可以做这样的事情:
#ifdef WITH_TEST_VALUE
constexpr auto WITH_TEST = WITH_TEST_VALUE;
#else
// something
#endif
相关文章:
- C++ gmock - 我们如何在单元测试 cpp 文件中读取/获取 cpp 文件函数的参数值
- C++/CPP 读取添加的十六进制地址
- CPP 在读取结构数据时无限循环错误?
- 如何将变量从 CMakeLists.txt 读取到 cpp 文件
- AWS S3 CPP SDK读取字节多于指定的范围
- 使用stat和read()读取cpp文件时出错
- 使用tserial.cpp驱动程序读取COM端口时的延迟
- 如何在cpp中读取多行
- 如何使用ESE CPP api从ESE数据库文件中读取字符串值
- Rational软件架构师如何将.h和.cpp文件读取到新项目中
- 允许写入/读取的联机CPP编译器
- 从.cpp文件(C++)中的头文件读取枚举
- 如何使用cpp从ESE数据库中读取记录
- CPP快速读取双倍的小二进制文件
- 是否可以像txt文件一样读取cpp文件
- Eclipse 在使用 freopen 或 fopen CPP 时无法读取文件
- 如何读取.cpp文件中的下一个字符
- 从.cpp文件读取时出现问题
- 使用CPP读取CSV文件,使用CMake文件编译代码
- 使用python解析或读取CPP文件,并通过忽略CPP文件注释来添加数据