generated from Kardbord/cpp-project-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·48 lines (44 loc) · 1.01 KB
/
install.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
#!/usr/bin/env bash
set -e
function usage() {
echo "${0}"
echo
echo "Usage"
echo " ${0} [-h] [-p]"
echo
echo "Options"
echo " -h Prints this usage"
echo " -p INSTALL_PREFIX Sets the target path for installation. If unspecified, uses the system default."
}
INSTALL_PREFIX=""
while getopts ":hp:" opt; do
case "${opt}" in
p)
INSTALL_PREFIX="${OPTARG}"
;;
h)
usage
exit 0
;;
*)
usage
exit 1
;;
esac
done
shift $((OPTIND - 1))
mkdir -p "$(dirname "${BASH_SOURCE[0]}")/../build"
pushd "$(dirname "${BASH_SOURCE[0]}")/../build" >/dev/null
rm -rf ./* # Start from clean slate
if [[ -n "${INSTALL_PREFIX}" ]]; then
if ! [[ -d "${INSTALL_PREFIX}" ]]; then
echo "No such directory: ${INSTALL_PREFIX}"
exit 1
fi
cmake .. "-DCMAKE_INSTALL_PREFIX:PATH=${INSTALL_PREFIX}" -DINSTALL=ON
else
cmake .. -DINSTALL=ON
fi
cmake --build . --config Release --target install -- -j "$(nproc)"
rm -rf ./* # Clean up build files
popd >/dev/null