#!/bin/bash function cd_dir { local dir_path=$1 # 检查目录是否存在 if [ ! -d "$dir_path" ]; then echo "Directory $dir_path does not exist. Creating..." mkdir -p "$dir_path" fi cd "$dir_path" || exit } cd_dir build cmake -DBUILD_SHARED_LIBS=OFF -DBUILD_STATIC_LIBS=ON -DINSTALL_HEADERS=ON -DINSTALL_SHARED_LIBS=OFF -DINSTALL_STATIC_LIBS=ON .. make -j8 sudo make install -j8 cd ..