Skip to content

Instantly share code, notes, and snippets.

@wcaune
Forked from fscm/install_cmake.md
Last active June 21, 2024 14:34
Show Gist options
  • Save wcaune/67f714f377502ed9b13ace0773461274 to your computer and use it in GitHub Desktop.
Save wcaune/67f714f377502ed9b13ace0773461274 to your computer and use it in GitHub Desktop.
[macOS 14.5] Install CMake 3.29.6

[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:

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. Copy the link for the package version that you want to install from there.

Get the CMake installer package using the following commands:

mkdir ~/Downloads/CMake
curl --silent --location --retry 3 "https://github.com/Kitware/CMake/releases/download/v3.29.6/cmake-3.29.6-macos-universal.dmg" --output ~/Downloads/CMake/cmake-macos.dmg

Mount the image using the following command:

yes | PAGER=cat hdiutil attach -quiet -mountpoint /Volumes/cmake-macos ~/Downloads/CMake/cmake-macos.dmg

Copy the CMake app to the applications folder using the following command:

cp -R /Volumes/cmake-macos/CMake.app /Applications/

Unmount the image using the following command:

hdiutil detach /Volumes/cmake-macos

Add the CMake tool to the PATH using the following command:

sudo "/Applications/CMake.app/Contents/bin/cmake-gui" --install=/usr/local/bin

And the screen shows:

Linked: '/usr/local/bin/cmake' -> '/Applications/CMake.app/Contents/bin/cmake'
Linked: '/usr/local/bin/ctest' -> '/Applications/CMake.app/Contents/bin/ctest'
Linked: '/usr/local/bin/cpack' -> '/Applications/CMake.app/Contents/bin/cpack'
Linked: '/usr/local/bin/cmake-gui' -> '/Applications/CMake.app/Contents/bin/cmake-gui'
Linked: '/usr/local/bin/ccmake' -> '/Applications/CMake.app/Contents/bin/ccmake'

Verify

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

cmake --version

We got:

cmake version 3.29.6

CMake suite maintained and supported by Kitware (kitware.com/cmake).

Clean up

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

rm -rf ~/Downloads/CMake
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment