Skip to content

Instantly share code, notes, and snippets.

@fscm
Last active February 26, 2026 13:02
Show Gist options
  • Select an option

  • Save fscm/29fd23093221cf4d96ccfaac5a1a5c90 to your computer and use it in GitHub Desktop.

Select an option

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/v4.2.3/cmake-4.2.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
@shinhookang
Copy link
Copy Markdown

Thank you!

@Khilud
Copy link
Copy Markdown

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
Copy Markdown
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.

@Andres9104
Copy link
Copy Markdown

Thanks mate!

@hnxsad
Copy link
Copy Markdown

hnxsad commented Jun 3, 2024

Thank you ,, it worked

@yongyanghz
Copy link
Copy Markdown

Great, thanks.

@vitalyster
Copy link
Copy Markdown

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

@aneniex
Copy link
Copy Markdown

aneniex commented Jul 12, 2024

love

@Daydream0929
Copy link
Copy Markdown

good, thanks~

@nbesoro
Copy link
Copy Markdown

nbesoro commented Aug 14, 2024

thanks!

@Neta1910
Copy link
Copy Markdown

Great tutorial,
Thank you!

@SP2610
Copy link
Copy Markdown

SP2610 commented Oct 6, 2024

Thank you!!

@5JM
Copy link
Copy Markdown

5JM commented Nov 22, 2024

thanks :)

@sumitbhuia
Copy link
Copy Markdown

Love you man ;)

@sammarxz
Copy link
Copy Markdown

Thank you!

@loufi04
Copy link
Copy Markdown

loufi04 commented Feb 2, 2025

thank you

@sgshor
Copy link
Copy Markdown

sgshor commented Feb 7, 2025

Still works :)

@arpit3018
Copy link
Copy Markdown

Thanks for the steps! Worked like a charm.

@unfetchable
Copy link
Copy Markdown

Thank you

@AronLenvig
Copy link
Copy Markdown

thank you !

@eramudeep
Copy link
Copy Markdown

Thanks : )

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