Skip to content

Commit

Permalink
GH-15139: [C++] Improve bzip2 static library path detection for arrow…
Browse files Browse the repository at this point in the history
….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 <[email protected]>
Signed-off-by: Sutou Kouhei <[email protected]>
  • Loading branch information
kou authored Jan 18, 2023
1 parent e837f73 commit 359f28b
Showing 1 changed file with 25 additions and 3 deletions.
28 changes: 25 additions & 3 deletions cpp/cmake_modules/ThirdpartyToolchain.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 359f28b

Please sign in to comment.