From 19aeaedd5486289caf19faf0c2f5e64fed3ab2f4 Mon Sep 17 00:00:00 2001
From: Raphael Kubo da Costa <rakuco@FreeBSD.org>
Date: Thu, 15 Jan 2015 00:05:34 +0200
Subject: [PATCH] cmake: Make the check for QC_CERTSTORE_PATH actually work.

The previous code (present since the file was created) mixed different
checks that required different expansions:

* `if (ENV{foo})' will always evaluate to false even if $ENV{foo} is
  set, and may even be a CMake bug.
* `if (EXISTS ...)' expects an actual string, not an variable that has
  not been expanded.

It is not clear why the code expects QC_CERTSTORE_PATH to be an
environment variable instead of a regular variable passed to CMake in
the first place, but that can be changed in another commit.

REVIEW: 122062
---
 CMakeLists.txt | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index efab26bd..f005ea40 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -281,13 +281,13 @@ message(STATUS "Checking for certstore..")
 if( WIN32 )
 # USE BUILTIN
 else ( WIN32 )
-  if ( ENV{QC_CERTSTORE_PATH} )
-    if(EXISTS ENV{QC_CERTSTORE_PATH})
+  if ( DEFINED ENV{QC_CERTSTORE_PATH} )
+    if(EXISTS $ENV{QC_CERTSTORE_PATH})
       set( qca_CERTSTORE $ENV{QC_CERTSTORE_PATH})
-    else(EXISTS ENV{QC_CERTSTORE_PATH})
+    else(EXISTS $ENV{QC_CERTSTORE_PATH})
       # path to try
-    endif(EXISTS ENV{QC_CERTSTORE_PATH})
-  else( ENV{QC_CERTSTORE_PATH} )
+    endif(EXISTS $ENV{QC_CERTSTORE_PATH})
+  else( DEFINED ENV{QC_CERTSTORE_PATH} )
     set( toTry
       "/etc/ssl/certs/ca-certificates.crt"
       "/usr/share/ssl/cert.pem"
@@ -301,7 +301,7 @@ else ( WIN32 )
         set( qca_CERTSTORE ${_current_try})
       endif(EXISTS ${_current_try})
     endforeach (_current_try)
-  endif( ENV{QC_CERTSTORE_PATH} )
+  endif( DEFINED ENV{QC_CERTSTORE_PATH} )
 endif(WIN32)
 
 if (qca_CERTSTORE)