#!/bin/bash set -e cd /tmp git clone --depth 1 https://github.com/MEONMedical/Log4Qt.git ./log4qt cd log4qt mkdir build && cd build cmake .. -DCMAKE_INSTALL_PREFIX=/usr/local -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_STANDARD=17 make -j$(nproc) make install # Patch installed headers for C++17 compatibility # Fix 1: Replace C++20 spaceship operator with traditional comparison operators in level.h # Uses mValue (the actual member variable) instead of mLevel 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; }/' /usr/local/include/log4qt/level.h # Fix 2: Ensure mThreshold.load() is used in appenderskeleton.h sed -i 's/return (mThreshold <= level)/return (mThreshold.load() <= level)/g' /usr/local/include/log4qt/appenderskeleton.h echo "log4qt built and patched for C++17"