kuksa-val: add recipe
[AGL/meta-agl-demo.git] / recipes-connectivity / kuksa-val / kuksa-val / 0004-Disable-default-fetch-and-build-of-googletest.patch
1 From 73701bc4ac7e0c21990f73139839bc633afdd772 Mon Sep 17 00:00:00 2001
2 From: Scott Murray <scott.murray@konsulko.com>
3 Date: Tue, 24 May 2022 10:21:44 -0400
4 Subject: [PATCH 4/4] Disable default fetch and build of googletest
5
6 The logic in test/unit-test/CMakeLists.txt was always fetching and
7 building googletest even if the unit-test was not enabled (which is
8 the default), rework it a bit to only do so when the unit-test is
9 desired.
10
11 Upstream-Status: Pending
12
13 Signed-off-by: Scott Murray <scott.murray@konsulko.com>
14 ---
15  test/unit-test/CMakeLists.txt | 42 +++++++++++++++++------------------
16  1 file changed, 21 insertions(+), 21 deletions(-)
17
18 diff --git a/test/unit-test/CMakeLists.txt b/test/unit-test/CMakeLists.txt
19 index 873d604..976eb18 100644
20 --- a/test/unit-test/CMakeLists.txt
21 +++ b/test/unit-test/CMakeLists.txt
22 @@ -16,18 +16,6 @@ enable_testing()
23  include(CTest)
24  include(FetchContent)
25  
26 -FetchContent_Declare(
27 -  googletest
28 -  GIT_REPOSITORY https://github.com/google/googletest.git
29 -  GIT_TAG        release-1.11.0
30 -)
31 -
32 -FetchContent_GetProperties(googletest)
33 -if(NOT googletest_POPULATED)
34 -  FetchContent_Populate(googletest)
35 -  add_subdirectory(${googletest_SOURCE_DIR} ${googletest_BINARY_DIR})
36 -endif()
37 -
38  ######
39  # CMake configuration responsible for building kuksa-val optional unit tests based on core library
40  
41 @@ -37,18 +25,30 @@ set(UNITTEST_EXE_NAME "kuksaval-unit-test" )
42  
43  set(BUILD_UNIT_TEST OFF CACHE BOOL "Build unit tests")
44  
45 -###
46 -# Setup targets
47 +if(BUILD_UNIT_TEST)
48 +  FetchContent_Declare(
49 +    googletest
50 +    GIT_REPOSITORY https://github.com/google/googletest.git
51 +    GIT_TAG        release-1.11.0
52 +  )
53  
54 -set(proto_gen_dir "${CMAKE_BINARY_DIR}/proto")
55 -include_directories(${proto_gen_dir})
56 -include_directories(${googletest_SOURCE_DIR} ${googletest_BINARY_DIR})
57 +  FetchContent_GetProperties(googletest)
58 +  if(NOT googletest_POPULATED)
59 +    FetchContent_Populate(googletest)
60 +    add_subdirectory(${googletest_SOURCE_DIR} ${googletest_BINARY_DIR})
61 +  endif()
62  
63 -# Prevent GoogleTest from overriding our compiler/linker options
64 -# when building with Visual Studio
65 -set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
66 +  ###
67 +  # Setup targets
68 +
69 +  set(proto_gen_dir "${CMAKE_BINARY_DIR}/proto")
70 +  include_directories(${proto_gen_dir})
71 +  include_directories(${googletest_SOURCE_DIR} ${googletest_BINARY_DIR})
72 +
73 +  # Prevent GoogleTest from overriding our compiler/linker options
74 +  # when building with Visual Studio
75 +  set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
76  
77 -if(BUILD_UNIT_TEST)
78    add_executable(${UNITTEST_EXE_NAME}
79      AccessCheckerTests.cpp
80      AuthenticatorTests.cpp
81 -- 
82 2.35.1
83