# sudo apt-get install cmake

version="${1:-"3.14.0"}"
url="https://github.com/Kitware/CMake/releases/download/v$version/cmake-$version-Linux-x86_64.sh"
file="$(basename "$url")"
prefix="${PREFIX:-"/usr/local"}"

tmp_dir="$(mktemp -d)"
trap 'rm -rf "$tmp_dir"' EXIT

(
    cd "$tmp_dir"
    wget "$url"
    chmod +x "$file"
    sudo "./$file" --prefix="$prefix" --exclude-subdir --skip-license
)