CMake wrapper for Windows

This commit is contained in:
Jay Berkenbilt 2022-03-11 20:54:07 -05:00 committed by Jay Berkenbilt
parent aacf48a2e0
commit 3a902ad20a
2 changed files with 39 additions and 0 deletions

View File

@ -27,6 +27,10 @@ CFLAGS="-fsanitize=address -fsanitize=undefined" \
CC=clang CXX=clang++ \
cmake -DMAINTAINER_MODE=1 -DBUILD_SHARED_LIBS=0 -DCMAKE_BUILD_TYPE=Debug ..
Windows:
../cmake-win {mingw|msvc} maint
VERSIONS
* The version number on the main branch is whatever the version would

35
cmake-win Executable file
View File

@ -0,0 +1,35 @@
#!/bin/bash
set -e
whoami=$(basename $0)
tool=$1
mode=$2
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)
args=(-DCMAKE_BUILD_TYPE=RelWithDebInfo)
if cl 2>&1 | grep -q 'for x86'; then
args=("${args[@]}" -A win32)
fi
;;
mingw)
args=(-G 'MSYS Makefiles' -DCMAKE_BUILD_TYPE=RelWithDebInfo)
;;
*)
echo 1>&2 "Usage: $whoami {msvc|mingw}"
exit 2
;;
esac
if [ "$mode" = "maint" ]; then
args=("${args[@]}" -DMAINTAINER_MODE=1 -DBUILD_DOC=0 -DBUILD_STATIC_LIBS=0)
elif [ "$mode" = "ci" ]; then
args=("${args[@]}" -DCI_MODE=1 -DINSTALL_MANUAL=1)
fi
set -x
cmake "${args[@]}" $dir