环境:Ubuntu 16.04 LTS
命令:
export MY_INSTALL_DIR=/home/sa/GrpcTest
mkdir -p $MY_INSTALL_DIR
export PATH="$PATH:$MY_INSTALL_DIR/bin"
cmake --version
注:官方文档显示 CMake 需要版本不低于 3.13,如低于需先更新 CMake
更新 CMake 步骤:
sudo apt remove cmake,卸载旧版的cmake;
安装新版本 cmake:
$ wget -q -O cmake-linux.sh https://github.com/Kitware/CMake/releases/download/v3.17.0/cmake-3.17.0-Linux-x86_64.sh
$ sh cmake-linux.sh -- --skip-license --prefix=$MY_INSTALL_DIR
$ rm cmake-linux.sh
$
sudo ln -sf $MY_INSTALL_DIR/bin/* /usr/bin/
$
cmake --version
sudo apt install -y build-essential autoconf libtool pkg-config
cd /home/sa/GrpcTest
git clone https://github.com/HDQY/Grpc_v1.34.0.git
cd grpc
$ mkdir -p cmake/build
$ pushd cmake/build
$ cmake -DgRPC_INSTALL=ON
-DgRPC_BUILD_TESTS=OFF
-DCMAKE_INSTALL_PREFIX=$MY_INSTALL_DIR
../..
$ make -j
$ make install
$ popd