Commit 4020af1e authored by jan.koester's avatar jan.koester
Browse files

tset

parent f6f9e61f
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -16,7 +16,6 @@ list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
find_package(libnetplus REQUIRED)
find_package(libhtmlpp REQUIRED)
find_package(libhttppp REQUIRED)
find_package(Brotli REQUIRED)
find_package(libcmdplus REQUIRED)
find_package(libconfplus REQUIRED)
find_package(libdbpp REQUIRED)

cmake/FindBrotli.cmake

deleted100644 → 0
+0 −106
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
)
 No newline at end of file
+0 −2
Original line number Diff line number Diff line
@@ -23,7 +23,6 @@ if(NOT TARGET blogidev)
    find_package(libuuidp REQUIRED)
    find_package(authdb REQUIRED)
    find_package(smtpclient REQUIRED)
    find_package(Brotli REQUIRED)
    find_package(paritypp REQUIRED)
    find_package(ZLIB REQUIRED)
    add_definitions(-D${CMAKE_HOST_SYSTEM_NAME} -DWIN32_LEAN_AND_MEAN -DNOMINMAX)
@@ -76,7 +75,6 @@ else()
        tinyxml2::tinyxml2
        uuidp::uuidp
        authdb::client
        Brotli::Brotli
        ZLIB::ZLIB
        dl
    )
+0 −4
Original line number Diff line number Diff line
@@ -22,7 +22,6 @@ target_link_libraries(blogidev PUBLIC
    httppp::httppp
    netplus::netplus
    cmdplus::cmdplus
    Brotli::Brotli
    json-c::json-c
    authdb::client
    confplus::confplus
@@ -101,10 +100,7 @@ if(${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Windows" )
            "$<TARGET_FILE_DIR:httppp::httppp>"
            "$<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:dbpp::dbpp>"
            "$<TARGET_FILE_DIR:Brotli::Common>"
        DESTINATION bin
        PRE_EXCLUDE_REGEXES "((api|ext)-ms-.*|.*azureattest.*|vcruntime.*|ucrtbase.*|msvcrt.*|wpaxholder.*|hvsifiletrust.*|pdmutilities.*)\\.dll"
        POST_EXCLUDE_REGEXES [[.*(\\|/)system32(\\|/).*\.dll]]