2022-03-12 01:54:07 +00:00
|
|
|
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
whoami=$(basename $0)
|
|
|
|
tool=$1
|
|
|
|
mode=$2
|
2023-05-21 00:50:09 +00:00
|
|
|
config=${3-RelWithDebInfo}
|
2022-03-12 01:54:07 +00:00
|
|
|
|
|
|
|
dir=$(realpath --relative-to . $(dirname $0))
|
|
|
|
if [ "$dir" = "." ]; then
|
|
|
|
echo 1>&2 "$whoami: run from other than the source directory."
|
|
|
|
exit 2
|
|
|
|
fi
|
|
|
|
declare -a args
|
|
|
|
case $tool in
|
|
|
|
msvc)
|
2023-05-21 00:50:09 +00:00
|
|
|
args=(-DCMAKE_BUILD_TYPE=$config)
|
2022-03-12 01:54:07 +00:00
|
|
|
if cl 2>&1 | grep -q 'for x86'; then
|
|
|
|
args=("${args[@]}" -A win32)
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
mingw)
|
2023-05-21 00:50:09 +00:00
|
|
|
args=(-G 'MSYS Makefiles' -DCMAKE_BUILD_TYPE=$config)
|
2022-03-12 01:54:07 +00:00
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo 1>&2 "Usage: $whoami {msvc|mingw}"
|
|
|
|
exit 2
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
if [ "$mode" = "maint" ]; then
|
2022-05-21 13:25:25 +00:00
|
|
|
args=("${args[@]}" -DWERROR=1 -DBUILD_STATIC_LIBS=0)
|
2022-03-12 01:54:07 +00:00
|
|
|
elif [ "$mode" = "ci" ]; then
|
|
|
|
args=("${args[@]}" -DCI_MODE=1 -DINSTALL_MANUAL=1)
|
|
|
|
fi
|
|
|
|
|
|
|
|
set -x
|
|
|
|
cmake "${args[@]}" $dir
|
2022-05-21 13:25:25 +00:00
|
|
|
set +x
|
|
|
|
if [ "$tool" = "msvc" ]; then
|
|
|
|
echo ""
|
2023-05-21 00:50:09 +00:00
|
|
|
echo "***"
|
|
|
|
echo "*** Remember to pass --config $config to cmake --build"
|
|
|
|
echo "*** and -C $config to ctest"
|
|
|
|
echo "***"
|
2022-05-21 13:25:25 +00:00
|
|
|
echo ""
|
|
|
|
fi
|