I assume you downloaded the script from CMake's Download Page. The documentation how to use it is admittedly a little sparse.
In short, call (installation path for CMake here is /usr/local
):
# sudo cmake-3.11.3-Linux-x86_64.sh --skip-license --exclude-subdir --prefix=/usr/local
Note: You need to uninstall any package manager installed CMake packages first
# sudo apt remove cmake
# sudo apt purge --auto-remove cmake
Options
The script has the following options:
# cmake-3.11.3-Linux-x86_64.sh --help
Usage: cmake-3.11.3-Linux-x86_64.sh [options]
Options: [defaults in brackets after descriptions]
--help print this message
--version print cmake installer version
--prefix=dir directory in which to install
--include-subdir include the cmake-3.11.3-Linux-x86_64 subdirectory
--exclude-subdir exclude the cmake-3.11.3-Linux-x86_64 subdirectory
--skip-license accept license
The one you are searching for is --prefix=dir
. Otherwise it will just use the current directory to extract the installation files.
Test Output on Ubuntu
# cmake-3.11.3-Linux-x86_64.sh --skip-license --exclude-subdir --prefix=/usr/local
CMake Installer Version: 3.11.3, Copyright (c) Kitware
This is a self-extracting archive.
The archive will be extracted to: /usr/local
Using target directory: /usr/local
Extracting, please wait...
Unpacking finished successfully
# cmake --version
cmake version 3.11.3
CMake suite maintained and supported by Kitware (kitware.com/cmake).
Reference / Alternative