From a3061b8fe69fb8407d52d7f43cae57796015d185 Mon Sep 17 00:00:00 2001
From: Volker Schroer <3470424+dl1ksv@users.noreply.github.com>
Date: Tue, 24 Nov 2020 12:37:05 +0100
Subject: [PATCH 5/5] Do not disable boost, if only the unit_test_framework is
 missing

---
 CMakeLists.txt              | 14 ++++++++------
 cmake/Modules/GrBoost.cmake |  7 ++-----
 2 files changed, 10 insertions(+), 11 deletions(-)

--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -47,7 +47,14 @@
 message(STATUS "Build type set to ${CMAKE_BUILD_TYPE}.")
 
 include(GrComponent)
-GR_REGISTER_COMPONENT("testing-support" ENABLE_TESTING)
+########################################################################
+# Setup Boost for global use (within this build)
+# Do this before enabling testing support, as it depends
+# on unit_test_framework
+########################################################################
+include(GrBoost)
+GR_REGISTER_COMPONENT("testing-support" ENABLE_TESTING
+         Boost_unit_test_framework_FOUND )
 
 # Set the version information here
 SET(VERSION_MAJOR 3)
@@ -358,11 +365,6 @@
 )
 
 ########################################################################
-# Setup Boost for global use (within this build)
-########################################################################
-include(GrBoost)
-
-########################################################################
 # Enable python component
 ########################################################################
 include(GrPython)
--- a/cmake/Modules/GrBoost.cmake
+++ b/cmake/Modules/GrBoost.cmake
@@ -35,10 +35,6 @@
     thread
 )
 
-if(ENABLE_TESTING)
-    list(APPEND BOOST_REQUIRED_COMPONENTS unit_test_framework)
-endif(ENABLE_TESTING)
-
 if(UNIX AND NOT BOOST_ROOT AND EXISTS "/usr/lib64")
     list(APPEND BOOST_LIBRARYDIR "/usr/lib64") #fedora 64-bit fix
 endif(UNIX AND NOT BOOST_ROOT AND EXISTS "/usr/lib64")
@@ -85,7 +81,8 @@
     "1.71.0" "1.71"
 )
 
-find_package(Boost ${GR_BOOST_MIN_VERSION} COMPONENTS ${BOOST_REQUIRED_COMPONENTS})
+find_package(Boost ${GR_BOOST_MIN_VERSION} REQUIRED ${BOOST_REQUIRED_COMPONENTS}
+                                           OPTIONAL_COMPONENTS unit_test_framework)
 
 # Boost 1.52 disabled, see https://svn.boost.org/trac/boost/ticket/7669
 # Similar problems with Boost 1.46 and 1.47.
