Skip to content

Instantly share code, notes, and snippets.

@ctracerpp
Forked from fscm/install_cmake.md
Created March 18, 2024 02:42

Revisions

  1. @fscm fscm revised this gist Dec 14, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion install_cmake.md
    Original file line number Diff line number Diff line change
    @@ -23,7 +23,7 @@ Get the CMake installer package using the following commands:

    ```sh
    mkdir ~/Downloads/CMake
    curl --silent --location --retry 3 "https://github.com/Kitware/CMake/releases/download/v3.18.4/cmake-3.18.4-Darwin-x86_64.dmg" --output ~/Downloads/CMake/cmake-Darwin-x86_64.dmg
    curl --silent --location --retry 3 "https://github.com/Kitware/CMake/releases/download/v3.19.1/cmake-3.19.1-Darwin-x86_64.dmg" --output ~/Downloads/CMake/cmake-Darwin-x86_64.dmg
    ```

    Mount the image using the following command:
  2. @fscm fscm created this gist Nov 8, 2020.
    64 changes: 64 additions & 0 deletions install_cmake.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,64 @@
    # [macOS] Install CMake

    Instructions on how to install the CMake tool on macOS.

    ## Uninstall

    First step should be to unsinstall any previous CMake installation. This step
    can be skipped if no CMake version was previously installed.

    To uninstall any previous CMake installations use the following commands:

    ```sh
    sudo find /usr/local/bin -type l -lname '/Applications/CMake.app/*' -delete
    sudo rm -rf /Applications/CMake.app
    ```

    ## Install

    The CMake tool can be obtained [here](https://cmake.org/download//).
    Copy the link for the package version that you want to install from there.

    Get the CMake installer package using the following commands:

    ```sh
    mkdir ~/Downloads/CMake
    curl --silent --location --retry 3 "https://github.com/Kitware/CMake/releases/download/v3.18.4/cmake-3.18.4-Darwin-x86_64.dmg" --output ~/Downloads/CMake/cmake-Darwin-x86_64.dmg
    ```

    Mount the image using the following command:
    ```sh
    yes | PAGER=cat hdiutil attach -quiet -mountpoint /Volumes/cmake-Darwin-x86_64 ~/Downloads/CMake/cmake-Darwin-x86_64.dmg
    ```

    Copy the CMake app to the applications folder using the following command:
    ```sh
    cp -R /Volumes/cmake-Darwin-x86_64/CMake.app /Applications/
    ```

    Unmount the image using the following command:
    ```sh
    hdiutil detach /Volumes/cmake-Darwin-x86_64
    ```

    Add the CMake tool to the PATH using the following command:
    ```sh
    sudo "/Applications/CMake.app/Contents/bin/cmake-gui" --install=/usr/local/bin
    ```

    ## Verify

    Open a new terminal window and check if the CMake tool is installed:

    ```sh
    cmake --version
    ```

    ## Clean up

    After installing the CMake tool you can remove the downloaded installation
    image using the following command:

    ```sh
    rm -rf ~/Downloads/CMake
    ```