This commit is contained in:
1 file changed
+16
-48
+16
-48
@@ -1,53 +1,21 @@
|
|||||||
#!/usr/bin/env bash
|
#!/bin/bash
|
||||||
set -euo pipefail
|
set -e
|
||||||
|
|
||||||
# build_log4qt.sh - build and install Log4Qt into /usr/local
|
cd /tmp
|
||||||
# Designed to be run inside the Docker build or by a runner that has Qt installed at $QT_ROOT
|
git clone --depth 1 https://github.com/MEONMedical/Log4Qt.git ./log4qt
|
||||||
|
cd log4qt
|
||||||
|
|
||||||
QT_ROOT=${QT_ROOT:-/opt/Qt/6.8.3/gcc_64}
|
mkdir build && cd build
|
||||||
INSTALL_PREFIX=${INSTALL_PREFIX:-/usr/local}
|
cmake .. -DCMAKE_INSTALL_PREFIX=/usr/local -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_STANDARD=17
|
||||||
|
make -j$(nproc)
|
||||||
|
make install
|
||||||
|
|
||||||
echo "Building Log4Qt (QT_ROOT=${QT_ROOT})..."
|
# 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
|
||||||
|
|
||||||
TMPDIR=$(mktemp -d)
|
# Fix 2: Ensure mThreshold.load() is used in appenderskeleton.h
|
||||||
trap 'rm -rf "$TMPDIR"' EXIT
|
sed -i 's/return (mThreshold <= level)/return (mThreshold.load() <= level)/g' /usr/local/include/log4qt/appenderskeleton.h
|
||||||
|
|
||||||
cd "$TMPDIR"
|
echo "log4qt built and patched for C++17"
|
||||||
if ! git clone --depth 1 https://github.com/MEONMedical/Log4Qt.git ./log4qt; then
|
|
||||||
echo "Warning: failed to clone Log4Qt from github. Exiting build." >&2
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
mkdir -p log4qt/build
|
|
||||||
cd log4qt/build
|
|
||||||
cmake -DCMAKE_BUILD_TYPE=Release \
|
|
||||||
-DCMAKE_CXX_STANDARD=20 \
|
|
||||||
-DCMAKE_CXX_EXTENSIONS=OFF \
|
|
||||||
-DCMAKE_PREFIX_PATH="${QT_ROOT}" \
|
|
||||||
-DCMAKE_INSTALL_PREFIX="${INSTALL_PREFIX}" ..
|
|
||||||
|
|
||||||
cmake --build . -- -j$(nproc) || true
|
|
||||||
cmake --install . || true
|
|
||||||
|
|
||||||
# Create minimal CMake config so find_package(Log4Qt) will work
|
|
||||||
mkdir -p "${INSTALL_PREFIX}/lib/cmake/Log4Qt"
|
|
||||||
libpath=$((ls "${INSTALL_PREFIX}/lib/libLog4Qt.so"* 2>/dev/null || ls "${INSTALL_PREFIX}/lib/liblog4qt.so"* 2>/dev/null) | head -n1 || true)
|
|
||||||
if [ -n "$libpath" ]; then
|
|
||||||
cat > "${INSTALL_PREFIX}/lib/cmake/Log4Qt/Log4QtConfig.cmake" <<EOF
|
|
||||||
# Minimal Log4QtConfig.cmake created by build_log4qt.sh
|
|
||||||
if (NOT TARGET Log4Qt::log4qt)
|
|
||||||
add_library(Log4Qt::log4qt UNKNOWN IMPORTED)
|
|
||||||
set_target_properties(Log4Qt::log4qt PROPERTIES
|
|
||||||
IMPORTED_LOCATION "${libpath}"
|
|
||||||
INTERFACE_INCLUDE_DIRECTORIES "${INSTALL_PREFIX}/include"
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
set(Log4Qt_FOUND TRUE CACHE INTERNAL "Log4Qt found by package config")
|
|
||||||
set(Log4Qt_INCLUDE_DIRS "${INSTALL_PREFIX}/include" CACHE INTERNAL "Log4Qt include dir")
|
|
||||||
set(Log4Qt_LIBRARIES "${libpath}" CACHE INTERNAL "Log4Qt library")
|
|
||||||
EOF
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Log4Qt build script finished."
|
|
||||||
|
|
||||||
exit 0
|
|
||||||
Reference in new issue
Block a user