建立gtest版本
Establish gtest version
我如何知道我正在处理的项目中使用的是Gtest的哪个版本?我在linux平台上工作。
libgtest
或libgtest_main
库的源代码不包含允许识别其版本的特殊函数(类似于GetGTestVersion ()
或其他)。头文件也没有任何定义的标识符(比如GTEST_VERSION
或其他什么)。所以您不能在运行时在用户代码中检查Google C++ Testing Framework
的版本。
但是,作为框架的一部分,维护人员提供了特殊的脚本/gtest-conf,它是:
...
provides access to the necessary compile and linking
flags to connect with Google C++ Testing Framework, both in a build prior to
installation, and on the system proper after installation.
...
除其他外,这个脚本有几个与版本相关的选项:
...
Installation Queries:
...
--version the version of the Google Test installation
Version Queries:
--min-version=VERSION return 0 if the version is at least VERSION
--exact-version=VERSION return 0 if the version is exactly VERSION
--max-version=VERSION return 0 if the version is at most VERSION
...
该脚本还包含它的用法示例:
Examples:
gtest-config --min-version=1.0 || echo "Insufficient Google Test version."
...
这意味着用户可以使用脚本gtest-config
在构建时测试框架的版本。
注意:
脚本gtest-config
在配置期间通过config.ac.中声明的变量获得框架的实际版本
...
AC_INIT([Google C++ Testing Framework],
[1.7.0],
[googletestframework@googlegroups.com],
[gtest])
...
在调用autoconf
之后,填充了configure
文件中的以下标识符:
...
# Identity of this package.
PACKAGE_NAME='Google C++ Testing Framework'
PACKAGE_TARNAME='gtest'
PACKAGE_VERSION='1.7.0'
PACKAGE_STRING='Google C++ Testing Framework 1.7.0'
PACKAGE_BUGREPORT='googletestframework@googlegroups.com'
PACKAGE_URL=''
...
# Define the identity of the package.
PACKAGE='gtest'
VERSION='1.7.0'
...
到目前为止,使用选项AC_CONFIG_HEADERS编译的框架将该标识符存储在文件build-aux/config.h
中,并在编译时可供用户使用。
gtest主目录中的文件CHANGES包含gtest版本号。
如果您已经克隆了官方repo,您可以在Google Test的目录中检查最新的Git提交(例如使用git log -n 1
或git rev-parse HEAD
),并将其与发布版本列表进行比较。
在我的案例中,提交哈希是ec44c6c1675c25b9827aacd08c02433cccde7780,它对应于版本1.8.0。
相关文章:
- 为cl.exe(Visual Studio代码)指定命令行C++版本
- 导入库可以跨dll版本工作吗
- 在调用FreeLibrary后,释放动态链接到具有相同版本的CRT堆的DLL的内存
- 在clang++预处理器中确定gcc工具链版本
- 码头化的C++应用程序是否向后兼容早期的内核版本
- 不同的Visual Studio版本中缺少.dll
- 在gtest.中使用fff.h模拟系统API
- 用符号版本替换对函数的所有调用
- luaL_dofile在已知良好的字节码上失败,可以使用未编译的版本
- 正在解码MSVC 32位版本的程序集(作业).没有手术做什么
- 我需要分发哪些版本的可再分发文件
- CV_OCL_RUN宏如何在OpenCV(版本3.4.5)的goodFeaturesToTrack实现中工作?
- 在运行时读取 libstdc++ 版本
- 如何声明一个可以在整个程序中使用的全局 2d 3d 4d .. 数组(堆版本)变量?
- FindPackageHandleStandardArgs.cmake:137 的 CMake 错误(消息):找不到 Boost (缺少:正则表达式)(找到合适的版本"1.72.0",
- Vulkan SDK 版本 1.1.85.0 在 Kubuntu 18.10 上链接
- 如何正确实现与基类不同的版本?
- 如何解决GTest和LibTorch联动冲突
- 从预处理器获取 Windows 版本(C++ Win32)
- 建立gtest版本