Skip to content

Commit

Permalink
ORC-1846: [C++] Fix imported libraries in the Conan build
Browse files Browse the repository at this point in the history
### What changes were proposed in this pull request?

Fix all imported libraries of thirdparty dependencies to build in Conan.

### Why are the changes needed?

Upgrading the C++ ORC 2.1.0 in Conan will fail due to the CMake refactoring. See conan-io/conan-center-index#26426

### How was this patch tested?

See CIs from Conan: https://github.com/conan-io/conan-center-index/pull/26426/checks?check_run_id=35916226382

### Was this patch authored or co-authored using generative AI tooling?

No.

Closes #2121 from wgtmac/fix_conan.

Authored-by: Gang Wu <[email protected]>
Signed-off-by: Gang Wu <[email protected]>
(cherry picked from commit 09b0650)
Signed-off-by: Gang Wu <[email protected]>
  • Loading branch information
wgtmac committed Jan 22, 2025
1 parent 3f6d5de commit 6aea9ed
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions cmake_modules/ThirdpartyToolchain.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,8 @@ ExternalProject_Add (orc-format_ep
# Snappy
if (ORC_PACKAGE_KIND STREQUAL "conan")
find_package (Snappy REQUIRED CONFIG)
orc_add_resolved_library (orc_snappy ${Snappy_LIBRARIES} ${Snappy_INCLUDE_DIR})
add_library (orc_snappy INTERFACE)
target_link_libraries(orc_snappy INTERFACE Snappy::snappy)
list (APPEND ORC_SYSTEM_DEPENDENCIES Snappy)
list (APPEND ORC_INSTALL_INTERFACE_TARGETS "$<INSTALL_INTERFACE:Snappy::snappy>")
elseif (ORC_PACKAGE_KIND STREQUAL "vcpkg")
Expand Down Expand Up @@ -207,7 +208,8 @@ add_library (orc::snappy ALIAS orc_snappy)

if (ORC_PACKAGE_KIND STREQUAL "conan")
find_package (ZLIB REQUIRED CONFIG)
orc_add_resolved_library (orc_zlib ${ZLIB_LIBRARIES} ${ZLIB_INCLUDE_DIR})
add_library (orc_zlib INTERFACE)
target_link_libraries(orc_zlib INTERFACE ZLIB::ZLIB)
list (APPEND ORC_SYSTEM_DEPENDENCIES ZLIB)
list (APPEND ORC_INSTALL_INTERFACE_TARGETS "$<INSTALL_INTERFACE:ZLIB::ZLIB>")
elseif (ORC_PACKAGE_KIND STREQUAL "vcpkg")
Expand Down Expand Up @@ -265,7 +267,11 @@ add_library (orc::zlib ALIAS orc_zlib)

if (ORC_PACKAGE_KIND STREQUAL "conan")
find_package (ZSTD REQUIRED CONFIG)
orc_add_resolved_library (orc_zstd ${zstd_LIBRARIES} ${zstd_INCLUDE_DIR})
add_library (orc_zstd INTERFACE)
target_link_libraries (orc_zstd INTERFACE
$<TARGET_NAME_IF_EXISTS:zstd::libzstd_static>
$<TARGET_NAME_IF_EXISTS:zstd::libzstd_shared>
)
list (APPEND ORC_SYSTEM_DEPENDENCIES ZSTD)
list (APPEND ORC_INSTALL_INTERFACE_TARGETS "$<INSTALL_INTERFACE:$<IF:$<TARGET_EXISTS:zstd::libzstd_shared>,zstd::libzstd_shared,zstd::libzstd_static>>")
elseif (ORC_PACKAGE_KIND STREQUAL "vcpkg")
Expand Down Expand Up @@ -330,9 +336,13 @@ add_library (orc::zstd ALIAS orc_zstd)
# LZ4
if (ORC_PACKAGE_KIND STREQUAL "conan")
find_package (LZ4 REQUIRED CONFIG)
orc_add_resolved_library (orc_lz4 ${lz4_LIBRARIES} ${lz4_INCLUDE_DIR})
add_library (orc_lz4 INTERFACE)
target_link_libraries (orc_lz4 INTERFACE
$<TARGET_NAME_IF_EXISTS:LZ4::lz4_shared>
$<TARGET_NAME_IF_EXISTS:LZ4::lz4_static>
)
list (APPEND ORC_SYSTEM_DEPENDENCIES LZ4)
list (APPEND ORC_INSTALL_INTERFACE_TARGETS "$<INSTALL_INTERFACE:LZ4::lz4>")
list (APPEND ORC_INSTALL_INTERFACE_TARGETS "$<INSTALL_INTERFACE:$<IF:$<TARGET_EXISTS:LZ4::lz4_shared>,LZ4::lz4_shared,LZ4::lz4_static>>")
elseif (ORC_PACKAGE_KIND STREQUAL "vcpkg")
find_package(lz4 CONFIG REQUIRED)
add_library (orc_lz4 INTERFACE IMPORTED)
Expand Down Expand Up @@ -491,9 +501,10 @@ endif ()

if (ORC_PACKAGE_KIND STREQUAL "conan")
find_package (Protobuf REQUIRED CONFIG)
orc_add_resolved_library (orc_protobuf ${protobuf_LIBRARIES} ${protobuf_INCLUDE_DIR})
add_library (orc_protobuf INTERFACE)
target_link_libraries(orc_protobuf INTERFACE protobuf::protobuf)
list (APPEND ORC_SYSTEM_DEPENDENCIES Protobuf)
list (APPEND ORC_INSTALL_INTERFACE_TARGETS "$<INSTALL_INTERFACE:protobuf::libprotobuf>")
list (APPEND ORC_INSTALL_INTERFACE_TARGETS "$<INSTALL_INTERFACE:protobuf::protobuf>")
elseif (ORC_PACKAGE_KIND STREQUAL "vcpkg")
find_package(Protobuf CONFIG REQUIRED)
add_library (orc_protobuf INTERFACE IMPORTED)
Expand Down

0 comments on commit 6aea9ed

Please sign in to comment.