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

@@ -69,7 +69,8 @@ gnc_add_scheme_targets(scm-test-core
add_dependencies(check scm-test-core)
if(NOT GTEST_SHARED_LIB)
set (lib_gtest_SOURCES ${GTEST_SRC_DIR}/src/gtest-all.cc)
# in contrast to GoogleTest build system libraries libgtest.a and libgtest_main.a
# are combined to one library libtest.a here
add_library(gtest STATIC ${lib_gtest_SOURCES})
if(APPLE)
target_compile_options(gtest PRIVATE -Wno-missing-prototypes)