This is an automated email from the ASF dual-hosted git repository.

gangwu pushed a commit to branch branch-2.1
in repository https://gitbox.apache.org/repos/asf/orc.git


The following commit(s) were added to refs/heads/branch-2.1 by this push:
     new 6aea9edfa ORC-1846: [C++] Fix imported libraries in the Conan build
6aea9edfa is described below

commit 6aea9edfae549ca23f8b6265f01bc1a1713833b6
Author: Gang Wu <[email protected]>
AuthorDate: Wed Jan 22 16:25:05 2025 +0800

    ORC-1846: [C++] Fix imported libraries in the Conan build
    
    ### 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 https://github.com/conan-io/conan-center-index/pull/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 09b06501258e281f15c0e0c239a903674713fe78)
    Signed-off-by: Gang Wu <[email protected]>
---
 cmake_modules/ThirdpartyToolchain.cmake | 25 ++++++++++++++++++-------
 1 file changed, 18 insertions(+), 7 deletions(-)

diff --git a/cmake_modules/ThirdpartyToolchain.cmake 
b/cmake_modules/ThirdpartyToolchain.cmake
index fa5a1c0e1..9b2c829c7 100644
--- a/cmake_modules/ThirdpartyToolchain.cmake
+++ b/cmake_modules/ThirdpartyToolchain.cmake
@@ -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")
@@ -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")
@@ -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")
@@ -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)
@@ -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)

Reply via email to