1From b1bf398015bc090020459954e5cd1ec3b51b8ac3 Mon Sep 17 00:00:00 2001
2From: Yi Zhao <yi.zhao@windriver.com>
3Date: Tue, 11 Jul 2023 16:53:46 +0800
4Subject: [PATCH] Do not build external gtest
5
6We don't need to build external gtest since we already depend on
7googletest.
8
9Upstream-Status: Inappropriate [embedded specific]
10
11Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
12---
13 CMakeLists.txt                    | 11 ----
14 test/CMakeLists.txt               | 22 +------
15 test/network_tests/CMakeLists.txt | 99 -------------------------------
16 3 files changed, 3 insertions(+), 129 deletions(-)
17
18diff --git a/CMakeLists.txt b/CMakeLists.txt
19index d791c12e..f1bcba27 100644
20--- a/CMakeLists.txt
21+++ b/CMakeLists.txt
22@@ -18,17 +18,6 @@ set (VSOMEIP_VERSION ${VSOMEIP_MAJOR_VERSION}.${VSOMEIP_MINOR_VERSION}.${VSOMEIP
23 set (PACKAGE_VERSION ${VSOMEIP_VERSION}) # Used in documentation/doxygen.in
24 set (CMAKE_VERBOSE_MAKEFILE off)
25
26-if (NOT GTEST_ROOT)
27-    if (DEFINED ENV{GTEST_ROOT})
28-        set(GTEST_ROOT $ENV{GTEST_ROOT})
29-    else()
30-        include(FetchContent)
31-        FetchContent_Declare(googletest GIT_REPOSITORY https://github.com/google/googletest.git GIT_TAG v1.14.0)
32-        FetchContent_Populate(googletest)
33-        set(GTEST_ROOT ${googletest_SOURCE_DIR})
34-    endif()
35-endif()
36-
37 ###################################################################################################
38 # see http://www.cmake.org/Wiki/CMake/Tutorials/How_to_create_a_ProjectConfig.cmake_file
39 ###################################################################################################
40diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
41index f66ac5d3..6f09bf40 100644
42--- a/test/CMakeLists.txt
43+++ b/test/CMakeLists.txt
44@@ -17,27 +17,11 @@ find_package(benchmark)
45 # remove export symbols from the cxx flags
46 string(REPLACE "${EXPORTSYMBOLS}" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
47
48-# check for set environment variable
49-if(${GTEST_ROOT} STREQUAL "n/a")
50-    message(STATUS "GTEST_ROOT is not defined. For building the tests the variable
51-             GTEST_ROOT has to be defined. Tests can not be built.")
52-    # early exit
53-    return()  # test can not be build -> make commands build_tests and check are not available
54-else()
55-    message(STATUS "GTEST_ROOT is set. gtest root path set to ${GTEST_ROOT}")
56+find_package(GTest)
57+if (NOT GTest_FOUND)
58+    message(WARNING "GTest is not found. Tests can not be built.")
59 endif()
60
61-# build google test as static library (always) -> therefore deactivate BUILD_SHARED_LIBS in case it is active
62-set(BUILD_SHARED_LIBS_AUTOMATIC_OFF 0)
63-if ("${BUILD_SHARED_LIBS}" STREQUAL "ON")
64-    set(BUILD_SHARED_LIBS OFF)
65-    set(BUILD_SHARED_LIBS_AUTOMATIC_OFF 1)
66-endif()
67-add_subdirectory(${GTEST_ROOT} ${CMAKE_CURRENT_BINARY_DIR}/gtest EXCLUDE_FROM_ALL)
68-if ("${BUILD_SHARED_LIBS_AUTOMATIC_OFF}" STREQUAL "1")
69-    set(BUILD_SHARED_LIBS ON)
70-    set(BUILD_SHARED_LIBS_AUTOMATIC_OFF 0)
71-endif()
72
73 ##############################################################################
74 # build tests
75diff --git a/test/network_tests/CMakeLists.txt b/test/network_tests/CMakeLists.txt
76index 883cc5cf..9a2a4f5e 100644
77--- a/test/network_tests/CMakeLists.txt
78+++ b/test/network_tests/CMakeLists.txt
79@@ -4116,105 +4116,6 @@ if(NOT ${TESTS_BAT})
80
81 endif()
82
83-##############################################################################
84-# Add for every test a dependency to gtest
85-##############################################################################
86-
87-if(NOT ${TESTS_BAT})
88-    add_dependencies(${TEST_CONFIGURATION} gtest)
89-    add_dependencies(${TEST_APPLICATION} gtest)
90-    add_dependencies(${TEST_APPLICATION_SINGLE_PROCESS_NAME} gtest)
91-    add_dependencies(${TEST_APPLICATION_AVAILABILITY_NAME} gtest)
92-    add_dependencies(${TEST_MAGIC_COOKIES_CLIENT} gtest)
93-    add_dependencies(${TEST_MAGIC_COOKIES_SERVICE} gtest)
94-    add_dependencies(${TEST_HEADER_FACTORY} gtest)
95-    add_dependencies(${TEST_HEADER_FACTORY_CLIENT} gtest)
96-    add_dependencies(${TEST_HEADER_FACTORY_SERVICE} gtest)
97-    add_dependencies(${TEST_LOCAL_ROUTING_SERVICE} gtest)
98-    add_dependencies(${TEST_LOCAL_ROUTING_CLIENT} gtest)
99-    add_dependencies(${TEST_EXTERNAL_LOCAL_ROUTING_SERVICE} gtest)
100-    add_dependencies(${TEST_PAYLOAD_SERVICE} gtest)
101-    add_dependencies(${TEST_PAYLOAD_CLIENT} gtest)
102-    add_dependencies(${TEST_BIG_PAYLOAD_SERVICE} gtest)
103-    add_dependencies(${TEST_BIG_PAYLOAD_CLIENT} gtest)
104-    add_dependencies(${TEST_CLIENT_ID_SERVICE} gtest)
105-    add_dependencies(${TEST_CLIENT_ID_UTILITY} gtest)
106-    add_dependencies(${TEST_DEBOUNCE_CLIENT} gtest)
107-    add_dependencies(${TEST_DEBOUNCE_SERVICE} gtest)
108-    add_dependencies(${TEST_DEBOUNCE_FILTER_CLIENT} gtest)
109-    add_dependencies(${TEST_DEBOUNCE_FILTER_SERVICE} gtest)
110-    add_dependencies(${TEST_DEBOUNCE_CALLBACK_CLIENT} gtest)
111-    add_dependencies(${TEST_DEBOUNCE_CALLBACK_SERVICE} gtest)
112-    add_dependencies(${TEST_DEBOUNCE_FREQUENCY_CLIENT} gtest)
113-    add_dependencies(${TEST_DEBOUNCE_FREQUENCY_SERVICE} gtest)
114-    add_dependencies(${TEST_SUBSCRIBE_NOTIFY_SERVICE} gtest)
115-    add_dependencies(${TEST_SUBSCRIBE_NOTIFY_ONE_EVENT_TWO_EVENTGROUPS_SERVICE} gtest)
116-    add_dependencies(${TEST_SUBSCRIBE_NOTIFY_ONE_EVENT_TWO_EVENTGROUPS_CLIENT} gtest)
117-    add_dependencies(${TEST_SUBSCRIBE_NOTIFY_ONE_SERVICE} gtest)
118-    add_dependencies(${TEST_CPU_LOAD_SERVICE} gtest)
119-    add_dependencies(${TEST_CPU_LOAD_CLIENT} gtest)
120-    add_dependencies(${TEST_INITIAL_EVENT_SERVICE} gtest)
121-    add_dependencies(${TEST_INITIAL_EVENT_CLIENT} gtest)
122-    add_dependencies(${TEST_INITIAL_EVENT_AVAILABILITY_CHECKER} gtest)
123-    add_dependencies(${TEST_INITIAL_EVENT_STOP_SERVICE} gtest)
124-    add_dependencies(${TEST_OFFER_SERVICE} gtest)
125-    add_dependencies(${TEST_OFFER_CLIENT} gtest)
126-    add_dependencies(${TEST_OFFER_SERVICE_EXTERNAL} gtest)
127-    add_dependencies(${TEST_OFFER_EXTERNAL_SD_MESSAGE_SENDER} gtest)
128-    add_dependencies(${TEST_OFFERED_SERVICES_INFO_CLIENT} gtest)
129-    add_dependencies(${TEST_OFFERED_SERVICES_INFO_SERVICE} gtest)
130-    add_dependencies(${TEST_PENDING_SUBSCRIPTION_SERVICE} gtest)
131-    add_dependencies(${TEST_PENDING_SUBSCRIPTION_CLIENT} gtest)
132-    add_dependencies(${TEST_MALICIOUS_DATA_SERVICE} gtest)
133-    add_dependencies(${TEST_MALICIOUS_DATA_CLIENT} gtest)
134-    if (${TEST_SECURITY})
135-        add_dependencies(${TEST_SECURITY_SERVICE} gtest)
136-        add_dependencies(${TEST_SECURITY_CLIENT} gtest)
137-    endif()
138-    add_dependencies(${TEST_E2E_SERVICE} gtest)
139-    add_dependencies(${TEST_E2E_CLIENT} gtest)
140-    if (${TEST_E2E_PROFILE_04})
141-    add_dependencies(${TEST_E2E_PROFILE_04_SERVICE} gtest)
142-    add_dependencies(${TEST_E2E_PROFILE_04_CLIENT} gtest)
143-    endif()
144-    if (${TEST_E2E_PROFILE_07})
145-    add_dependencies(${TEST_E2E_PROFILE_07_SERVICE} gtest)
146-    add_dependencies(${TEST_E2E_PROFILE_07_CLIENT} gtest)
147-    endif()
148-    add_dependencies(${TEST_EVENT_SERVICE} gtest)
149-    add_dependencies(${TEST_EVENT_CLIENT} gtest)
150-    if (NOT ${CMAKE_SYSTEM_NAME} MATCHES "QNX")
151-    add_dependencies(${TEST_NPDU_SERVICE_ONE} gtest)
152-    add_dependencies(${TEST_NPDU_SERVICE_TWO} gtest)
153-    add_dependencies(${TEST_NPDU_SERVICE_THREE} gtest)
154-    add_dependencies(${TEST_NPDU_SERVICE_FOUR} gtest)
155-    add_dependencies(${TEST_NPDU_CLIENT_ONE} gtest)
156-    add_dependencies(${TEST_NPDU_CLIENT_TWO} gtest)
157-    add_dependencies(${TEST_NPDU_CLIENT_THREE} gtest)
158-    add_dependencies(${TEST_NPDU_CLIENT_FOUR} gtest)
159-    add_dependencies(${TEST_NPDU_DAEMON_CLIENT} gtest)
160-    add_dependencies(${TEST_NPDU_DAEMON_SERVICE} gtest)
161-    endif()
162-    add_dependencies(${TEST_SOMEIPTP_CLIENT} gtest)
163-    add_dependencies(${TEST_SOMEIPTP_SERVICE} gtest)
164-    if(${TEST_SECOND_ADDRESS})
165-        add_dependencies(${TEST_SECOND_ADDRESS_CLIENT} gtest)
166-        add_dependencies(${TEST_SECOND_ADDRESS_SERVICE} gtest)
167-    endif()
168-    add_dependencies(${TEST_SUSPEND_RESUME_CLIENT} gtest)
169-    add_dependencies(${TEST_SUSPEND_RESUME_SERVICE} gtest)
170-else()
171-    add_dependencies(${TEST_APPLICATION} gtest)
172-    add_dependencies(${TEST_HEADER_FACTORY} gtest)
173-    add_dependencies(${TEST_HEADER_FACTORY_CLIENT} gtest)
174-    add_dependencies(${TEST_HEADER_FACTORY_SERVICE} gtest)
175-    add_dependencies(${TEST_PAYLOAD_SERVICE} gtest)
176-    add_dependencies(${TEST_PAYLOAD_CLIENT} gtest)
177-    add_dependencies(${TEST_BIG_PAYLOAD_SERVICE} gtest)
178-    add_dependencies(${TEST_BIG_PAYLOAD_CLIENT} gtest)
179-    add_dependencies(${TEST_LOCAL_ROUTING_SERVICE} gtest)
180-    add_dependencies(${TEST_LOCAL_ROUTING_CLIENT} gtest)
181-endif()
182
183 ##############################################################################
184 # Add tests to the target build_network_tests
185--
1862.25.1
187
188