From 38ec6e5550b9f50a7393182b48c5c26cad4d541f Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Sun, 27 Aug 2017 10:37:49 -0700
Subject: [PATCH] libcxxabi: Find libunwind headers when
 LIBCXXABI_LIBUNWIND_INCLUDES is set

Currently, when LIBCXXABI_LIBUNWIND_INCLUDES is set via CMake arguments
then it ends up not searching the specified dir and unwind.h is not found
especially for ARM targets

This patch makes the searching synthesized directories and then set
LIBCXXABI_LIBUNWIND_INCLUDES if its there in environment

Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
 CMakeLists.txt | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1adbdb3..ba4e9d7 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -409,15 +409,10 @@ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${LIBCXXABI_C_FLAGS}")
 # Setup Source Code
 #===============================================================================
 
-set(LIBCXXABI_LIBUNWIND_INCLUDES "${LIBCXXABI_LIBUNWIND_INCLUDES}" CACHE PATH
-    "Specify path to libunwind includes." FORCE)
-set(LIBCXXABI_LIBUNWIND_PATH "${LIBCXXABI_LIBUNWIND_PATH}" CACHE PATH
-    "Specify path to libunwind source." FORCE)
-
 include_directories(include)
 if (LIBCXXABI_USE_LLVM_UNWINDER OR LLVM_NATIVE_ARCH MATCHES ARM)
   find_path(
-    LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL
+    LIBCXXABI_LIBUNWIND_INCLUDES
     libunwind.h
     PATHS ${LIBCXXABI_LIBUNWIND_INCLUDES}
           ${LIBCXXABI_LIBUNWIND_PATH}/include
@@ -427,15 +422,21 @@ if (LIBCXXABI_USE_LLVM_UNWINDER OR LLVM_NATIVE_ARCH MATCHES ARM)
     NO_DEFAULT_PATH
   )
 
-  if (LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL STREQUAL "LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL-NOTFOUND")
-    set(LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL "")
+  if (LIBCXXABI_LIBUNWIND_INCLUDES STREQUAL "LIBCXXABI_LIBUNWIND_INCLUDES-NOTFOUND")
+    set(LIBCXXABI_LIBUNWIND_INCLUDES "")
   endif()
 
-  if (NOT LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL STREQUAL "")
-    include_directories("${LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL}")
+  if (NOT LIBCXXABI_LIBUNWIND_INCLUDES STREQUAL "")
+    include_directories("${LIBCXXABI_LIBUNWIND_INCLUDES}")
   endif()
 endif()
 
+set(LIBCXXABI_LIBUNWIND_INCLUDES "${LIBCXXABI_LIBUNWIND_INCLUDES}" CACHE PATH
+    "Specify path to libunwind includes." FORCE)
+set(LIBCXXABI_LIBUNWIND_PATH "${LIBCXXABI_LIBUNWIND_PATH}" CACHE PATH
+    "Specify path to libunwind source." FORCE)
+
+
 # Add source code. This also contains all of the logic for deciding linker flags
 # soname, etc...
 add_subdirectory(src)
-- 
2.16.1

