#!/usr/bin/env bash set -euo pipefail if [[ $# -lt 1 || $# -gt 2 ]]; then echo "usage: $0 /path/to/SignalSim [build-directory]" >&2 exit 2 fi signalsim_source=$(realpath "$1") project_root=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd) build_directory=${2:-"${project_root}/build/signalsim"} if [[ ! -f "${signalsim_source}/IFdataGen/CMakeLists.txt" ]]; then echo "error: ${signalsim_source} is not a SignalSim tree with IFdataGen/CMakeLists.txt" >&2 exit 3 fi for dependency in cmake c++; do if ! command -v "${dependency}" >/dev/null 2>&1; then echo "error: required build dependency '${dependency}' is missing" >&2 exit 4 fi done generator=() if command -v ninja >/dev/null 2>&1; then generator=(-G Ninja) fi echo "SignalSim source: ${signalsim_source}" echo "Build directory: ${build_directory}" echo "CMake: $(cmake --version | head -n 1)" echo "Compiler: $(c++ --version | head -n 1)" if command -v ninja >/dev/null 2>&1; then echo "Ninja: $(ninja --version)" else echo "Ninja: unavailable; using CMake default generator" fi cmake -S "${signalsim_source}/IFdataGen" -B "${build_directory}" "${generator[@]}" \ -DCMAKE_BUILD_TYPE=Release -DUSE_NATIVE_OPT=OFF cmake --build "${build_directory}" --parallel executable="${build_directory}/IFdataGen" if [[ ! -x "${executable}" ]]; then echo "error: build completed without expected executable ${executable}" >&2 exit 5 fi echo "SIGNALSIM_EXECUTABLE=${executable}"