How to specify where CMake is installed in Ubuntu?

前端 未结 2 1209
借酒劲吻你
借酒劲吻你 2021-01-19 09:55

I have downloaded the cmake-3.11.3-Linux-x86_64.sh file. Then I executed it and it created a folder that has a bin file there is cmake

相关标签:
2条回答
  • 2021-01-19 10:38

    Rather than installing CMake mannually,
    Please let apt take care of it.

    Just rollback whatever changes you've done.
    Simply type sudo apt install cmake on your terminal.

    and you're ready to use CMake since apt takes care of all dependencies installations and environment variable settings.

    I hope, this will help.

    0 讨论(0)
  • 2021-01-19 10:41

    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

    • Ask Ubuntu: How do I install the latest version of cmake from the command line?
    0 讨论(0)
提交回复
热议问题