Commit 1de834c9 authored by jan.koester's avatar jan.koester
Browse files

test

parent 998b40ff
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -25,9 +25,11 @@ find_package(libhtmlpp)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}  ${CMAKE_SOURCE_DIR}/cmake/)

# --- Response/request compression (src/httpcompression.cpp) ---
# zlib gets CMake's own FindZLIB; brotli has no upstream CMake config package, so we use
# our own cmake/FindBrotli.cmake instead of pkg-config (pkg-config isn't available on
# Windows, and both deps are PRIVATE below -- consumers never need to find either).
# Neither zlib nor brotli has a reliable upstream CMake config package, and pkg-config isn't
# available on Windows, so both get our own cmake/Find*.cmake modules instead (consistent
# Windows-DLL-path handling; see cmake/FindZLIB.cmake and cmake/FindBrotli.cmake). Both deps
# are PRIVATE below -- consumers never link them directly -- but see src/cmake/httpppConfig.cmake
# for why find_dependency() still has to re-run these finds for anyone consuming httppp-static.
find_package(ZLIB REQUIRED)
find_package(Brotli REQUIRED)

cmake/FindZLIB.cmake

0 → 100644
+72 −0
Original line number Diff line number Diff line
#=============================================================================
# FindZLIB.cmake (Shared Library Version - Windows/Linux)
#=============================================================================
# Our own module instead of CMake's bundled FindZLIB, for the same reason as
# FindBrotli.cmake in this directory: consistent DLL-path handling on Windows
# and a single ZLIB::ZLIB target shape shared by both platforms. Placed in
# ${CMAKE_MODULE_PATH} (see the top-level CMakeLists.txt) so find_package(ZLIB)
# picks this up ahead of CMake's own Modules/FindZLIB.cmake.

include(FindPackageHandleStandardArgs)

# -----------------------------------------------------------------------------
# 1. Find Header and Link Library
# -----------------------------------------------------------------------------

find_path(ZLIB_INCLUDE_DIR "zlib.h"
    HINTS ENV ZLIB_ROOT
    PATH_SUFFIXES include
)

find_library(ZLIB_LIBRARY NAMES z zlib zdll zlibstatic)

# -----------------------------------------------------------------------------
# 2. Handle Required Arguments
# -----------------------------------------------------------------------------

find_package_handle_standard_args(ZLIB
    FOUND_VAR           ZLIB_FOUND
    REQUIRED_VARS       ZLIB_INCLUDE_DIR
                        ZLIB_LIBRARY
    FAIL_MESSAGE        "Could NOT find ZLIB library or headers."
)

# -----------------------------------------------------------------------------
# 3. Define Imported Shared Target
# -----------------------------------------------------------------------------

if(ZLIB_FOUND AND NOT TARGET ZLIB::ZLIB)
    add_library(ZLIB::ZLIB SHARED IMPORTED)

    set_target_properties(ZLIB::ZLIB PROPERTIES
        INTERFACE_INCLUDE_DIRECTORIES "${ZLIB_INCLUDE_DIR}"
    )

    if(WIN32)
        # Set IMPORTED_IMPLIB (the .lib) for linking
        set_target_properties(ZLIB::ZLIB PROPERTIES
            IMPORTED_IMPLIB "${ZLIB_LIBRARY}"
        )

        # CRITICAL FOR DLL PATH RESOLUTION: same bin/lib layout assumption as
        # FindBrotli.cmake's configure_brotli_shared_target().
        get_filename_component(_ZLIB_LIB_DIR "${ZLIB_LIBRARY}" DIRECTORY)
        get_filename_component(_ZLIB_PARENT_DIR "${_ZLIB_LIB_DIR}" DIRECTORY)

        set_target_properties(ZLIB::ZLIB PROPERTIES
            IMPORTED_LOCATION_RELEASE "${_ZLIB_PARENT_DIR}/bin/zlib1.dll"
            IMPORTED_LOCATION_DEBUG   "${_ZLIB_PARENT_DIR}/bin/zlib1d.dll"
        )
    else()
        # Non-Windows systems: link file is the runtime file
        set_target_properties(ZLIB::ZLIB PROPERTIES
            IMPORTED_LOCATION "${ZLIB_LIBRARY}"
        )
    endif()
endif()

# Hide internal variables from the CMake GUI
mark_as_advanced(
    ZLIB_INCLUDE_DIR
    ZLIB_LIBRARY
)