build(docker): extract Log4Qt build into ./app/build_log4qt.sh; keep Dockerfile simple (builds call script)\n\nCo-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

This commit is contained in:
torsten committed 2026-07-17 13:16:48 +02:00
1 parent c7abae2727
commit fd7ba24128
1 file changed
+53
+53
View File
@@ -0,0 +1,53 @@
#!/usr/bin/env bash
set -euo pipefail
# build_log4qt.sh - build and install Log4Qt into /usr/local
# Designed to be run inside the Docker build or by a runner that has Qt installed at $QT_ROOT
QT_ROOT=${QT_ROOT:-/opt/Qt/6.8.3/gcc_64}
INSTALL_PREFIX=${INSTALL_PREFIX:-/usr/local}
echo "Building Log4Qt (QT_ROOT=${QT_ROOT})..."
TMPDIR=$(mktemp -d)
trap 'rm -rf "$TMPDIR"' EXIT
cd "$TMPDIR"
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