Skip to content

Commit

Permalink
Add support for third-party library directories for libzstd on macOS. #…
Browse files Browse the repository at this point in the history
  • Loading branch information
nmoinvaz committed Oct 25, 2020
1 parent abc1c2d commit b7e682f
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ set(STDLIB_DEF)
set(MINIZIP_DEF)
set(MINIZIP_INC)
set(MINIZIP_LIB)
set(MINIZIP_LBD)
set(MINIZIP_DEP)
set(MINIZIP_LFG)

Expand Down Expand Up @@ -131,10 +132,11 @@ if(MZ_ZLIB)
find_package(ZLIB QUIET)
endif()
if(ZLIB_FOUND AND NOT ZLIB_FORCE_FETCH)
message(STATUS "Using ZLIB ${ZLIB_VERSION_STRING}")
message(STATUS "Using ZLIB ${ZLIB_VERSION}")

list(APPEND MINIZIP_INC ${ZLIB_INCLUDE_DIRS})
list(APPEND MINIZIP_LIB ${ZLIB_LIBRARIES})
list(APPEND MINIZIP_LBD ${ZLIB_LIBRARY_DIRS})

set(PC_PRIVATE_LIBS " -lz")
else()
Expand Down Expand Up @@ -201,10 +203,11 @@ if(MZ_ZSTD)
endif()

if(ZSTD_FOUND AND NOT ZSTD_FORCE_FETCH)
message(STATUS "Using ZSTD ${ZSTD_VERSION_STRING}")
message(STATUS "Using ZSTD ${ZSTD_VERSION}")

list(APPEND MINIZIP_INC ${ZSTD_INCLUDE_DIRS})
list(APPEND MINIZIP_LIB ${ZSTD_LIBRARIES})
list(APPEND MINIZIP_LBD ${ZSTD_LIBRARY_DIRS})

set(PC_PRIVATE_LIBS "${PC_PRIVATE_LIBS} -lzstd")
else()
Expand Down Expand Up @@ -254,10 +257,11 @@ if(MZ_BZIP2)
# Check if bzip2 is present
find_package(BZip2)
if(BZIP2_FOUND)
message(STATUS "Using BZIP2 ${BZIP2_VERSION_STRING}")
message(STATUS "Using BZIP2 ${BZIP2_VERSION}")

list(APPEND MINIZIP_INC ${BZIP2_INCLUDE_DIRS})
list(APPEND MINIZIP_LIB ${BZIP2_LIBRARIES})
list(APPEND MINIZIP_LBD ${BZIP2_LIBRARY_DIRS})

set(PC_PRIVATE_LIBS "${PC_PRIVATE_LIBS} -lbzip2")
else()
Expand Down Expand Up @@ -295,7 +299,7 @@ if(MZ_LZMA)
endif()

if(LZMA_FOUND)
message(STATUS "Using LZMA ${LZMA_VERSION_STRING}")
message(STATUS "Using LZMA ${LZMA_VERSION}")

list(APPEND MINIZIP_INC ${LZMA_INCLUDE_DIRS})
list(APPEND MINIZIP_LIB ${LZMA_LIBRARIES})
Expand Down Expand Up @@ -458,7 +462,9 @@ if(MZ_OPENSSL)

list(APPEND MINIZIP_SRC mz_crypt_openssl.c)
list(APPEND MINIZIP_LIB ${OPENSSL_LIBRARIES})
list(APPEND MINIZIP_LBD ${OPENSSL_LIBRARY_DIRS})
list(APPEND MINIZIP_INC ${OPENSSL_INCLUDE_DIR})

if(OPENSSL_INCLUDE_DIRS)
list(APPEND MINIZIP_INC ${OPENSSL_INCLUDE_DIRS})
endif()
Expand Down Expand Up @@ -542,6 +548,7 @@ if(UNIX)
list(APPEND MINIZIP_DEF -DHAVE_LIBBSD -DHAVE_ARC4RANDOM_BUF)
list(APPEND MINIZIP_INC ${LIBBSD_INCLUDE_DIRS})
list(APPEND MINIZIP_LIB ${LIBBSD_LIBRARIES})
list(APPEND MINIZIP_LBD ${LIBBSD_LIBRARY_DIRS})

link_directories(${LIBBSD_LIBRARY_DIRS})
endif()
Expand All @@ -563,6 +570,7 @@ if(UNIX)
list(APPEND MINIZIP_INC ${Iconv_INCLUDE_DIRS})
if(NOT Iconv_IS_BUILT_IN)
list(APPEND MINIZIP_LIB ${Iconv_LIBRARIES})
list(APPEND MINIZIP_LBD ${Iconv_LIBRARY_DIRS})
endif()

set(PC_PRIVATE_LIBS "${PC_PRIVATE_LIBS} -liconv")
Expand Down Expand Up @@ -738,6 +746,7 @@ if(MZ_LZMA)
endif()

target_link_libraries(${PROJECT_NAME} PRIVATE ${MINIZIP_LIB} ${MINIZIP_DEP})
target_link_directories(${PROJECT_NAME} PUBLIC ${MINIZIP_LBD})
target_compile_definitions(${PROJECT_NAME} PRIVATE ${STDLIB_DEF} ${MINIZIP_DEF})
target_include_directories(${PROJECT_NAME} PRIVATE ${MINIZIP_INC})
target_include_directories(${PROJECT_NAME} PUBLIC
Expand Down

0 comments on commit b7e682f

Please sign in to comment.