From ac533010f3cacb5b16f0885ceab85dea389394a2 Mon Sep 17 00:00:00 2001
From: Mario Lang <mlang@delysid.org>
Date: Sun, 13 Mar 2016 16:54:59 +0100
Subject: [PATCH] Support for OPTIONAL_COMPONENTS in FindBoost.cmake.

---
 Modules/FindBoost.cmake | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/Modules/FindBoost.cmake b/Modules/FindBoost.cmake
index c3058ea..eb2b11c 100644
--- a/Modules/FindBoost.cmake
+++ b/Modules/FindBoost.cmake
@@ -10,7 +10,9 @@
 #     [version] [EXACT]      # Minimum or EXACT version e.g. 1.36.0
 #     [REQUIRED]             # Fail with error if Boost is not found
 #     [COMPONENTS <libs>...] # Boost libraries by their canonical name
-#     )                      # e.g. "date_time" for "libboost_date_time"
+#                              e.g. "date_time" for "libboost_date_time"
+#     [OPTIONAL_COMPONENTS <libs>...] # Optional Boost libraries
+#     )
 #
 # This module finds headers and requested component libraries OR a CMake
 # package configuration file provided by a "Boost CMake" build.  For the
@@ -1476,12 +1478,11 @@ if(Boost_FOUND)
   # The headers were found.  Check for requested component libs.
   set(_boost_CHECKED_COMPONENT FALSE)
   set(_Boost_MISSING_COMPONENTS "")
-  foreach(COMPONENT ${Boost_FIND_COMPONENTS})
-    string(TOUPPER ${COMPONENT} COMPONENT)
+  foreach(component ${Boost_FIND_COMPONENTS})
+    string(TOUPPER ${component} COMPONENT)
     set(_boost_CHECKED_COMPONENT TRUE)
-    if(NOT Boost_${COMPONENT}_FOUND)
-      string(TOLOWER ${COMPONENT} COMPONENT)
-      list(APPEND _Boost_MISSING_COMPONENTS ${COMPONENT})
+    if(NOT Boost_${COMPONENT}_FOUND AND Boost_FIND_REQUIRED_${component})
+      list(APPEND _Boost_MISSING_COMPONENTS ${component})
     endif()
   endforeach()
 
-- 
2.7.0

