#!/bin/bash set -e cd /tmp rm -rf ./log4qt git clone --depth 1 https://github.com/MEONMedical/Log4Qt.git ./log4qt cd log4qt # Patch source files BEFORE build for C++17 compatibility # Fix 1: Replace C++20 spaceship operator in level.h sed -i 's/\[\[nodiscard\]\] constexpr auto operator<=>(const Level\& other) const noexcept = default;/bool operator<(const Level\& other) const noexcept { return mValue < other.mValue; }\n bool operator<=(const Level\& other) const noexcept { return mValue <= other.mValue; }\n bool operator>(const Level\& other) const noexcept { return mValue > other.mValue; }\n bool operator>=(const Level\& other) const noexcept { return mValue >= other.mValue; }\n bool operator==(const Level\& other) const noexcept { return mValue == other.mValue; }/' src/log4qt/level.h # Fix 2: Ensure mThreshold.load() is used in appenderskeleton.h sed -i 's/return (mThreshold <= level)/return (mThreshold.load() <= level)/g' src/log4qt/appenderskeleton.h mkdir build && cd build cmake .. \ -DCMAKE_INSTALL_PREFIX=/usr/local \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_CXX_STANDARD=17 \ -DCMAKE_CXX_STANDARD_REQUIRED=ON \ -DLOG4QT_BUILD_TESTS=OFF \ -DLOG4QT_EXAMPLES=OFF \ -DLOG4QT_BUILD_SHARED_LIBS=ON make -j$(nproc) make install # Verify CMake config files were installed if [ -f /usr/local/lib/cmake/Log4Qt/Log4QtConfig.cmake ]; then echo "Log4Qt CMake config installed successfully" else echo "WARNING: Log4Qt CMake config not found, creating manually..." mkdir -p /usr/local/lib/cmake/Log4Qt cat > /usr/local/lib/cmake/Log4Qt/Log4QtConfig.cmake << 'EOF' include(CMakeFindDependencyMacro) find_dependency(Qt6 COMPONENTS Core) include("${CMAKE_CURRENT_LIST_DIR}/Log4QtTargets.cmake") set(Log4Qt_FOUND TRUE) set(Log4Qt_INCLUDE_DIRS "/usr/local/include") set(Log4Qt_LIBRARIES "log4qt") EOF fi echo "log4qt built and installed with CMake config"