From 1cb9f09b2d19d12f8affb6e5968d61a4c0f2485d Mon Sep 17 00:00:00 2001
From: Andreas Kloeckner <inform@tiker.net>
Date: Sat, 19 Nov 2011 19:52:50 -0500
Subject: [PATCH] Fix include path finding in cache.

---
 pyopencl/cache.py | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/pyopencl/cache.py b/pyopencl/cache.py
index cb9af2c3..f0d03cf7 100644
--- a/pyopencl/cache.py
+++ b/pyopencl/cache.py
@@ -299,10 +299,21 @@ class _SourceInfo(Record):
     pass
 
 def _create_built_program_from_source_cached(ctx, src, options, devices, cache_dir):
-    include_path = ["."] + [
-            option[2:]
-            for option in options
-            if option.startswith("-I") or option.startswith("/I")]
+    include_path = ["."]
+
+    option_idx = 0
+    while option_idx < len(options):
+        option = options[option_idx].strip()
+        if option.startswith("-I") or option.startswith("/I"):
+            if len(option) == 2:
+                if option_idx+1 < len(options):
+                    include_path.append(options[option_idx+1])
+                option_idx += 2
+            else:
+                include_path.append(option[2:])
+                option_idx += 1
+        else:
+            option_idx += 1
 
     if cache_dir is None:
         from os.path import join
-- 
GitLab