8

Using CLion on Windows (a C++ IDE), I'd like to install the latest version of cmake on Ubuntu 18.04.3 LTS run via WSL (the current version of CLion requires cmake > 3.15, while I have only version 3.10.2 installed).

Following cmake installation instructions found in a related answer, an error occurs when bootstrapping CMake (first step in A-3 in linked answer):

-- Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the system variable OPENSSL_ROOT_DIR (missing: OPENSSL_CRYPTO_LIBRARY) (found version "1.1.1")
CMake Error at Utilities/cmcurl/CMakeLists.txt:454 (message):
Could not find OpenSSL.  Install an OpenSSL development package or
configure CMake with -DCMAKE_USE_OPENSSL=OFF to build without OpenSSL.

-- Configuring incomplete, errors occurred!

I have already installed libssl-dev as recommended in another cmake-related thread.

Any ideas on how this issue can be fixed?

2 Answers 2

18

I ran into the same problem last year. My solution was this:

run the following in your WSL terminal

sudo apt-get update
sudo apt-get install apt-transport-https ca-certificates gnupg software-properties-common wget

After that is finished

wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | sudo apt-key add -

Next add the updated repository by typing in the following

sudo apt-add-repository 'deb https://apt.kitware.com/ubuntu/ bionic main'
sudo apt-get update

Finally

sudo apt-get install cmake

And it should be updated to the latest version.

Note: if the above doesn't work, be very careful when trying the below steps. It is not elegant, it is not clean, but it does work.

If this does not work. Go to https://cmake.org/download/ and download the Latest Ubuntu version. If you have a folder where you maintain all your projects I suggest downloading the file into your top most directory where your projects are.

For example all my projects are in a folder called "Github" so I would download the file into my "Github" Folder. If there is not a top level directory create a cmake folder in the C drive or what ever drive you save your projects to.

Next after its finished downloading Extract the file (through winrar/winzip/7zip/ or terminal) into that same directory. Once extracted cd into the folder (cmake-{version number}) and do the following commands.

cmake .
make
make install

This will make the latest version of cmake and then install the required components. It can take a while to have everything build and installed.

Once that is done you are going to want to locate the /bin/ folder inside your cmake folder. Make sure a file called "cmake" is in this folder. Copy the path of this directory and type the following

sudo nano ~/.bash_aliases

You can use vi or vim or whatever text editor you want from within the terminal. At the end of the file type the following

alias cmake="{PATH to /bin/ folder}/cmake"

Make sure if you copied the path from windows explorer you replace \ with / save the file and exit.

Restart your terminal and type

cmake --version

It should show up with whichever version you just downloaded.

Congrats you now have the updated version of cmake.

As per the comment by John, this is version specific, these exact same directions (for the first method at least) are available here for the latest version of CMake.

1
  • 3
    Since the above is version-specific, here's a link to the updated directions from kitware: apt.kitware.com
    – John
    Feb 19, 2021 at 16:30
2

I tried to install CMAKE in my WSL and I had the similar problem at the bootstrap stage as well, but this error disappeared once I installed the OpenSSL by using the command in the terminal:

sudo apt-get install libssl-dev

It seems to me the most likely reason in your case is that the OpenSSL package hasn't been properly installed. To test if it is that case, perhaps you could have a look at this answer.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .