T
T
tr1cks2018-03-24 19:13:04
Qt
tr1cks, 2018-03-24 19:13:04

How to properly add and distribute zlib to a Qt 5 CMake project?

The project is cross-platform (Windows, Linux, Mac OS). There is a problem with find at least on Windows - I never managed to get CMake to find zlib and build everything. The option with qmake and using the zlib built into Qt is understandable, but it is not clear how to transfer it to CMake.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
tr1cks, 2018-03-25
@tr1cks

So far I have settled on the option - add sources to the project and connect via But so far I have not found a better way to include headers in the main project than adding target_include_directories to the CMakeLists.txt of the child project:

add_library(zlib SHARED ${ZLIB_SRCS} ${ZLIB_ASMS} ${ZLIB_DLL_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
target_include_directories(zlib PUBLIC ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
add_library(zlibstatic STATIC ${ZLIB_SRCS} ${ZLIB_ASMS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
target_include_directories(zlibstatic PUBLIC ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR})

And I still don’t understand how to make normal support for CPack, if collected as a shared library.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question