Skip to content

Provide correct BZip2 information for in-project build #227

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ if(QUAZIP_BZIP2)
list(APPEND QUAZIP_LBD ${BZIP2_LIBRARY_DIRS})

set(PC_PRIVATE_LIBS "${PC_PRIVATE_LIBS} -lbzip2")

set(QUAZIP_BZIP2_BUILD FALSE)
elseif(QUAZIP_FETCH_LIBS)
clone_repo(bzip2 https://sourceware.org/git/bzip2.git)

Expand All @@ -193,13 +195,23 @@ if(QUAZIP_BZIP2)

add_library(bzip2 STATIC ${BZIP2_SRC} ${BZIP2_HDR})

set_target_properties(bzip2 PROPERTIES
PUBLIC_HEADER "${BZIP2_SOURCE_DIR}/bzlib.h"
)
target_include_directories(bzip2 PUBLIC
$<BUILD_INTERFACE:${BZIP2_SOURCE_DIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)

if(NOT QUAZIP_BZIP2_STDIO)
target_compile_definitions(bzip2 PRIVATE -DBZ_NO_STDIO)
endif()

list(APPEND QUAZIP_DEP bzip2)
list(APPEND QUAZIP_LIB bzip2)
list(APPEND QUAZIP_INC ${BZIP2_SOURCE_DIR})

set(QUAZIP_BZIP2_BUILD ON)
else()
message(STATUS "BZip2 library not found")

Expand Down
2 changes: 1 addition & 1 deletion quazip/QuaZipConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ else()
message(FATAL_ERROR "Qt version QUAZIP_QT_MAJOR_VERSION=@QUAZIP_QT_MAJOR_VERSION@ is unsupported")
endif()

if(@QUAZIP_BZIP2@)
if(@QUAZIP_BZIP2@ AND NOT @QUAZIP_BZIP2_BUILD@)
find_dependency(BZip2 REQUIRED)
endif()

Expand Down