Skip to content

Instantly share code, notes, and snippets.

@chrisjvz
Created August 16, 2025 03:47
Show Gist options
  • Select an option

  • Save chrisjvz/7490cbfd9ce2139ac1dbe3767bbb37ae to your computer and use it in GitHub Desktop.

Select an option

Save chrisjvz/7490cbfd9ce2139ac1dbe3767bbb37ae to your computer and use it in GitHub Desktop.
Updating and installing latest Cmake in WSL2
# First remove the preinstalled version of cmake via apt
# In my case this was cmake 3.28.3 and my linux distro was Ubuntu 22.04 LTS
sudo apt remove --purge --auto-remove cmake
# Download the install script via https://cmake.org/download/#latest
# I am using a x86_64 system so use wget to download the relevant script
wget https://github.com/Kitware/CMake/releases/download/v4.1.0/cmake-4.1.0-linux-x86_64.sh
# Make sure to add execute priviledges
# NOTE: This priviledge extends to user, group, and others by default
# If you want to specify which just add u+x, updates user with execute priviledge
chmod +x cmake-4.1.0-linux-x86_64.sh
# Ensure sh executable is used to run the script,
# --prefix just sets the base path from where all folder and executables and such will
# be placed, ex. executable will go in [prefix]/bin/
# --exclude-subdir ensure that the installer DOESN'T create an extra version-specific
# folder. If it does, it likely will mess with your systems $PATH
sudo /bin/sh ./cmake-4.1.0-linux-x86_64.sh --prefix=/usr/local --exclude-subdir
# Check if all went well!
cmake --version
# Output: cmake version 4.1.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment