Skip to content

Commit

Permalink
ARROW-17367: [C++] Fix the LZ4's CMake target name (apache#13831)
Browse files Browse the repository at this point in the history
I changed the LZ4's CMake target name to lz4::lz4 from LZ4::lz4 by
ARROW-16614 because I thought that the official LZ4's CMake package
uses lz4::lz4 not LZ4::lz4.

But I was wrong. The official LZ4's CMake package uses LZ4::lz4 not
lz4::lz4:
lz4/lz4@f937813

Authored-by: Sutou Kouhei <kou@clear-code.com>
Signed-off-by: Sutou Kouhei <kou@clear-code.com>
  • Loading branch information
kou authored and ksuarez1423 committed Aug 15, 2022
1 parent e64dd2d commit 21aa422
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 12 deletions.
4 changes: 2 additions & 2 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -753,9 +753,9 @@ if(ARROW_WITH_BZ2)
endif()

if(ARROW_WITH_LZ4)
list(APPEND ARROW_STATIC_LINK_LIBS lz4::lz4)
list(APPEND ARROW_STATIC_LINK_LIBS LZ4::lz4)
if(lz4_SOURCE STREQUAL "SYSTEM")
list(APPEND ARROW_STATIC_INSTALL_INTERFACE_LIBS lz4::lz4)
list(APPEND ARROW_STATIC_INSTALL_INTERFACE_LIBS LZ4::lz4)
endif()
endif()

Expand Down
10 changes: 7 additions & 3 deletions cpp/cmake_modules/Findlz4Alt.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ endif()
find_package(lz4 ${find_package_args})
if(lz4_FOUND)
set(lz4Alt_FOUND TRUE)
# Conan uses lz4::lz4 not LZ4::lz4
if(NOT TARGET LZ4::lz4 AND TARGET lz4::lz4)
add_library(LZ4::lz4 ALIAS lz4::lz4)
endif()
return()
endif()

Expand Down Expand Up @@ -89,9 +93,9 @@ endif()
find_package_handle_standard_args(lz4Alt REQUIRED_VARS LZ4_LIB LZ4_INCLUDE_DIR)

if(lz4Alt_FOUND)
if(NOT TARGET lz4::lz4)
add_library(lz4::lz4 UNKNOWN IMPORTED)
set_target_properties(lz4::lz4
if(NOT TARGET LZ4::lz4)
add_library(LZ4::lz4 UNKNOWN IMPORTED)
set_target_properties(LZ4::lz4
PROPERTIES IMPORTED_LOCATION "${LZ4_LIB}"
INTERFACE_INCLUDE_DIRECTORIES "${LZ4_INCLUDE_DIR}")
endif()
Expand Down
12 changes: 6 additions & 6 deletions cpp/cmake_modules/ThirdpartyToolchain.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2336,14 +2336,14 @@ macro(build_lz4)
BUILD_BYPRODUCTS ${LZ4_STATIC_LIB})

file(MAKE_DIRECTORY "${LZ4_PREFIX}/include")
add_library(lz4::lz4 STATIC IMPORTED)
set_target_properties(lz4::lz4
add_library(LZ4::lz4 STATIC IMPORTED)
set_target_properties(LZ4::lz4
PROPERTIES IMPORTED_LOCATION "${LZ4_STATIC_LIB}"
INTERFACE_INCLUDE_DIRECTORIES "${LZ4_PREFIX}/include")
add_dependencies(toolchain lz4_ep)
add_dependencies(lz4::lz4 lz4_ep)
add_dependencies(LZ4::lz4 lz4_ep)

list(APPEND ARROW_BUNDLED_STATIC_LIBS lz4::lz4)
list(APPEND ARROW_BUNDLED_STATIC_LIBS LZ4::lz4)
endmacro()

if(ARROW_WITH_LZ4)
Expand Down Expand Up @@ -4278,7 +4278,7 @@ macro(build_orc)
INTERFACE_INCLUDE_DIRECTORIES)
get_filename_component(ORC_SNAPPY_ROOT "${ORC_SNAPPY_INCLUDE_DIR}" DIRECTORY)

get_target_property(ORC_LZ4_ROOT lz4::lz4 INTERFACE_INCLUDE_DIRECTORIES)
get_target_property(ORC_LZ4_ROOT LZ4::lz4 INTERFACE_INCLUDE_DIRECTORIES)
get_filename_component(ORC_LZ4_ROOT "${ORC_LZ4_ROOT}" DIRECTORY)

# Weirdly passing in PROTOBUF_LIBRARY for PROTOC_LIBRARY still results in ORC finding
Expand Down Expand Up @@ -4322,7 +4322,7 @@ macro(build_orc)

set(ORC_VENDORED 1)
add_dependencies(orc_ep ZLIB::ZLIB)
add_dependencies(orc_ep lz4::lz4)
add_dependencies(orc_ep LZ4::lz4)
add_dependencies(orc_ep ${Snappy_TARGET})
add_dependencies(orc_ep ${ARROW_PROTOBUF_LIBPROTOBUF})

Expand Down
2 changes: 1 addition & 1 deletion cpp/src/arrow/adapters/orc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ set(ORC_MIN_TEST_LIBS
GTest::gtest_main
GTest::gtest
${Snappy_TARGET}
lz4::lz4
LZ4::lz4
ZLIB::ZLIB)

if(ARROW_BUILD_STATIC)
Expand Down

0 comments on commit 21aa422

Please sign in to comment.