From 539cef345ef18262b2533a16e0850ec6d92fde37 Mon Sep 17 00:00:00 2001
From: Dominik Schmidt <dev@dominik-schmidt.de>
Date: Thu, 6 Dec 2018 12:03:59 +0100
Subject: [PATCH] Switch to standard opt-out BUILD_TESTING instead of opt-in
 UNIT_TESTING

Compare https://cmake.org/cmake/help/v3.0/module/CTest.html
Craft automatically handles BUILD_TESTING, so we don't need to handle it
in our own blueprint.
---
 .drone.yml                    | 4 ++--
 CMakeLists.txt                | 6 ++++--
 src/csync/DefineOptions.cmake | 1 -
 3 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/.drone.yml b/.drone.yml
index ab39fc1f0..0955e5492 100644
--- a/.drone.yml
+++ b/.drone.yml
@@ -9,7 +9,7 @@ steps:
       path: /drone/build
   commands:
     - cd /drone/build
-    - cmake -DCMAKE_C_COMPILER=gcc-10 -DCMAKE_CXX_COMPILER=g++-10 -DCMAKE_BUILD_TYPE=Debug -DNO_SHIBBOLETH=1 -DBUILD_UPDATER=ON -DUNIT_TESTING=1 -DSANITIZE_ADDRESS=ON ../src
+    - cmake -DCMAKE_C_COMPILER=gcc-10 -DCMAKE_CXX_COMPILER=g++-10 -DCMAKE_BUILD_TYPE=Debug -DNO_SHIBBOLETH=1 -DBUILD_UPDATER=ON -DBUILD_TESTING=1 -DSANITIZE_ADDRESS=ON ../src
 - name: compile
   image: nextcloudci/client-5.12:client-5.12-11
   volumes:
@@ -53,7 +53,7 @@ steps:
       path: /drone/build
   commands:
     - cd /drone/build
-    - cmake -GNinja -DCMAKE_EXPORT_COMPILE_COMMANDS=ON DCMAKE_C_COMPILER=clang-10 -DCMAKE_CXX_COMPILER=clang++-10 -DCMAKE_BUILD_TYPE=Debug -DNO_SHIBBOLETH=1 -DBUILD_UPDATER=ON -DUNIT_TESTING=1 -DSANITIZE_ADDRESS=ON ../src
+    - cmake -GNinja -DCMAKE_EXPORT_COMPILE_COMMANDS=ON DCMAKE_C_COMPILER=clang-10 -DCMAKE_CXX_COMPILER=clang++-10 -DCMAKE_BUILD_TYPE=Debug -DNO_SHIBBOLETH=1 -DBUILD_UPDATER=ON -DBUILD_TESTING=1 -DSANITIZE_ADDRESS=ON ../src
 - name: compile
   image: nextcloudci/client-5.12:client-5.12-11
   volumes:
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4c01fbd87..7da9f36de 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -259,9 +259,11 @@ if(BUILD_SHELL_INTEGRATION)
     add_subdirectory(shell_integration)
 endif()
 
-if(UNIT_TESTING)
+include(CTest)
+if(BUILD_TESTING)
+    enable_testing()
     add_subdirectory(test)
-endif(UNIT_TESTING)
+endif()
 
 configure_file(config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h)
 configure_file(version.h.in ${CMAKE_CURRENT_BINARY_DIR}/version.h)
diff --git a/src/csync/DefineOptions.cmake b/src/csync/DefineOptions.cmake
index 485e18322..5cb525fe4 100644
--- a/src/csync/DefineOptions.cmake
+++ b/src/csync/DefineOptions.cmake
@@ -1,2 +1 @@
-option(UNIT_TESTING "Build with unit tests" OFF)
 option(MEM_NULL_TESTS "Enable NULL memory testing" OFF)