windows: make zlib static by default
This commit is contained in:
parent
1f72df2936
commit
278e04ebd6
|
|
@ -18,6 +18,7 @@ option(ENABLE_OPTIM "Enable build with -O3 optimization level"
|
||||||
option(BUILD_STATIC "Whether or not to build with static libraries" OFF)
|
option(BUILD_STATIC "Whether or not to build with static libraries" OFF)
|
||||||
option(USE_PKGCONFIG "Use pkgconfig to find libraries" ON)
|
option(USE_PKGCONFIG "Use pkgconfig to find libraries" ON)
|
||||||
option(LINK_CMAKE_THREADS "Use CMake find_package to link the threading library" OFF)
|
option(LINK_CMAKE_THREADS "Use CMake find_package to link the threading library" OFF)
|
||||||
|
option(WINDOWS_STATIC_ZLIB "Link zlib statically for Windows builds" ON)
|
||||||
|
|
||||||
if (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
|
if (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
|
||||||
set(ENABLE_UDEV OFF)
|
set(ENABLE_UDEV OFF)
|
||||||
|
|
@ -223,16 +224,44 @@ if (USE_PKGCONFIG)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# zlib support (gzip)
|
# zlib support (gzip)
|
||||||
pkg_check_modules(ZLIB zlib)
|
if (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
|
||||||
if (NOT ZLIB_FOUND)
|
if (WINDOWS_STATIC_ZLIB)
|
||||||
# try zlib-ng
|
set(ZLIB_USE_STATIC_LIBS ON)
|
||||||
pkg_check_modules(ZLIB zlib-ng)
|
|
||||||
if (ZLIB_FOUND)
|
|
||||||
add_definitions(-DHAS_ZLIBNG)
|
|
||||||
else()
|
|
||||||
message(FATAL_ERROR "Could find ZLIB")
|
|
||||||
endif()
|
endif()
|
||||||
endif(NOT ZLIB_FOUND)
|
|
||||||
|
# Use CMake zlib finder for Windows builds to avoid host pkg-config contamination
|
||||||
|
# during cross-compilation and to allow static linking selection.
|
||||||
|
find_package(ZLIB QUIET)
|
||||||
|
if (NOT ZLIB_FOUND)
|
||||||
|
if (windows_crosscompile)
|
||||||
|
message(FATAL_ERROR
|
||||||
|
"zlib for Windows target not found. Install MinGW zlib development files "
|
||||||
|
"(for example: libz-mingw-w64-dev on Debian/Ubuntu or mingw64-zlib on Fedora).")
|
||||||
|
else()
|
||||||
|
message(FATAL_ERROR
|
||||||
|
"zlib for Windows build not found. Install zlib development files for your "
|
||||||
|
"Windows toolchain.")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (WINDOWS_STATIC_ZLIB AND ZLIB_LIBRARIES MATCHES "\\.dll\\.a$")
|
||||||
|
message(FATAL_ERROR
|
||||||
|
"Static zlib requested (WINDOWS_STATIC_ZLIB=ON), but CMake selected "
|
||||||
|
"'${ZLIB_LIBRARIES}'. Install static zlib (for example mingw64-zlib-static) "
|
||||||
|
"or set -DWINDOWS_STATIC_ZLIB=OFF.")
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
pkg_check_modules(ZLIB zlib)
|
||||||
|
if (NOT ZLIB_FOUND)
|
||||||
|
# try zlib-ng
|
||||||
|
pkg_check_modules(ZLIB zlib-ng)
|
||||||
|
if (ZLIB_FOUND)
|
||||||
|
add_definitions(-DHAS_ZLIBNG)
|
||||||
|
else()
|
||||||
|
message(FATAL_ERROR "Could find ZLIB")
|
||||||
|
endif()
|
||||||
|
endif(NOT ZLIB_FOUND)
|
||||||
|
endif()
|
||||||
|
|
||||||
if (ENABLE_UDEV)
|
if (ENABLE_UDEV)
|
||||||
pkg_check_modules(LIBUDEV libudev)
|
pkg_check_modules(LIBUDEV libudev)
|
||||||
|
|
|
||||||
|
|
@ -216,6 +216,7 @@ The build system will automatically download and build the required dependencies
|
||||||
|
|
||||||
sudo apt install \
|
sudo apt install \
|
||||||
mingw-w64 \
|
mingw-w64 \
|
||||||
|
libz-mingw-w64-dev \
|
||||||
cmake \
|
cmake \
|
||||||
pkg-config \
|
pkg-config \
|
||||||
p7zip-full
|
p7zip-full
|
||||||
|
|
@ -247,6 +248,13 @@ The build system will automatically download and build the required dependencies
|
||||||
The resulting ``openFPGALoader.exe`` will be a statically-linked executable
|
The resulting ``openFPGALoader.exe`` will be a statically-linked executable
|
||||||
that only depends on standard Windows system DLLs (KERNEL32, msvcrt, WS2_32).
|
that only depends on standard Windows system DLLs (KERNEL32, msvcrt, WS2_32).
|
||||||
|
|
||||||
|
.. NOTE::
|
||||||
|
``zlib`` for the Windows target is required. Configuration fails if it is
|
||||||
|
missing (install ``libz-mingw-w64-dev`` on Debian/Ubuntu or
|
||||||
|
``mingw64-zlib`` on Fedora/RHEL/Rocky).
|
||||||
|
``zlib`` is linked statically by default on Windows builds
|
||||||
|
(``-DWINDOWS_STATIC_ZLIB=ON``).
|
||||||
|
|
||||||
**Optional: Strip debug symbols to reduce size:**
|
**Optional: Strip debug symbols to reduce size:**
|
||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: bash
|
||||||
|
|
@ -257,6 +265,7 @@ that only depends on standard Windows system DLLs (KERNEL32, msvcrt, WS2_32).
|
||||||
|
|
||||||
- ``-DCROSS_COMPILE_DEPS=OFF`` - Disable automatic dependency download (use system libraries)
|
- ``-DCROSS_COMPILE_DEPS=OFF`` - Disable automatic dependency download (use system libraries)
|
||||||
- ``-DENABLE_CMSISDAP=ON`` - Enable CMSIS-DAP support (requires manually providing hidapi)
|
- ``-DENABLE_CMSISDAP=ON`` - Enable CMSIS-DAP support (requires manually providing hidapi)
|
||||||
|
- ``-DWINDOWS_STATIC_ZLIB=OFF`` - Allow dynamic zlib linkage (produces ``zlib1.dll`` runtime dependency)
|
||||||
|
|
||||||
Common
|
Common
|
||||||
======
|
======
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue