2013-02-04 83 views
8

我如何知道我正在使用的項目中正在使用哪個版本的Gtest?我正在開發一個Linux平臺。建立gtest版本

+0

你注入或鏈接? –

+0

@BЈовић鏈接 – Baz

+0

您在項目中看到gtest的哪些文件?你能找到gtest/gtest.h所在的文件夾嗎? – Strubbl

回答

0

gtest主目錄中的文件CHANGES包含一個gtest版本號。

1

源代碼libgtestlibgtest_main庫不包含允許識別它們的版本(如GetGTestVersion()或其他東西)的特殊功能。 頭文件也沒有任何定義的標識符(如GTEST_VERSION或其他東西)。 因此,您無法在用戶代碼的運行時檢查Google C++ Testing Framework的版本。

但維護者提供的框架特殊的腳本scripts/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通過configure.ac聲明的變量配置過程中獲得的框架的實際版本。

... 
AC_INIT([Google C++ Testing Framework], 
     [1.7.0], 
     [[email protected]], 
     [gtest]) 
... 

,並呼籲autoconfconfigure文件以下標識符填充後:

... 
# 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='[email protected]' 
PACKAGE_URL='' 
... 
# Define the identity of the package. 
PACKAGE='gtest' 
VERSION='1.7.0' 
... 

,只要與選項AC_CONFIG_HEADERS編譯框架這個標識符存儲到文件build-aux/config.h和availiable用戶在編譯時。