Skip to content

Instantly share code, notes, and snippets.

@fscm
Last active July 1, 2026 21:27
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
@ipyana

ipyana commented Jul 25, 2023

Copy link
Copy Markdown

Thank you very much

@Tongyuang

Copy link
Copy Markdown

Thanks

@mvn-chienhoang-hn

Copy link
Copy Markdown

Tks

@itsmusician

Copy link
Copy Markdown

Thank you!

@aavash23

Copy link
Copy Markdown

thanks worked like a charm

@vanessachung97

Copy link
Copy Markdown

Great help. Thanks a lot!!

@ferant

ferant commented Feb 15, 2024

Copy link
Copy Markdown

Awesome! Thank you!!

@shinhookang

Copy link
Copy Markdown

Thank you!

@Khilud

Khilud commented Mar 20, 2024

Copy link
Copy Markdown

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

fscm commented Mar 20, 2024

Copy link
Copy Markdown
Author

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.

@andres-navarrete

Copy link
Copy Markdown

Thanks mate!

@hnxsad

hnxsad commented Jun 3, 2024

Copy link
Copy Markdown

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

aneniex commented Jul 12, 2024

Copy link
Copy Markdown

love

@Daydream0929

Copy link
Copy Markdown

good, thanks~

@nbesoro

nbesoro commented Aug 14, 2024

Copy link
Copy Markdown

thanks!

@Neta1910

Copy link
Copy Markdown

Great tutorial,
Thank you!

@SP2610

SP2610 commented Oct 6, 2024

Copy link
Copy Markdown

Thank you!!

@5JM

5JM commented Nov 22, 2024

Copy link
Copy Markdown

thanks :)

@sumitbhuia

Copy link
Copy Markdown

Love you man ;)

@sammarxz

Copy link
Copy Markdown

Thank you!

@loufi04

loufi04 commented Feb 2, 2025

Copy link
Copy Markdown

thank you

@sgshor

sgshor commented Feb 7, 2025

Copy link
Copy Markdown

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

@reginaldojunior

Copy link
Copy Markdown

Perfect bro! Thanks ;)

@mjolnerd

mjolnerd commented Jul 1, 2026

Copy link
Copy Markdown

Appreciate you. That got me moving on a little whimsical project quickly!

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