Commit c297f42b authored by jan.koester's avatar jan.koester
Browse files

it'S working

parent 73c0efbe
Loading
Loading
Loading
Loading
−1
Changes for CMakeLists.txt: 0 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -26,7 +26,6 @@ add_definitions(-D${CMAKE_HOST_SYSTEM_NAME} -DWIN32_LEAN_AND_MEAN)
include_directories(
    ${NETPLUS_INCLUDE_DIRS}
    ${HTTPPP_INCLUDE_DIRS}
    ${CRYPTPLUS_INCLUDE_DIRS}
    ${CMAKE_SOURCE_DIR}/src
    ${SECUREID_INCLUDE_DIRS}
    ${DBPP_INCLUDE_DIR}
+45 −78
Changes for cmake/FindBrotli.cmake: 45 added lines, 78 removed lines.
Original line number Diff line number Diff line
#=============================================================================
# FindBrotli.cmake
#
# Finds the Brotli compression library.
#
# Defines the following variables:
#  BROTLI_FOUND           - True if Brotli was found.
#  BROTLI_INCLUDE_DIR     - The directory containing the Brotli headers.
#  BROTLICOMMON_LIBRARY   - The path to the brotlicommon link library.
#  BROTLIDEC_LIBRARY      - The path to the brotlidec link library.
#  BROTLIENC_LIBRARY      - The path to the brotlienc link library.
#
# Defines the following imported targets:
#  Brotli::Dec            - The decoder library target.
#  Brotli::Enc            - The encoder library target.
#  Brotli::Common         - The common library target.
#  Brotli::Brotli         - An interface target linking to Dec, Enc, and Common.
#
# Usage:
#   find_package(Brotli REQUIRED)
#   target_link_libraries(MyTarget PRIVATE Brotli::Brotli)
#
# NOTE on Windows: This script assumes that if the .lib (Import Library) is found,
# the corresponding .dll (Runtime Library) is in a discoverable location.
# FindBrotli.cmake (Shared Library Version - Refined for Windows DLL Paths)
#=============================================================================

# Include standard CMake modules
include(FindPackageHandleStandardArgs)

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

# Find the common header file
find_path(BROTLI_INCLUDE_DIR "brotli/decode.h"
    HINTS ENV BROTLI_ROOT
    PATH_SUFFIXES include
)

# Find the link libraries (.lib or .so/.a)
# We prioritize SHARED library names in the find_library calls
find_library(BROTLICOMMON_LIBRARY NAMES brotlicommon)
find_library(BROTLIDEC_LIBRARY NAMES brotlidec)
find_library(BROTLIENC_LIBRARY NAMES brotlienc)
@@ -53,85 +27,78 @@ find_package_handle_standard_args(Brotli
                        BROTLIDEC_LIBRARY
                        BROTLIENC_LIBRARY
                        BROTLICOMMON_LIBRARY
    FAIL_MESSAGE        "Could NOT find Brotli. Set BROTLI_ROOT or check library/header paths."
    FAIL_MESSAGE        "Could NOT find Brotli shared libraries or headers."
)

# -----------------------------------------------------------------------------
# 3. Define Imported Targets (Modern CMake)
# 3. Define Imported Shared Targets
# -----------------------------------------------------------------------------

if(BROTLI_FOUND)
    # Determine the type of library found (Shared or Static)
    # This is a heuristic. On Windows, if find_library found a .lib and 
    # we expect DLLs, we must define it as SHARED.
    if(WIN32)
        # Check if we are linking against an MSVC-style import library (.lib)
        # Assuming that if a library is found, it is either the static lib 
        # or the shared import lib. We default to SHARED for runtime path support.
        set(_BROTLI_LIB_TYPE SHARED)
        set(_BROTLI_IMPLIB_PROPERTY IMPORTED_IMPLIB)
        set(_BROTLI_LOCATION_PROPERTY IMPORTED_LOCATION)

        # Helper to get the base directory of the link library
        function(get_lib_dir LIB_VAR OUT_VAR)
            get_filename_component(_path ${${LIB_VAR}} DIRECTORY)
            set(${OUT_VAR} "${_path}" PARENT_SCOPE)
        endfunction()
    else()
        # Non-Windows systems typically don't separate link and runtime files
        set(_BROTLI_LIB_TYPE SHARED)
        set(_BROTLI_IMPLIB_PROPERTY) # Not used on non-Windows for SHARED
        set(_BROTLI_LOCATION_PROPERTY IMPORTED_LOCATION)
    endif()
    
    # 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)
        
    # ------------------ BROTLI::DEC Target ------------------
    get_lib_dir(BROTLIDEC_LIBRARY BROTLIDEC_LIB_DIR)
    add_library(Brotli::Dec ${_BROTLI_LIB_TYPE} IMPORTED)
    set_target_properties(Brotli::Dec PROPERTIES
        # 2. Set the public interface (headers)
        set_target_properties(Brotli::${NAME} PROPERTIES
            INTERFACE_INCLUDE_DIRECTORIES "${BROTLI_INCLUDE_DIR}"
        # Set link file (.lib or .so/.a)
        ${_BROTLI_IMPLIB_PROPERTY} "${BROTLIDEC_LIBRARY}"
        # Set the runtime file (DLL on Windows, or the .so on others)
        # On Windows, we assume the DLL is in the same directory as the .lib, 
        # using the DLL naming convention.
        IMPORTED_LOCATION_RELEASE "$<IF:$<BOOL:${_BROTLI_IMPLIB_PROPERTY}>,${BROTLIDEC_LIB_DIR}/brotlidec.dll,${BROTLIDEC_LIBRARY}>"
        )
        
    # ------------------ BROTLI::ENC Target ------------------
    get_lib_dir(BROTLIENC_LIBRARY BROTLIENC_LIB_DIR)
    add_library(Brotli::Enc ${_BROTLI_LIB_TYPE} IMPORTED)
    set_target_properties(Brotli::Enc PROPERTIES
        INTERFACE_INCLUDE_DIRECTORIES "${BROTLI_INCLUDE_DIR}"
        ${_BROTLI_IMPLIB_PROPERTY} "${BROTLIENC_LIBRARY}"
        IMPORTED_LOCATION_RELEASE "$<IF:$<BOOL:${_BROTLI_IMPLIB_PROPERTY}>,${BROTLIENC_LIB_DIR}/brotlienc.dll,${BROTLIENC_LIBRARY}>"
        # 3. Set the location properties
        if(WIN32)
            # Set IMPORTED_IMPLIB (the .lib) for linking
            set_target_properties(Brotli::${NAME} PROPERTIES
                IMPORTED_IMPLIB "${${LIB_VAR}}"
            )
            
    # ------------------ BROTLI::COMMON Target ------------------
    get_lib_dir(BROTLICOMMON_LIBRARY BROTLICOMMON_LIB_DIR)
    add_library(Brotli::Common ${_BROTLI_LIB_TYPE} IMPORTED)
    set_target_properties(Brotli::Common PROPERTIES
        INTERFACE_INCLUDE_DIRECTORIES "${BROTLI_INCLUDE_DIR}"
        ${_BROTLI_IMPLIB_PROPERTY} "${BROTLICOMMON_LIBRARY}"
        IMPORTED_LOCATION_RELEASE "$<IF:$<BOOL:${_BROTLI_IMPLIB_PROPERTY}>,${BROTLICOMMON_LIB_DIR}/brotlicommon.dll,${BROTLICOMMON_LIBRARY}>"
            # 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 target for users to link against all components
    # 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
    )
    # The interface target inherits the include directory
    target_include_directories(Brotli::Brotli INTERFACE "${BROTLI_INCLUDE_DIR}")
    
endif()

# Hide internal variables from the CMake GUI
mark_as_advanced(
    BROTLI_FOUND
    BROTLI_INCLUDE_DIR
    BROTLICOMMON_LIBRARY
    BROTLIDEC_LIBRARY
+2
Changes for src/CMakeLists.txt: 2 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -79,6 +79,8 @@ if(${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Windows" )
            "$<TARGET_FILE_DIR:uuidp::uuidp>"
            "$<TARGET_FILE_DIR:json-c::json-c>"
            "$<TARGET_FILE_DIR:Brotli::Enc>"
            "$<TARGET_FILE_DIR:Brotli::Dec>"
            "$<TARGET_FILE_DIR:Brotli::Common>"
        DESTINATION bin
        PRE_EXCLUDE_REGEXES "((api|ext)-ms-.*|.*azureattest.*|vcruntime.*|ucrtbase.*|msvcrt.*|wpaxholder.*|hvsifiletrust.*|pdmutilities.*)\\.dll"
    )