Home > database >  How can I install a specific version of CMake with WSL on Windows
How can I install a specific version of CMake with WSL on Windows

Time:10-17

I installed CMake with the command :

sudo apt-get -y install cmake

But when I tried to Configure a WSL toolchain for my project in clion I have a message saying that my version is not supported.

My version is 3.24.1 and the supported is between 2.8 - 3.20.

Can I have the solution to my problem so I can downgrade the version?

CodePudding user response:

  1. Download the x86_64 .tar.gz package for Linux from the binary distributions section on the download page, e.g. version 3.24.2: ( https://github.com/Kitware/CMake/releases/download/v3.24.2/cmake-3.24.2-linux-x86_64.tar.gz ).

  2. Unpack the archive to a suitable location on the wsl file system. You can make use of the fact that you can access the file system of the Windows host via /mnt/<lowercase drive letter>/....

    sudo mkdir /opt
    sudo tar xz -f /mnt/c/Users/Joki004/Downloads/cmake-3.24.2-linux-x86_64.tar.gz -C /opt
    
  3. All you need to do is make sure the cmake command uses the cmake program from the bin directory of the unpacked archive. You could skip this step, if you want to use the path to the binary.

    To do this you could add the following line to the end of ~/.bashrc

    export PATH=/opt/cmake-3.24.2-linux-x86_64/bin:$PATH
    

    (The line differs depending on the version of CMake you installed.)

    echo "export PATH=/opt/$(ls /opt | grep -m 1 cmake)/bin:\$PATH" >> ~/.bashrc
    
  4. Reopen the WLS terminal or source ~/.bashrc.

    . ~/.bashrc
    
  5. Check, if the process was successful:

    cmake --version
    

Note: There's a good change CLion allows you to specify the path to the cmake executable via settings, so you may want to replace steps 3 to 5 with modifying CLion settings.

  • Related