Skip to content

Commit

Permalink
Rework the way zlib and QuaZip are used via CMake. Use Quazip via Fet…
Browse files Browse the repository at this point in the history
…chContent.
  • Loading branch information
przemek83 committed Dec 11, 2024
1 parent b56c70a commit 2a8160e
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 29 deletions.
25 changes: 12 additions & 13 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,18 @@ qt_standard_project_setup()
include(GNUInstallDirs)
include(CMakePackageConfigHelpers)

set(THIRD_PARTY_LIBS zlib quazip)
foreach(library ${THIRD_PARTY_LIBS})
configure_file(CMakeLists.txt.${library} ${library}/CMakeLists.txt)
execute_process(COMMAND ${CMAKE_COMMAND} -G ${CMAKE_GENERATOR} .
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/${library})
execute_process(COMMAND ${CMAKE_COMMAND} --build .
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/${library} )
endforeach(library)

set(ZLIB_ROOT ${CMAKE_BINARY_DIR}/zlib/install)
configure_file(CMakeLists.txt.zlib zlib/CMakeLists.txt)
execute_process(COMMAND ${CMAKE_COMMAND} -G ${CMAKE_GENERATOR} .
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/zlib)
execute_process(COMMAND ${CMAKE_COMMAND} --build .
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/zlib )

set(ZLIB_ROOT ${CMAKE_CURRENT_BINARY_DIR}/zlib/install)
find_package(ZLIB REQUIRED)
list(APPEND CMAKE_PREFIX_PATH "${CMAKE_BINARY_DIR}/quazip/install/")
find_package(QuaZip-Qt6 CONFIG REQUIRED)
include_directories( ${CMAKE_CURRENT_BINARY_DIR}/zlib/install/include)

include(CMakeLists.txt.quazip)
include_directories(${CMAKE_CURRENT_BINARY_DIR}/_deps/quazip-src)

set(${PROJECT_NAME}_SOURCES
src/EibleUtilities.h
Expand Down Expand Up @@ -88,7 +87,7 @@ install(TARGETS ${PROJECT_NAME}
install(FILES ${CMAKE_BINARY_DIR}/${PROJECT_NAME}.pc
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/pkgconfig)

target_link_libraries(${PROJECT_NAME} PRIVATE Qt6::Core Qt6::Widgets Qt6::Xml Qt6::Core5Compat QuaZip::QuaZip)
target_link_libraries(${PROJECT_NAME} PRIVATE Qt6::Core Qt6::Widgets Qt6::Xml Qt6::Core5Compat QuaZip)

if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
add_subdirectory(examples)
Expand Down
17 changes: 5 additions & 12 deletions CMakeLists.txt.quazip
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
cmake_minimum_required(VERSION 3.16)
include(FetchContent)

include(ExternalProject)

project(quazip NONE)

ExternalProject_Add(quazip
PREFIX quazip
FetchContent_Declare(
QuaZip
GIT_REPOSITORY https://github.com/stachenov/quazip.git
GIT_TAG 9d3aa3ee948c1cde5a9f873ecbc3bb229c1182ee
CMAKE_ARGS -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/quazip/install
-DQUAZIP_QT_MAJOR_VERSION=6
-DZLIB_ROOT=${CMAKE_BINARY_DIR}/zlib/install
-DQUAZIP_BZIP2=OFF
)

FetchContent_MakeAvailable(QuaZip)
4 changes: 2 additions & 2 deletions CMakeLists.txt.zlib
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ project(zlib NONE)
ExternalProject_Add(zlib
PREFIX zlib
GIT_REPOSITORY https://github.com/madler/zlib.git
GIT_TAG v1.2.13
GIT_TAG v1.3.1
CMAKE_ARGS -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/zlib/install
-DSTATIC=OFF
-DZLIB_BUILD_EXAMPLES=OFF
)
2 changes: 1 addition & 1 deletion examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ qt_add_resources(${PROJECT_EXAMPLES}_SOURCES examplesResources.qrc)

add_executable(${PROJECT_EXAMPLES} ${${PROJECT_EXAMPLES}_SOURCES})

target_link_libraries(${PROJECT_EXAMPLES} PRIVATE eible Qt6::Core Qt6::Widgets QuaZip::QuaZip)
target_link_libraries(${PROJECT_EXAMPLES} PRIVATE eible Qt6::Core Qt6::Widgets QuaZip)
2 changes: 1 addition & 1 deletion tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ qt_add_resources(${PROJECT_TESTS}_SOURCES testResources.qrc)

add_executable(${PROJECT_TESTS} ${${PROJECT_TESTS}_SOURCES})

target_link_libraries(${PROJECT_TESTS} PRIVATE eible Qt6::Core Qt6::Widgets Qt6::Test QuaZip::QuaZip)
target_link_libraries(${PROJECT_TESTS} PRIVATE eible Qt6::Core Qt6::Widgets Qt6::Test QuaZip)

add_test(NAME ${PROJECT_TESTS} COMMAND ${PROJECT_TESTS})

Expand Down

0 comments on commit 2a8160e

Please sign in to comment.