-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerate_build.sh
executable file
·57 lines (49 loc) · 1.82 KB
/
generate_build.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/env sh
set -x
if [ ! -f ./CMakeLists.txt ]
then
echo "This script should be launched from the project root"
exit 1
fi
################################################################################
# Determining build type #
################################################################################
additional_opts="-DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCPPUTILS_ENABLE_TESTING=ON"
build_dir=""
if [ "$1" = "debug" ]
then
additional_opts="$additional_opts -DCMAKE_BUILD_TYPE=Debug -DUSE_SANITIZERS=ON"
build_dir="./debug"
elif [ "$1" = "release" ]
then
additional_opts="$additional_opts -DCMAKE_BUILD_TYPE=Release"
build_dir="./release"
else
echo "Please pass the build type (debug or release)"
exit 1
fi
################################################################################
# Determining mechanism for fetching dependencies #
################################################################################
if [ "$#" -lt 2 ]
then
while true
do
read -p "Are you sure you want to continue without providing vcpkg root? (y/n)" answer
case $answer in
[Yy]* )
echo "Proceeding with installation from urls"
break;;
[Nn]* )
echo "Please relaunch the script and pass vcpkg root as the second argument. Aborting"
exit 0
break;;
* ) echo "Please answer with 'y' or 'n'.";;
esac
done
else
additional_opts="$additional_opts -DUSE_VCPKG=ON -DCMAKE_TOOLCHAIN_FILE=$2/scripts/buildsystems/vcpkg.cmake"
fi
# NOTE: the second variable is not quoted because I want it to be split
cmake -S . -B "$build_dir" $additional_opts
cp --force "$build_dir/compile_commands.json" .