shell执行mkdir build \ cd build\ cmake.. \ make命令

新建rebuild.sh,放入脚本代码

代码如下:

#!/bin/bash
if [ ! -d "build" ]; then
    mkdir build
else
    rm -rf build/*
fi
cd build
Local_Dir=$(cd "$(dirname "$0")"; pwd)
echo "Now work at Dir:$Local_Dir"
cmake ..
make

也可以用下面这种:

#!/bin/bash
if [ ! -d "build" ]; then
    mkdir build
else
    rm -rf build/*
fi
cmake -S . -B build
cmake --build build

执行代码:

bash rebuild.sh

好用就点个赞吧~

你可能感兴趣的:(服务器,ubuntu,人工智能,开发语言)