From 21a33ac3b07b00b510c80f50bde7cc42dcada039 Mon Sep 17 00:00:00 2001 From: Scott Murray Date: Thu, 6 Oct 2022 13:31:02 -0400 Subject: [PATCH 3/3] Disable default fetch and build of googletest The logic in test/unit-test/CMakeLists.txt was always fetching and building googletest even if the unit-test was not enabled (which is the default), rework it a bit to only do so when the unit-test is desired. Upstream-Status: Pending Signed-off-by: Scott Murray --- .../test/unit-test/CMakeLists.txt | 42 +++++++++---------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/kuksa-val-server/test/unit-test/CMakeLists.txt b/kuksa-val-server/test/unit-test/CMakeLists.txt index 55eedc9..6cec94f 100644 --- a/kuksa-val-server/test/unit-test/CMakeLists.txt +++ b/kuksa-val-server/test/unit-test/CMakeLists.txt @@ -16,18 +16,6 @@ enable_testing() include(CTest) include(FetchContent) -FetchContent_Declare( - googletest - GIT_REPOSITORY https://github.com/google/googletest.git - GIT_TAG release-1.11.0 -) - -FetchContent_GetProperties(googletest) -if(NOT googletest_POPULATED) - FetchContent_Populate(googletest) - add_subdirectory(${googletest_SOURCE_DIR} ${googletest_BINARY_DIR}) -endif() - ###### # CMake configuration responsible for building kuksa-val optional unit tests based on core library @@ -37,18 +25,30 @@ set(UNITTEST_EXE_NAME "kuksaval-unit-test" ) set(BUILD_UNIT_TEST OFF CACHE BOOL "Build unit tests") -### -# Setup targets +if(BUILD_UNIT_TEST) + FetchContent_Declare( + googletest + GIT_REPOSITORY https://github.com/google/googletest.git + GIT_TAG release-1.11.0 + ) -set(proto_gen_dir "${CMAKE_BINARY_DIR}/proto") -include_directories(${proto_gen_dir}) -include_directories(${googletest_SOURCE_DIR} ${googletest_BINARY_DIR}) + FetchContent_GetProperties(googletest) + if(NOT googletest_POPULATED) + FetchContent_Populate(googletest) + add_subdirectory(${googletest_SOURCE_DIR} ${googletest_BINARY_DIR}) + endif() -# Prevent GoogleTest from overriding our compiler/linker options -# when building with Visual Studio -set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) + ### + # Setup targets + + set(proto_gen_dir "${CMAKE_BINARY_DIR}/proto") + include_directories(${proto_gen_dir}) + include_directories(${googletest_SOURCE_DIR} ${googletest_BINARY_DIR}) + + # Prevent GoogleTest from overriding our compiler/linker options + # when building with Visual Studio + set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) -if(BUILD_UNIT_TEST) add_executable(${UNITTEST_EXE_NAME} AccessCheckerTests.cpp AuthenticatorTests.cpp -- 2.37.3