>From bb02d8426a9a279df76376313349c17774030753 Mon Sep 17 00:00:00 2001
From: DRC <information@virtualgl.org>
Date: Tue, 26 Feb 2013 04:01:36 -0600
Subject: [PATCH 3/4] We need to unset CMAKE_REQUIRED_LIBRARIES after checking
 for the libpng functions.  Otherwise, under certain circumstances (known to
 be an issue when building on OS X with the in-tree libpng implementation),
 the scandir() function check will fail, leaving HAVE_SCANDIR unset, and the
 build will subsequently fail.

---
 CMakeLists.txt | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index cae895e..0984aae 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -210,6 +210,9 @@ if(LIB_png)
 endif(LIB_png)
 CHECK_FUNCTION_EXISTS(png_get_valid          HAVE_PNG_GET_VALID)
 CHECK_FUNCTION_EXISTS(png_set_tRNS_to_alpha  HAVE_PNG_SET_TRNS_TO_ALPHA)
+if(LIB_png)
+   set(CMAKE_REQUIRED_LIBRARIES "")
+endif(LIB_png)
 
 CHECK_FUNCTION_EXISTS(scandir                HAVE_SCANDIR)
 CHECK_FUNCTION_EXISTS(snprintf               HAVE_SNPRINTF)
-- 
1.8.1.3

