Fix "TODO" and provide the configure-time options to find libunwind.
This is done the same way as we're looking for libc++


git-svn-id: https://llvm.org/svn/llvm-project/libcxxabi/trunk@236874 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0ffd300..0abdd8b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -299,13 +299,38 @@
 # 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)
-  include_directories(${LLVM_MAIN_SRC_DIR}/projects/libunwind/include)
-  # TODO: libunwind does not place libunwind_ext.h into include, so we need to
-  # reach into its source directory.  This is primarily for
-  # _Unwind_VRS_Interpret, which is part of ARM EHABI, and should be in unwind.h
-  include_directories(${LLVM_MAIN_SRC_DIR}/projects/libunwind/src)
+  find_path(
+    LIBCXXABI_LIBUNWIND_INCLUDES
+    libunwind.h
+    PATHS ${LIBCXXABI_LIBUNWIND_INCLUDES}
+          ${LIBCXXABI_LIBUNWIND_PATH}/include
+          ${CMAKE_BINARY_DIR}/${LIBCXXABI_LIBUNWIND_INCLUDES}
+          ${LLVM_MAIN_SRC_DIR}/projects/libunwind/include
+  )
+
+  find_path(
+    LIBCXXABI_LIBUNWIND_SOURCES
+    libunwind_ext.h
+    PATHS ${LIBCXXABI_LIBUNWIND_PATH}/src/
+          ${LIBCXXABI_LIBUNWIND_INCLUDES}/../src/
+          ${LLVM_MAIN_SRC_DIR}/projects/libunwind/src/
+    NO_DEFAULT_PATH
+  )
+
+  if (LIBCXXABI_LIBUNWIND_SOURCES STREQUAL "LIBCXXABI_LIBUNWIND_PATH-NOTFOUND")
+    message(WARNING "LIBCXXABI_LIBCXX_PATH was not specified and couldn't be infered.")
+    set(LIBCXXABI_LIBUNWIND_PATH "")
+  endif()
+
+  include_directories("${LIBCXXABI_LIBUNWIND_INCLUDES}")
+  include_directories("${LIBCXXABI_LIBUNWIND_SOURCES}")
 endif ()
 
 # Add source code. This also contains all of the logic for deciding linker flags