Add gtest_main.cc to libgtest.a

Currently when compiling GoogleTest from source code, source file
gtest_main.cc from GoogleTest repository is not compiled into any
library as in GoogleTest repository, where it is compiled into
libgtest_main.a. Instead gtest_main.cc is added to source file list
GTEST_SRC, which is then added to the list of source files of every
single GoogleTest based test application.

To simplify this gtest_main.cc is added to the source file list of
target gtest now. Additionally GTEST_SRC is merged into
lib_gtest_SOURCES, since both variables defined source files for
GoogleTest libraries.

Now target gtest generates library libgtest.a, which already contains
the main function from source file gtest_main.cc. This is different to
GoogleTest build system, where both are separated into two independent
libraries libgtest.a and libgtest_main.a.
This commit is contained in:
Christian Gruber
2019-08-15 23:20:45 +02:00
parent 188f8768b5
commit 1b4e481296
5 changed files with 19 additions and 28 deletions

View File

@@ -129,7 +129,10 @@ function(gnc_gtest_configure)
set(GTEST_LIB "${GTEST_MAIN_LIB};${GTEST_SHARED_LIB}" PARENT_SCOPE)
unset(GTEST_SRC_DIR CACHE)
else()
set(GTEST_SRC "${GTEST_SRC_DIR}/src/gtest_main.cc" PARENT_SCOPE)
set(lib_gtest_SOURCES
"${GTEST_SRC_DIR}/src/gtest_main.cc"
"${GTEST_SRC_DIR}/src/gtest-all.cc"
PARENT_SCOPE)
set(GTEST_LIB "${CMAKE_BINARY_DIR}/common/test-core/libgtest.a" PARENT_SCOPE)
endif()
else()