@@ -44,20 +44,32 @@ function(FIND_ARROW_LIB LIB_NAME)
4444 endif ()
4545 message (STATUS "Found Arrow library: ${ARROW_LIB_${LIB_NAME} }" )
4646
47- # Get the parent-parent directory of the lib file. For example:
48- #
49- # * ${ARROW_LIB_${LIB_NAME}}: /usr/local/lib/libarrow.a
50- # * ${ARROW_LIB_INCLUDE_DIR}: /usr/local
51- #
52- # Then we can get our include directory: /usr/local/include
53- get_filename_component (ARROW_LIB_INCLUDE_DIR "${ARROW_LIB_${LIB_NAME} }"
54- PATH )
55- get_filename_component (ARROW_LIB_INCLUDE_DIR "${ARROW_LIB_INCLUDE_DIR} "
56- PATH )
47+ # Walk up from the library directory until we find a parent that contains an
48+ # "include/arrow/api.h" anchor file. This handles both conventional layouts
49+ # (/usr/local/lib/libarrow.a → /usr/local/include) and multi-arch ones
50+ # (/usr/lib/x86_64-linux-gnu/libarrow.a → /usr/include) without hard-coding
51+ # the number of directory levels to strip.
52+ get_filename_component (_arrow_search_dir "${ARROW_LIB_${LIB_NAME} }" PATH )
53+ set (ARROW_LIB_INCLUDE_DIR "" )
54+ foreach (_level RANGE 5)
55+ if (EXISTS "${_arrow_search_dir} /include/arrow/api.h" )
56+ set (ARROW_LIB_INCLUDE_DIR "${_arrow_search_dir} /include" )
57+ break ()
58+ endif ()
59+ get_filename_component (_arrow_search_dir "${_arrow_search_dir} " PATH )
60+ endforeach ()
61+ if (NOT ARROW_LIB_INCLUDE_DIR)
62+ message (
63+ FATAL_ERROR
64+ "Could not locate Arrow headers near ${ARROW_LIB_${LIB_NAME} }. "
65+ "Set ARROW_HOME to the Arrow installation prefix (the directory "
66+ "that contains lib/ and include/)." )
67+ endif ()
68+ message (STATUS "Found Arrow include: ${ARROW_LIB_INCLUDE_DIR} " )
5769
5870 set_target_properties (
5971 Arrow::${LIB_NAME}
6072 PROPERTIES IMPORTED_LOCATION ${ARROW_LIB_${LIB_NAME} }
61- INTERFACE_INCLUDE_DIRECTORIES ${ARROW_LIB_INCLUDE_DIR} /include )
73+ INTERFACE_INCLUDE_DIRECTORIES ${ARROW_LIB_INCLUDE_DIR} )
6274 endif ()
6375endfunction ()
0 commit comments