You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by ko...@apache.org on 2023/01/18 14:21:56 UTC

[arrow] branch master updated: GH-15139: [C++] Improve bzip2 static library path detection for arrow.pc (#33712)

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

kou pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow.git


The following commit(s) were added to refs/heads/master by this push:
     new 359f28ba9d GH-15139: [C++] Improve bzip2 static library path detection for arrow.pc (#33712)
359f28ba9d is described below

commit 359f28ba9d62a5e8456d92dfbe5b16b790019edd
Author: Sutou Kouhei <ko...@clear-code.com>
AuthorDate: Wed Jan 18 23:21:49 2023 +0900

    GH-15139: [C++] Improve bzip2 static library path detection for arrow.pc (#33712)
    
    ### Rationale for this change
    
    If bzip2 is installed for debug build and release build on Windows, find_package(BZip2)
    returns both static library paths of them.
    
    ### What changes are included in this PR?
    
    We should use one of detected library paths in arrow.pc.
    
    The bzip2's official build system doesn't provide bzip2.pc but vcpkg provides bzip2.pc. We can use it instead of detecting bzip2's static library path by ourselves.
    
    ### Are these changes tested?
    
    Yes. We test these changes in #15139 manually.
    
    ### Are there any user-facing changes?
    
    No.
    * Closes: #15139
    
    Authored-by: Sutou Kouhei <ko...@clear-code.com>
    Signed-off-by: Sutou Kouhei <ko...@clear-code.com>
---
 cpp/cmake_modules/ThirdpartyToolchain.cmake | 28 +++++++++++++++++++++++++---
 1 file changed, 25 insertions(+), 3 deletions(-)

diff --git a/cpp/cmake_modules/ThirdpartyToolchain.cmake b/cpp/cmake_modules/ThirdpartyToolchain.cmake
index 3eda538fb2..39044f956a 100644
--- a/cpp/cmake_modules/ThirdpartyToolchain.cmake
+++ b/cpp/cmake_modules/ThirdpartyToolchain.cmake
@@ -2569,9 +2569,31 @@ macro(build_bzip2)
 endmacro()
 
 if(ARROW_WITH_BZ2)
-  resolve_dependency(BZip2)
-  if(${BZip2_SOURCE} STREQUAL "SYSTEM")
-    string(APPEND ARROW_PC_LIBS_PRIVATE " ${BZIP2_LIBRARIES}")
+  resolve_dependency(BZip2 PC_PACKAGE_NAMES bzip2)
+  if(${BZip2_SOURCE} STREQUAL "SYSTEM" AND NOT bzip2_PC_FOUND)
+    set(ARROW_BZIP2_CONFIGS "")
+    if(BZIP2_LIBRARY_RELEASE)
+      string(APPEND ARROW_PC_LIBS_PRIVATE
+             " $<$<CONFIG:RELEASE>:${BZIP2_LIBRARY_RELEASE}>")
+      list(APPEND ARROW_BZIP2_CONFIGS "$<CONFIG:RELEASE>")
+    endif()
+    if(BZIP2_LIBRARY_DEBUG)
+      string(APPEND ARROW_PC_LIBS_PRIVATE " $<$<CONFIG:DEBUG>:${BZIP2_LIBRARY_DEBUG}>")
+      list(APPEND ARROW_BZIP2_CONFIGS "$<CONFIG:DEBUG>")
+    endif()
+    string(APPEND ARROW_PC_LIBS_PRIVATE " $<$<NOT:$<OR:")
+    if(CMAKE_VERSION VERSION_LESS "3.12")
+      string(REPLACE ";" "," ARROW_BZIP2_CONFIGS_CSV "${ARROW_BZIP2_CONFIGS}")
+    else()
+      list(JOIN ARROW_BZIP2_CONFIGS "," ARROW_BZIP2_CONFIGS_CSV)
+    endif()
+    string(APPEND ARROW_PC_LIBS_PRIVATE "${ARROW_BZIP2_CONFIGS_CSV}>>:")
+    if(BZIP2_LIBRARY)
+      string(APPEND ARROW_PC_LIBS_PRIVATE "${BZIP2_LIBRARY}")
+    else()
+      string(APPEND ARROW_PC_LIBS_PRIVATE "${BZIP2_LIBRARIES}")
+    endif()
+    string(APPEND ARROW_PC_LIBS_PRIVATE ">")
   endif()
 
   if(NOT TARGET BZip2::BZip2)