Commit 998b40ff authored by jan.koester's avatar jan.koester
Browse files

test

parent 5f69d5cc
Loading
Loading
Loading
Loading
+6 −7
Original line number Diff line number Diff line
@@ -22,18 +22,17 @@ find_package(libcmdplus REQUIRED)

find_package(libhtmlpp)

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}  ${CMAKE_SOURCE_DIR}/cmake/)

# --- Response/request compression (src/httpcompression.cpp) ---
# No CMake config package for either upstream, and no bundled FindBrotli module -- zlib gets
# CMake's own FindZLIB, brotli goes through pkg-config (libbrotlienc/libbrotlidec, Debian
# package libbrotli-dev).
# 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).
find_package(ZLIB REQUIRED)
find_package(PkgConfig REQUIRED)
pkg_check_modules(BROTLI REQUIRED IMPORTED_TARGET libbrotlienc libbrotlidec)
find_package(Brotli REQUIRED)

include(CheckIncludeFileCXX)

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}  ${CMAKE_SOURCE_DIR}/cmake/)

configure_file(config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h)

include_directories(

cmake/FindBrotli.cmake

0 → 100644
+106 −0
Original line number Diff line number Diff line
#=============================================================================
# FindBrotli.cmake (Shared Library Version - Refined for Windows DLL Paths)
#=============================================================================

include(FindPackageHandleStandardArgs)

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

find_path(BROTLI_INCLUDE_DIR "brotli/decode.h"
    HINTS ENV BROTLI_ROOT
    PATH_SUFFIXES include
)

find_library(BROTLICOMMON_LIBRARY NAMES brotlicommon)
find_library(BROTLIDEC_LIBRARY NAMES brotlidec)
find_library(BROTLIENC_LIBRARY NAMES brotlienc)

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

find_package_handle_standard_args(Brotli
    FOUND_VAR           BROTLI_FOUND
    REQUIRED_VARS       BROTLI_INCLUDE_DIR
                        BROTLIDEC_LIBRARY
                        BROTLIENC_LIBRARY
                        BROTLICOMMON_LIBRARY
    FAIL_MESSAGE        "Could NOT find Brotli shared libraries or headers."
)

# -----------------------------------------------------------------------------
# 3. Define Imported Shared Targets
# -----------------------------------------------------------------------------

if(BROTLI_FOUND)

    # Define a helper function to set common properties for shared targets
    function(configure_brotli_shared_target NAME LIB_VAR)

        # 1. Define the target as SHARED IMPORTED
        add_library(Brotli::${NAME} SHARED IMPORTED)

        # 2. Set the public interface (headers)
        set_target_properties(Brotli::${NAME} PROPERTIES
            INTERFACE_INCLUDE_DIRECTORIES "${BROTLI_INCLUDE_DIR}"
        )

        # 3. Set the location properties
        if(WIN32)
            # Set IMPORTED_IMPLIB (the .lib) for linking
            set_target_properties(Brotli::${NAME} PROPERTIES
                IMPORTED_IMPLIB "${${LIB_VAR}}"
            )

            # CRITICAL FOR DLL PATH RESOLUTION: Determine the DLL path.
            # We assume a common structure: DLLs are in 'bin' and .lib are in 'lib'.
            get_filename_component(_LIB_DIR "${${LIB_VAR}}" DIRECTORY)
            get_filename_component(_PARENT_DIR "${_LIB_DIR}" DIRECTORY)
            string(TOLOWER "${NAME}" _LOWER_NAME)

            # 💡 Heuristic: Assuming DLL is in <parent>/bin/
            set(_DLL_PATH_BASE "${_PARENT_DIR}/bin/brotli${_LOWER_NAME}")

            # Set IMPORTED_LOCATION for both Debug and Release configurations
            # This is essential for the INSTALL command to find the DLLs.
            set_target_properties(Brotli::${NAME} PROPERTIES
                IMPORTED_LOCATION_RELEASE "${_DLL_PATH_BASE}.dll"
                IMPORTED_LOCATION_DEBUG   "${_DLL_PATH_BASE}d.dll" # Common debug suffix 'd'
            )

        else()
            # Non-Windows systems: link file is the runtime file
            set_target_properties(Brotli::${NAME} PROPERTIES
                IMPORTED_LOCATION "${${LIB_VAR}}"
            )
        endif()

    endfunction()

    # Call the helper for each component
    configure_brotli_shared_target(Dec      BROTLIDEC_LIBRARY)
    configure_brotli_shared_target(Enc      BROTLIENC_LIBRARY)
    configure_brotli_shared_target(Common   BROTLICOMMON_LIBRARY)


    # ------------------ BROTLI::BROTLI Interface Target ------------------
    # Provides a single, convenient target for linking
    add_library(Brotli::Brotli INTERFACE IMPORTED)
    target_link_libraries(Brotli::Brotli INTERFACE
        Brotli::Common
        Brotli::Dec
        Brotli::Enc
    )
    target_include_directories(Brotli::Brotli INTERFACE "${BROTLI_INCLUDE_DIR}")

endif()

# Hide internal variables from the CMake GUI
mark_as_advanced(
    BROTLI_INCLUDE_DIR
    BROTLICOMMON_LIBRARY
    BROTLIDEC_LIBRARY
    BROTLIENC_LIBRARY
)
+4 −4
Original line number Diff line number Diff line
@@ -22,14 +22,14 @@ generate_export_header(httppp)

if(${CMAKE_HOST_SYSTEM_NAME} MATCHES "Windows")
  target_link_libraries(httppp PUBLIC netplus::netplus cmdplus::cmdplus)
  target_link_libraries(httppp PRIVATE ZLIB::ZLIB PkgConfig::BROTLI)
  target_link_libraries(httppp PRIVATE ZLIB::ZLIB Brotli::Brotli)
  target_link_libraries(httppp-static PUBLIC netplus::netplus-static cmdplus::cmdplus)
  target_link_libraries(httppp-static PRIVATE ZLIB::ZLIB PkgConfig::BROTLI)
  target_link_libraries(httppp-static PRIVATE ZLIB::ZLIB Brotli::Brotli)
else()
  target_link_libraries(httppp PUBLIC netplus::netplus cmdplus::cmdplus pthread)
  target_link_libraries(httppp PRIVATE ZLIB::ZLIB PkgConfig::BROTLI)
  target_link_libraries(httppp PRIVATE ZLIB::ZLIB Brotli::Brotli)
  target_link_libraries(httppp-static PUBLIC netplus::netplus-static cmdplus::cmdplus pthread)
  target_link_libraries(httppp-static PRIVATE ZLIB::ZLIB PkgConfig::BROTLI)
  target_link_libraries(httppp-static PRIVATE ZLIB::ZLIB Brotli::Brotli)
endif()

set_property(TARGET httppp PROPERTY VERSION ${Upstream_VERSION})