Skip to content

Instantly share code, notes, and snippets.

@fscm
Last active September 14, 2024 13:23
Show Gist options
  • Save fscm/29fd23093221cf4d96ccfaac5a1a5c90 to your computer and use it in GitHub Desktop.
Save fscm/29fd23093221cf4d96ccfaac5a1a5c90 to your computer and use it in GitHub Desktop.
[macOS] Install CMake

[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.28.3/cmake-3.28.3-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

Verify

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

cmake --version

Clean up

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

rm -rf ~/Downloads/CMake
@selimtan
Copy link

Great, thanks

@sebastiangits
Copy link

Thanks so much! Very helpful!

@JerryHamm
Copy link

Thanks this helped alot

@azulnogueraa
Copy link

thank u <3

@ipyana
Copy link

ipyana commented Jul 25, 2023

Thank you very much

@Tongyuang
Copy link

Thanks

@mvn-chienhoang-hn
Copy link

Tks

@itsmusician
Copy link

Thank you!

@aavash23
Copy link

thanks worked like a charm

@vanessachung97
Copy link

Great help. Thanks a lot!!

@ferant
Copy link

ferant commented Feb 15, 2024

Awesome! Thank you!!

@shinhookang
Copy link

Thank you!

@Khilud
Copy link

Khilud commented Mar 20, 2024

while adding to the cmake tool path , its giving me this error sudo: unable to execute /Applications/CMake.app/Contents/bin/cmake-gui: Bad CPU type in executable
Please what should i do

@fscm
Copy link
Author

fscm commented Mar 20, 2024

while adding to the cmake tool path , its giving me this error sudo: unable to execute /Applications/CMake.app/Contents/bin/cmake-gui: Bad CPU type in executable Please what should i do

@Khilud
Make sure that you are using the right .dmg file for your system. If you did not visit the https://cmake.org/download/ site to get the latest installer you may be trying to install the intel binary (the one given as example here) in an arm Mac.

I will update this gist to try to reflect the new CMake universal installer.

@yairandresnavarrete
Copy link

Thanks mate!

@hnxsad
Copy link

hnxsad commented Jun 3, 2024

Thank you ,, it worked

@yongyanghz
Copy link

Great, thanks.

@vitalyster
Copy link

No need in yes | PAGER=cat with latest CMake universal dmgs

@aneniex
Copy link

aneniex commented Jul 12, 2024

love

@Daydream0929
Copy link

good, thanks~

@nbesoro
Copy link

nbesoro commented Aug 14, 2024

thanks!

@Neta1910
Copy link

Great tutorial,
Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment