Author: Michael R. Crusoe <crusoe@debian.org>
Description: Use the packaged version of gtest
Forwarded: not-needed
--- seqan-raptor.orig/cmake/raptor_require_test.cmake
+++ seqan-raptor/cmake/raptor_require_test.cmake
@@ -10,22 +10,63 @@
 # Exposes the google-test targets `gtest` and `gtest_main`.
 macro (raptor_require_test)
     enable_testing ()
+    set (SEQAN3_TEST_CLONE_DIR "${PROJECT_BINARY_DIR}/vendor/googletest")
 
-    set (RAPTOR_GTEST_GIT_TAG "8d51dc50eb7e7698427fed81b85edad0e032112e" CACHE STRING "googletest commit to use")
+    # needed for add_library (seqan3::test::* INTERFACE IMPORTED)
+    # see cmake bug https://gitlab.kitware.com/cmake/cmake/issues/15052
+    file (MAKE_DIRECTORY ${SEQAN3_TEST_CLONE_DIR}/googletest/include/)
 
-    message (STATUS "Fetch Google Test:")
+    set (gtest_project_args ${SEQAN3_EXTERNAL_PROJECT_CMAKE_ARGS})
+    list (APPEND gtest_project_args "-DBUILD_GMOCK=0")
 
-    include (FetchContent)
-    FetchContent_Declare (
-        gtest_fetch_content
-        GIT_REPOSITORY "https://github.com/google/googletest.git"
-        GIT_TAG "${RAPTOR_GTEST_GIT_TAG}")
-    option (BUILD_GMOCK "" OFF)
-    FetchContent_MakeAvailable (gtest_fetch_content)
-
-    if (NOT TARGET gtest_build)
-        add_custom_target (gtest_build DEPENDS gtest_main gtest)
-        target_compile_options ("gtest_main" PUBLIC "-w")
-        target_compile_options ("gtest" PUBLIC "-w")
+    # force that libraries are installed to `lib/`, because GNUInstallDirs might install it into `lib64/`
+    list (APPEND gtest_project_args "-DCMAKE_INSTALL_LIBDIR=${PROJECT_BINARY_DIR}/lib/")
+
+    # google sets CMAKE_DEBUG_POSTFIX = "d"
+    set (gtest_main_path
+         "${PROJECT_BINARY_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}gtest_main${CMAKE_STATIC_LIBRARY_SUFFIX}")
+    if (CMAKE_BUILD_TYPE STREQUAL "Debug")
+        set (gtest_main_path
+             "${PROJECT_BINARY_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}gtest_maind${CMAKE_STATIC_LIBRARY_SUFFIX}")
+    endif ()
+
+    set (gtest_path "${PROJECT_BINARY_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}gtest${CMAKE_STATIC_LIBRARY_SUFFIX}")
+    if (CMAKE_BUILD_TYPE STREQUAL "Debug")
+        set (gtest_path "${PROJECT_BINARY_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}gtestd${CMAKE_STATIC_LIBRARY_SUFFIX}")
     endif ()
+
+    include (ExternalProject)
+    ExternalProject_Add (
+        gtest_project
+        PREFIX gtest_project
+	DOWNLOAD_COMMAND ""
+	SOURCE_DIR "/usr/src/googletest/"
+        CMAKE_ARGS "${gtest_project_args}"
+        BUILD_BYPRODUCTS "${gtest_main_path}" "${gtest_path}"
+        UPDATE_DISCONNECTED ${SEQAN3_TEST_BUILD_OFFLINE})
+    unset (gtest_project_args)
+
+    add_library (gtest_main STATIC IMPORTED)
+    add_dependencies (gtest_main gtest_project)
+    set_target_properties (gtest_main PROPERTIES IMPORTED_LOCATION "${gtest_main_path}")
+
+    add_library (gtest STATIC IMPORTED)
+    add_dependencies (gtest gtest_project)
+    set_target_properties (gtest PROPERTIES IMPORTED_LOCATION "${gtest_path}")
+    set_property (TARGET gtest
+                  APPEND
+                  PROPERTY INTERFACE_LINK_LIBRARIES "pthread")
+    set_property (TARGET gtest
+                  APPEND
+                  PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${SEQAN3_TEST_CLONE_DIR}/googletest/include/")
+
+    unset (gtest_main_path)
+    unset (gtest_path)
+    message (STATUS "Use googletest as external project.")
+
+    # if (NOT TARGET gtest_build)
+    #     add_custom_target (gtest_build DEPENDS gtest_main gtest)
+    #     target_compile_options ("gtest_main" PUBLIC "-w")
+    #     target_compile_options ("gtest" PUBLIC "-w")
+    # endif ()
 endmacro ()
--- seqan-raptor.orig/lib/chopper/test/cmake/chopper_require_test.cmake
+++ seqan-raptor/lib/chopper/test/cmake/chopper_require_test.cmake
@@ -11,21 +11,62 @@
 macro (chopper_require_test)
     enable_testing ()
 
-    set (CHOPPER_GTEST_GIT_TAG "8d51dc50eb7e7698427fed81b85edad0e032112e" CACHE STRING "googletest commit to use")
+    set (SEQAN3_TEST_CLONE_DIR "${PROJECT_BINARY_DIR}/vendor/googletest")
 
-    message (STATUS "Fetch Google Test:")
+    # needed for add_library (seqan3::test::* INTERFACE IMPORTED)
+    # see cmake bug https://gitlab.kitware.com/cmake/cmake/issues/15052
+    file (MAKE_DIRECTORY ${SEQAN3_TEST_CLONE_DIR}/googletest/include/)
 
-    include (FetchContent)
-    FetchContent_Declare (
-        gtest_fetch_content
-        GIT_REPOSITORY "https://github.com/google/googletest.git"
-        GIT_TAG "${CHOPPER_GTEST_GIT_TAG}")
-    option (BUILD_GMOCK "" OFF)
-    FetchContent_MakeAvailable (gtest_fetch_content)
-
-    if (NOT TARGET gtest_build)
-        add_custom_target (gtest_build DEPENDS gtest_main gtest)
-        target_compile_options ("gtest_main" PUBLIC "-w")
-        target_compile_options ("gtest" PUBLIC "-w")
+    set (gtest_project_args ${SEQAN3_EXTERNAL_PROJECT_CMAKE_ARGS})
+    list (APPEND gtest_project_args "-DBUILD_GMOCK=0")
+
+    # force that libraries are installed to `lib/`, because GNUInstallDirs might install it into `lib64/`
+    list (APPEND gtest_project_args "-DCMAKE_INSTALL_LIBDIR=${PROJECT_BINARY_DIR}/lib/")
+
+    # google sets CMAKE_DEBUG_POSTFIX = "d"
+    set (gtest_main_path
+         "${PROJECT_BINARY_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}gtest_main${CMAKE_STATIC_LIBRARY_SUFFIX}")
+    if (CMAKE_BUILD_TYPE STREQUAL "Debug")
+        set (gtest_main_path
+             "${PROJECT_BINARY_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}gtest_maind${CMAKE_STATIC_LIBRARY_SUFFIX}")
+    endif ()
+
+    set (gtest_path "${PROJECT_BINARY_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}gtest${CMAKE_STATIC_LIBRARY_SUFFIX}")
+    if (CMAKE_BUILD_TYPE STREQUAL "Debug")
+        set (gtest_path "${PROJECT_BINARY_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}gtestd${CMAKE_STATIC_LIBRARY_SUFFIX}")
     endif ()
+
+    include (ExternalProject)
+    ExternalProject_Add (
+        gtest_project
+        PREFIX gtest_project
+	DOWNLOAD_COMMAND ""
+	SOURCE_DIR "/usr/src/googletest/"
+        CMAKE_ARGS "${gtest_project_args}"
+        BUILD_BYPRODUCTS "${gtest_main_path}" "${gtest_path}"
+        UPDATE_DISCONNECTED ${SEQAN3_TEST_BUILD_OFFLINE})
+    unset (gtest_project_args)
+
+    add_library (gtest_main STATIC IMPORTED)
+    add_dependencies (gtest_main gtest_project)
+    set_target_properties (gtest_main PROPERTIES IMPORTED_LOCATION "${gtest_main_path}")
+
+    add_library (gtest STATIC IMPORTED)
+    add_dependencies (gtest gtest_project)
+    set_target_properties (gtest PROPERTIES IMPORTED_LOCATION "${gtest_path}")
+    set_property (TARGET gtest
+                  APPEND
+                  PROPERTY INTERFACE_LINK_LIBRARIES "pthread")
+    set_property (TARGET gtest
+                  APPEND
+                  PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${SEQAN3_TEST_CLONE_DIR}/googletest/include/")
+
+    unset (gtest_main_path)
+    unset (gtest_path)
+    message (STATUS "Use googletest as external project.")
+    # if (NOT TARGET gtest_build)
+    #     add_custom_target (gtest_build DEPENDS gtest_main gtest)
+    #     target_compile_options ("gtest_main" PUBLIC "-w")
+    #     target_compile_options ("gtest" PUBLIC "-w")
+    # endif ()
 endmacro ()
