I am trying to upgrade cmake on my linux computer. Here is the command I used.
Remove the old cmake:
sudo apt purge --auto-remove cmake
Download and extracted cmake-3.13.3.tar.gz from https://cmake.org/download/
Then in the extracted cmake folder:
./bootstrap
make
sudo make install
when I did cmake --version
it returns
bash: /usr/bin/cmake: No such file or directory
which indicates that no cmake executable exists in /usr/bin
. However when I run which cmake
it returns
/usr/local/bin/cmake
And that does exist.
How do I have the command cmake
point to /usr/local/bin/cmake
?
My $PATH
shows
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
Edit: different from the other question since I know exactly where the cmake executable is just that --version
and which
have different effect.
CMake will use whatever path the running CMake executable is in. Furthermore, it may get confused if you switch paths between runs without clearing the cache. So what you have to do is simply instead of running cmake <path_to_src> from the command line, run ~/usr/cmake-path/bin/cmake <path_to_src> .
The installation directory is usually left at its default, which is /usr/local . Installing software here ensures that it is automatically available to users. It is possible to specify a different installation directory by adding -DCMAKE_INSTALL_PREFIX=/path/to/install/dir to the CMake command line.
CMake is an open-source, cross-platform tool that uses compiler and platform independent configuration files to generate native build tool files specific to your compiler and platform.
In bash you can use hash -r
so that it forgets all remembered locations of previously executed commands.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With