1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2025-01-28 18:04:51 +00:00

Updating to Googletest 1.8.0

This commit is contained in:
Carles Fernandez 2016-09-23 21:59:00 +02:00
parent 15eb6adb8b
commit 8aafb23c30
2 changed files with 74 additions and 75 deletions

View File

@ -171,20 +171,20 @@ $ sudo ldconfig
#### Build the [Google C++ Testing Framework](https://github.com/google/googletest "Googletest Homepage"), also known as googletest:
~~~~~~
$ wget https://github.com/google/googletest/archive/release-1.7.0.zip
$ unzip release-1.7.0.zip
$ cd googletest-release-1.7.0
$ cmake .
$ wget https://github.com/google/googletest/archive/release-1.8.0.zip
$ unzip release-1.8.0.zip
$ cd googletest-release-1.8.0
$ cmake -DBUILD_GTEST=ON -DBUILD_GMOCK=OFF .
$ make
~~~~~~
Please **DO NOT install** googletest (do *not* type ```sudo make install```). Every user needs to compile his tests using the same compiler flags used to compile the installed Google Test libraries; otherwise he may run into undefined behaviors (i.e. the tests can behave strangely and may even crash for no obvious reasons). The reason is that C++ has this thing called the One-Definition Rule: if two C++ source files contain different definitions of the same class/function/variable, and you link them together, you violate the rule. The linker may or may not catch the error (in many cases it is not required by the C++ standard to catch the violation). If it does not, you get strange run-time behaviors that are unexpected and hard to debug. If you compile Google Test and your test code using different compiler flags, they may see different definitions of the same class/function/variable (e.g. due to the use of ```#if``` in Google Test). Therefore, for your sanity, we recommend to avoid installing pre-compiled Google Test libraries. Instead, each project should compile Google Test itself such that it can be sure that the same flags are used for both Google Test and the tests. The building system of GNSS-SDR does the compilation and linking of googletest to its own tests; it is only required that you tell the system where the googletest folder that you downloaded resides. Just add to your ```$HOME/.bashrc``` file the following line:
~~~~~~
export GTEST_DIR=/home/username/gtest-1.7.0
export GTEST_DIR=/home/username/googletest-release-1.8.0/googletest
~~~~~~
changing /home/username/gtest-1.7.0 by the actual directory where you downloaded googletest.
changing /home/username/googletest-release-1.8.0/googletest by the actual directory where you built googletest.

View File

@ -36,24 +36,24 @@ endif(GTEST_INCLUDE_DIRS)
if(NOT ${GTEST_DIR_LOCAL})
# if GTEST_DIR is not defined, we download and build it
set(gtest_RELEASE 1.7.0)
set(gtest_RELEASE 1.8.0)
ExternalProject_Add(
gtest-${gtest_RELEASE}
GIT_REPOSITORY https://github.com/google/googletest
GIT_TAG release-${gtest_RELEASE}
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../thirdparty/gtest/gtest-${gtest_RELEASE}
BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/../../gtest-${gtest_RELEASE}
CMAKE_ARGS -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
CMAKE_ARGS -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} -DBUILD_GTEST=ON -DBUILD_GMOCK=OFF
UPDATE_COMMAND ""
PATCH_COMMAND ""
INSTALL_COMMAND ""
)
# Set up variables
# Set recently downloaded and build Googletest root folder
set(GTEST_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../thirdparty/gtest/gtest-${gtest_RELEASE}")
set(GTEST_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../thirdparty/gtest/gtest-${gtest_RELEASE}/googletest")
# Source code
ExternalProject_Get_Property(gtest-${gtest_RELEASE} source_dir)
set(GTEST_INCLUDE_DIR ${source_dir}/include)
set(GTEST_INCLUDE_DIR ${source_dir}/googletest/include)
set(GTEST_INCLUDE_DIRECTORIES ${GTEST_DIR}/include ${GTEST_DIR} ${GTEST_DIR}/src)
# Library
ExternalProject_Get_Property(gtest-${gtest_RELEASE} binary_dir)
@ -62,13 +62,13 @@ if(NOT ${GTEST_DIR_LOCAL})
set(binary_dir "${binary_dir}/Debug")
endif(CMAKE_GENERATOR STREQUAL Xcode)
endif(OS_IS_MACOSX)
set(GTEST_LIBRARY_PATH "${binary_dir}/${CMAKE_FIND_LIBRARY_PREFIXES}gtest.a;${binary_dir}/${CMAKE_FIND_LIBRARY_PREFIXES}gtest_main.a")
set(GTEST_LIBRARY_PATH "${binary_dir}/googletest/${CMAKE_FIND_LIBRARY_PREFIXES}gtest.a;${binary_dir}/googletest/${CMAKE_FIND_LIBRARY_PREFIXES}gtest_main.a")
set(GTEST_LIBRARY gtest-${gtest_RELEASE})
set(GTEST_LIBRARIES
${binary_dir}/${CMAKE_FIND_LIBRARY_PREFIXES}gtest.a
${binary_dir}/${CMAKE_FIND_LIBRARY_PREFIXES}gtest_main.a
${binary_dir}/googletest/${CMAKE_FIND_LIBRARY_PREFIXES}gtest.a
${binary_dir}/googletest/${CMAKE_FIND_LIBRARY_PREFIXES}gtest_main.a
)
set(GTEST_LIB_DIR "${CMAKE_CURRENT_BINARY_DIR}/../../gtest-${gtest_RELEASE}")
set(GTEST_LIB_DIR "${CMAKE_CURRENT_BINARY_DIR}/../../gtest-${gtest_RELEASE}/googletest")
else(NOT ${GTEST_DIR_LOCAL})
if(GTEST_INCLUDE_DIRS)
set(GTEST_INCLUDE_DIRECTORIES ${GTEST_INCLUDE_DIRS} ${LIBGTEST_DEV_DIR})
@ -372,4 +372,3 @@ endif(NOT ${GTEST_DIR_LOCAL})
add_dependencies(check control_thread_test flowgraph_test gnss_block_test
gnuradio_block_test trk_test)