2017-07-21 22:00:32 -07:00
|
|
|
cmake_minimum_required(VERSION 3.8)
|
2017-07-23 10:57:20 -07:00
|
|
|
project(minizip C)
|
2017-07-21 22:00:32 -07:00
|
|
|
|
2019-11-26 07:54:49 +08:00
|
|
|
set(PROJECT_VERSION 1.2.11)
|
|
|
|
set(PROJECT_VERSION_MAJOR 1)
|
|
|
|
set(PROJECT_VERSION_MINOR 2)
|
|
|
|
set(PROJECT_VERSION_PATCH 11)
|
|
|
|
|
2017-07-21 22:00:32 -07:00
|
|
|
if(MSVC)
|
|
|
|
add_compile_options(/W3 /wd4005 /wd4996 /wd4018 -D_CRT_SECURE_NO_WARNINGS)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
find_package(ZLIB REQUIRED)
|
2019-07-18 19:26:48 +02:00
|
|
|
set(MIN_SRC contrib/minizip)
|
2017-07-21 22:00:32 -07:00
|
|
|
|
2019-07-18 19:26:48 +02:00
|
|
|
include_directories(${MIN_SRC} ${ZLIB_INCLUDE_DIRS})
|
2017-07-21 22:00:32 -07:00
|
|
|
|
2019-07-18 19:26:48 +02:00
|
|
|
set(MINIZIP_LIBRARIES ZLIB::ZLIB)
|
|
|
|
if(ENABLE_BZIP2)
|
|
|
|
message(STATUS "Building with bzip2 support")
|
|
|
|
find_package(BZip2)
|
2017-07-21 22:00:32 -07:00
|
|
|
|
2019-07-18 19:26:48 +02:00
|
|
|
include_directories(${BZIP2_INCLUDE_DIR})
|
|
|
|
set(MINIZIP_LIBRARIES ${MINIZIP_LIBRARIES} ${BZIP2_LIBRARIES})
|
|
|
|
else()
|
|
|
|
message(STATUS "Building without bzip2 support")
|
|
|
|
endif()
|
2017-07-21 22:00:32 -07:00
|
|
|
|
|
|
|
set(SRC
|
|
|
|
${MIN_SRC}/ioapi.c
|
|
|
|
${MIN_SRC}/unzip.c
|
|
|
|
${MIN_SRC}/zip.c
|
2017-07-23 10:57:20 -07:00
|
|
|
${MIN_SRC}/mztools.c
|
2017-07-21 22:00:32 -07:00
|
|
|
)
|
2018-11-22 22:56:06 +01:00
|
|
|
if(WIN32)
|
|
|
|
list(APPEND SRC ${MIN_SRC}/iowin32.c)
|
|
|
|
endif()
|
|
|
|
|
2017-07-21 22:00:32 -07:00
|
|
|
set(HEADERS
|
2017-07-25 16:50:25 -07:00
|
|
|
${MIN_SRC}/crypt.h
|
2017-07-21 22:00:32 -07:00
|
|
|
${MIN_SRC}/ioapi.h
|
|
|
|
${MIN_SRC}/unzip.h
|
|
|
|
${MIN_SRC}/zip.h
|
2017-07-23 10:57:20 -07:00
|
|
|
${MIN_SRC}/mztools.h
|
2017-07-21 22:00:32 -07:00
|
|
|
)
|
2018-11-22 22:56:06 +01:00
|
|
|
if(WIN32)
|
|
|
|
list(APPEND HEADERS ${MIN_SRC}/iowin32.h)
|
|
|
|
endif()
|
|
|
|
|
2017-07-21 22:00:32 -07:00
|
|
|
add_library(minizip ${SRC})
|
|
|
|
|
|
|
|
target_link_libraries(minizip PRIVATE ZLIB::ZLIB)
|
|
|
|
target_compile_definitions(minizip PRIVATE -D_ZLIB_H)
|
|
|
|
|
2019-07-18 19:26:48 +02:00
|
|
|
if(ENABLE_BZIP2)
|
2021-06-17 05:39:53 +08:00
|
|
|
target_link_libraries(minizip PUBLIC ${BZIP2_LIBRARIES})
|
2019-07-18 19:26:48 +02:00
|
|
|
target_compile_definitions(minizip PRIVATE -DHAVE_BZIP2=1)
|
|
|
|
endif()
|
2021-04-20 09:12:16 +09:00
|
|
|
if(ANDROID)
|
|
|
|
target_compile_definitions(minizip PRIVATE IOAPI_NO_64)
|
|
|
|
endif()
|
|
|
|
if(NOT DISABLE_INSTALL_TOOLS)
|
|
|
|
add_executable(minizip_bin ${MIN_SRC}/minizip.c)
|
|
|
|
add_executable(miniunz_bin ${MIN_SRC}/miniunz.c)
|
2017-07-21 22:00:32 -07:00
|
|
|
|
2021-04-20 09:12:16 +09:00
|
|
|
target_link_libraries(minizip_bin minizip ${MINIZIP_LIBRARIES})
|
|
|
|
target_link_libraries(miniunz_bin minizip ${MINIZIP_LIBRARIES})
|
2017-07-23 11:46:49 -07:00
|
|
|
|
2021-04-20 09:12:16 +09:00
|
|
|
set_target_properties(minizip_bin PROPERTIES OUTPUT_NAME minizip)
|
|
|
|
set_target_properties(miniunz_bin PROPERTIES OUTPUT_NAME miniunz)
|
|
|
|
endif()
|
2017-07-23 11:46:49 -07:00
|
|
|
|
2017-07-21 22:00:32 -07:00
|
|
|
install(
|
|
|
|
TARGETS minizip
|
2019-11-26 07:54:49 +08:00
|
|
|
EXPORT minizipTargets
|
2017-07-21 22:00:32 -07:00
|
|
|
RUNTIME DESTINATION bin
|
|
|
|
LIBRARY DESTINATION lib
|
|
|
|
ARCHIVE DESTINATION lib
|
|
|
|
)
|
|
|
|
|
2019-11-26 07:54:49 +08:00
|
|
|
include(CMakePackageConfigHelpers)
|
|
|
|
write_basic_package_version_file("${PROJECT_BINARY_DIR}/minizipConfigVersion.cmake"
|
|
|
|
COMPATIBILITY SameMajorVersion)
|
|
|
|
|
|
|
|
configure_package_config_file(${PROJECT_SOURCE_DIR}/cmake/minizipConfig.cmake.in
|
|
|
|
minizipConfig.cmake
|
|
|
|
INSTALL_DESTINATION share/minizip)
|
|
|
|
|
|
|
|
install(FILES
|
|
|
|
"${PROJECT_BINARY_DIR}/minizipConfig.cmake"
|
|
|
|
"${PROJECT_BINARY_DIR}/minizipConfigVersion.cmake"
|
|
|
|
DESTINATION share/minizip
|
|
|
|
)
|
|
|
|
|
|
|
|
install(EXPORT minizipTargets
|
|
|
|
NAMESPACE minizip::
|
|
|
|
DESTINATION share/minizip
|
|
|
|
)
|
|
|
|
|
2017-07-23 11:46:49 -07:00
|
|
|
if(NOT DISABLE_INSTALL_TOOLS)
|
|
|
|
install (
|
|
|
|
TARGETS minizip_bin miniunz_bin
|
|
|
|
RUNTIME DESTINATION tools/minizip
|
|
|
|
)
|
|
|
|
endif()
|
2017-07-21 22:00:32 -07:00
|
|
|
|
|
|
|
if(NOT DISABLE_INSTALL_HEADERS)
|
|
|
|
install(FILES ${HEADERS} DESTINATION include/minizip)
|
|
|
|
endif()
|