Browse Source

add build.sh

master
yuanlin zhong 2 months ago
parent
commit
6f093be3f8
  1. 62
      build.sh

62
build.sh

@ -0,0 +1,62 @@ @@ -0,0 +1,62 @@
#!/bin/bash
set -e
USER=`whoami`
SUDO=
function sudo_auth(){
echo "验证 sudo 权限..."
sudo -v >/dev/null 2>&1 || {
echo "❌ sudo 密码错误,退出脚本"
exit 1
}
}
function install_openmvs(){
cmake -S . -B make -DCMAKE_BUILD_TYPE=Release -DVCG_ROOT=./vcglib -DCGAL_DATA_DIR=/usr/share/cgal
cd make && make -j$(nproc)
make install
}
if [ "$USER" == "root" ]; then
SUDO=""
else
SUDO="sudo "
sudo_auth
fi
$SUDO apt update
install_if_missing() {
for pkg in "$@"; do
if dpkg -s "$pkg" >/dev/null 2>&1; then
echo "$pkg 已安装"
else
echo "📦 正在安装 $pkg ..."
$SUDO apt install -y "$pkg" || {
echo "❌ 安装 $pkg 失败"
exit 1
}
fi
done
}
install_if_missing build-essential cmake git pkg-config
#EIGEN3
install_if_missing libeigen3-dev
#opencv
install_if_missing libopencv-dev
#ceres solver
install_if_missing libceres-dev libceres2
#cgal
install_if_missing libcgal-dev libcgal-demo
#BOOST
install_if_missing libboost-all-dev
#GLFW
install_if_missing libglfw3-dev
install_openmvs
Loading…
Cancel
Save