embedded-framework/external/gtest/build_gtest.sh
2023-07-20 08:18:17 -07:00

35 lines
1.2 KiB
Bash

#!/bin/bash
#编译gtest库
platform=$1
CMAKE_SOURCE_DIR=$2
echo "Compile gtest, platform = $platform, cmake source dir = $CMAKE_SOURCE_DIR."
export ROOT_PATH=$PWD
if [ ! -d "./googletest-release-1.11.0" ];then
echo "tar zxvf googletest-release-1.11.0.tar.gz"
tar zxvf googletest-release-1.11.0.tar.gz
cp ./modify/CMakeList_gmock.txt ./googletest-release-1.11.0/googlemock/CMakeLists.txt
cp ./modify/CMakeList_gtest.txt ./googletest-release-1.11.0/googletest/CMakeLists.txt
fi
if [ ! -f "./googletest-release-1.11.0/googlemock/lib/libgtest.a" ] || [ ! -f "./googletest-release-1.11.0/googlemock/lib/libgmock.a" ];then
echo "make gtest"
cd ./googletest-release-1.11.0/googlemock/
rm CMakeCache.txt CMakeFiles/ cmake_install.cmake Makefile lib/ -rf
case $platform in
"linux")
echo "==Compile linux."
cmake -DCMAKE_TOOLCHAIN_FILE=$CMAKE_SOURCE_DIR/build/cmake/toolchain/linux.toolchain.cmake .
make
;;
"sigmastart_333DE")
echo "==Compile sigmastart_333DE."
cmake -DCMAKE_TOOLCHAIN_FILE=$CMAKE_SOURCE_DIR/333DE/build/cmake/toolchain/sigmastart_333DE.toolchain.cmake .
make
;;
*)
echo "Compile gtest failed."
;;
esac
fi
cd $ROOT_PATH
echo "Exit build_gtest.sh."