Last active
March 6, 2017 21:21
-
-
Save alghanmi/10767290 to your computer and use it in GitHub Desktop.
Install Google C++ Testing Framework. This script works for both MacOS and Linux
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## | |
## Install Google C++ Testing Framework | |
## | |
##Remove Libraries that are already installed | |
# Linux: | |
# sudo rm -rf /usr/local/opt/gtest* | |
# sudo libtool --mode=uninstall rm /usr/local/lib/libgtest.a | |
# sudo libtool --mode=uninstall rm /usr/local/lib/libgtest_main.a | |
# Mac: | |
# rm -rf /usr/local/opt/gtest* | |
# glibtool --mode=uninstall rm /usr/local/lib/libgtest.la | |
# glibtool --mode=uninstall rm /usr/local/lib/libgtest_main.la | |
##Choose the proper tools for each platform | |
RUN_AS='' | |
LIBTOOL='' | |
if [ "$(uname)" = "Darwin" ]; then | |
LIBTOOL=glibtool | |
elif [ "$(uname)" = "Linux" ]; then | |
RUN_AS=sudo | |
LIBTOOL="$RUN_AS libtool" | |
$RUN_AS apt-get -y install libtool | |
fi | |
OLD_PWD="$(pwd)" | |
#Download gtest | |
curl --silent -o gtest-1.7.0.zip http://googletest.googlecode.com/files/gtest-1.7.0.zip | |
#Unpack the gtest library | |
$RUN_AS unzip gtest-1.7.0.zip -d /usr/local/opt/ | |
$RUN_AS ln -s gtest-1.7.0 /usr/local/opt/gtest | |
#Compile GTest | |
cd /usr/local/opt/gtest | |
$RUN_AS ./configure | |
$RUN_AS make | |
#Install Library files | |
$LIBTOOL --mode=install install lib/libgtest.la /usr/local/lib | |
$LIBTOOL --mode=install install lib/libgtest_main.la /usr/local/lib | |
#Configure Linker (for linux) | |
if [ "$(uname)" = "Linux" ]; then | |
$RUN_AS ldconfig | |
fi | |
cd "$OLD_PWD" | |
rm gtest-1.7.0.zip | |
rm gtest_install.sh |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
curl --silent -L https://gist.githubusercontent.com/alghanmi/10767290/raw/gtest_install.sh -o gtest_install.sh
chmod 755 gtest_install.sh
./gtest_install.sh