if (NOT "${ORC_HOME}" STREQUAL "")
  file(TO_CMAKE_PATH ${ORC_HOME} _orc_path)
endif()

message (STATUS "ORC_HOME:  ${ORC_HOME}")

find_path (ORC_INCLUDE_DIR_INNER
  NAMES ColumnPrinter.hh Int128.hh orc-config.hh OrcFile.hh Reader.hh Type.hh Vector.hh
  HINTS ${_orc_path}
  NO_DEFAULT_PATH
  PATH_SUFFIXES "include" "orc")

find_library(ORC_L0 NAMES ${CMAKE_STATIC_LIBRARY_PREFIX}protobuf${CMAKE_STATIC_LIBRARY_SUFFIX} HINTS ${_orc_path} PATH_SUFFIXES "lib" NO_DEFAULT_PATH NO_SYSTEM_ENVIRONMENT_PATH) 
find_library(ORC_L1 NAMES ${CMAKE_STATIC_LIBRARY_PREFIX}z${CMAKE_STATIC_LIBRARY_SUFFIX} HINTS ${_orc_path} PATH_SUFFIXES "lib" NO_DEFAULT_PATH NO_SYSTEM_ENVIRONMENT_PATH)
find_library(ORC_L2 NAMES ${CMAKE_STATIC_LIBRARY_PREFIX}lz4${CMAKE_STATIC_LIBRARY_SUFFIX} HINTS ${_orc_path} PATH_SUFFIXES "lib" NO_DEFAULT_PATH NO_SYSTEM_ENVIRONMENT_PATH)
find_library(ORC_L3 NAMES ${CMAKE_STATIC_LIBRARY_PREFIX}snappy${CMAKE_STATIC_LIBRARY_SUFFIX} HINTS ${_orc_path} PATH_SUFFIXES "lib" NO_DEFAULT_PATH NO_SYSTEM_ENVIRONMENT_PATH)
find_library(ORC_L4 NAMES ${CMAKE_STATIC_LIBRARY_PREFIX}orc${CMAKE_STATIC_LIBRARY_SUFFIX} HINTS ${_orc_path} PATH_SUFFIXES "lib" NO_DEFAULT_PATH NO_SYSTEM_ENVIRONMENT_PATH)

if (ORC_INCLUDE_DIR_INNER AND ORC_L0 AND ORC_L0 AND ORC_L2 AND ORC_L3 AND ORC_L4)
  get_filename_component(ORC_INCLUDE_DIR ${ORC_INCLUDE_DIR_INNER} DIRECTORY)
  set(ORC_FOUND true)
endif()

if(ORC_FOUND)
  message (STATUS "Found ORC:")
  message (STATUS "  (Headers)       ${ORC_INCLUDE_DIR}")
  message (STATUS "  (Library)       ${ORC_L0}")
  message (STATUS "  (Library)       ${ORC_L1}")
  message (STATUS "  (Library)       ${ORC_L2}")
  message (STATUS "  (Library)       ${ORC_L3}")
  message (STATUS "  (Library)       ${ORC_L4}")
endif()
