2013-02-06 11:16:49 -05:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
function cmake_install {
|
|
|
|
if [[ `uname -s` == "Darwin" ]]; then
|
|
|
|
homebrew_cmake_install
|
|
|
|
else
|
|
|
|
linux_cmake_install
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
function homebrew_cmake_install {
|
|
|
|
if [[ `which brew &> /dev/null` ]]; then
|
|
|
|
brew install cmake
|
|
|
|
else
|
2013-02-07 21:12:42 -05:00
|
|
|
echo "Homebrew was not found installed in your system."
|
|
|
|
echo "Go to http://mxcl.github.com/homebrew/ and follow the instructions."
|
|
|
|
echo "Or install CMake somehow and retry."
|
2013-02-06 11:16:49 -05:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
function install {
|
|
|
|
ycm_dir=`pwd`
|
2013-02-07 22:19:55 -05:00
|
|
|
build_dir=`mktemp -d -t ycm_build.XXXX`
|
2013-02-06 11:16:49 -05:00
|
|
|
pushd $build_dir
|
2013-02-07 22:09:53 -05:00
|
|
|
cmake -G "Unix Makefiles" $1 . $ycm_dir/cpp
|
2013-02-06 15:00:58 -05:00
|
|
|
make ycm_core
|
2013-02-06 11:16:49 -05:00
|
|
|
popd
|
|
|
|
}
|
|
|
|
|
|
|
|
function linux_cmake_install {
|
2013-02-07 21:12:42 -05:00
|
|
|
echo "Please install CMake using your package manager and retry."
|
2013-02-06 11:16:49 -05:00
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
2013-02-07 21:24:25 -05:00
|
|
|
function usage {
|
2013-02-07 21:12:42 -05:00
|
|
|
echo "Usage: $0 [--clang-completer]"
|
|
|
|
exit 0
|
2013-02-07 21:24:25 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
if [[ $# -gt 1 ]]; then
|
|
|
|
usage
|
2013-02-07 21:12:42 -05:00
|
|
|
fi
|
|
|
|
|
|
|
|
case "$1" in
|
|
|
|
--clang-completer)
|
|
|
|
cmake_args='-DUSE_CLANG_COMPLETER=ON'
|
|
|
|
;;
|
2013-02-07 21:24:25 -05:00
|
|
|
'')
|
2013-02-07 21:12:42 -05:00
|
|
|
cmake_args=''
|
|
|
|
;;
|
2013-02-07 21:24:25 -05:00
|
|
|
*)
|
|
|
|
usage
|
|
|
|
;;
|
2013-02-07 21:12:42 -05:00
|
|
|
esac
|
|
|
|
|
2013-02-06 11:16:49 -05:00
|
|
|
if [[ ! -z `which cmake &> /dev/null` ]]; then
|
2013-02-07 21:12:42 -05:00
|
|
|
echo "CMake is required to build YouCompleteMe."
|
2013-02-06 11:16:49 -05:00
|
|
|
cmake_install
|
|
|
|
fi
|
2013-02-07 21:12:42 -05:00
|
|
|
install $cmake_args
|