Split CMakeLists.txt into cmake/Plugin.cmake (production formats and MinGW link flags) and cmake/Harness.cmake (console test harness with CTest registration). Add SERUMALT_BUILD_PLUGIN and SERUMALT_BUILD_TESTS options so production and harness builds are mutually exclusive and each omits the other's targets. Add build_linux.sh, build_macos.sh, and build_harness.sh with host validation, env-overridable build dirs, and explicit option flags. Rewrite build_windows.sh to use the checked-in mingw64-toolchain.cmake instead of regenerating it, validate all required tools, and stage with cmake -E copy_directory. Broaden .gitignore to cover all build_*/ directories.
51 lines
1.5 KiB
Bash
Executable File
51 lines
1.5 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
cd "$SCRIPT_DIR"
|
|
|
|
BUILD_DIR="${BUILD_DIR:-$SCRIPT_DIR/build_harness}"
|
|
BUILD_TYPE="${BUILD_TYPE:-Release}"
|
|
export CMAKE_BUILD_PARALLEL_LEVEL="${CMAKE_BUILD_PARALLEL_LEVEL:-2}"
|
|
|
|
if [[ $# -gt 1 || ( $# -eq 1 && "$1" != --run ) ]]; then
|
|
echo "Usage: $0 [--run]" >&2
|
|
exit 1
|
|
fi
|
|
|
|
TOOLS=(cmake ninja "${CC:-cc}" "${CXX:-c++}")
|
|
case "$(uname -s)" in
|
|
Linux) TOOLS+=(pkg-config) ;;
|
|
Darwin) TOOLS+=(xcrun) ;;
|
|
*) echo "ERROR: build_harness.sh requires a native Linux or macOS host." >&2; exit 1 ;;
|
|
esac
|
|
if [[ $# -eq 1 ]]; then
|
|
TOOLS+=(ctest)
|
|
fi
|
|
for tool in "${TOOLS[@]}"; do
|
|
if ! command -v "$tool" >/dev/null 2>&1; then
|
|
echo "ERROR: $tool not found. See README.md prerequisites." >&2
|
|
exit 1
|
|
fi
|
|
done
|
|
|
|
if [[ "$(uname -s)" == Darwin ]]; then
|
|
xcrun --sdk macosx --show-sdk-path
|
|
fi
|
|
|
|
echo "Configuring the native QA harness only in $BUILD_DIR ($BUILD_TYPE)..."
|
|
cmake -S "$SCRIPT_DIR" -B "$BUILD_DIR" -G Ninja \
|
|
-DCMAKE_BUILD_TYPE="$BUILD_TYPE" \
|
|
-DSERUMALT_BUILD_PLUGIN=OFF \
|
|
-DSERUMALT_BUILD_TESTS=ON
|
|
|
|
echo "Building SerumAltTest..."
|
|
cmake --build "$BUILD_DIR" --config "$BUILD_TYPE" --target SerumAltTest
|
|
|
|
if [[ $# -eq 1 ]]; then
|
|
echo "Running the QA harness with CTest..."
|
|
ctest --test-dir "$BUILD_DIR" --build-config "$BUILD_TYPE" --output-on-failure --no-tests=error
|
|
fi
|
|
|
|
echo "Done. QA harness: $BUILD_DIR/SerumAltTest_artefacts/$BUILD_TYPE/SerumAltTest"
|