KK2491
KK2491

Reputation: 508

cmake and /opt/cmake/bin/cmake showing different version

I am quite new to C++ programming and cmake. Kindly bear with me if the question seems simple.

I am building an application for which cmake 3.9.0 is the minimum version required.

Setup.sh: Building rpclib with libc++.
CMake Error at CMakeLists.txt:1 (cmake_minimum_required):
  CMake 3.9.0 or higher is required.  You are running version 3.5.1

So I planned to upgrade the cmake version and followed the below link.

cmake_installation

Note : Just to be clear, I don't want to purge the existing version as it might affect the ROS environment in my system.

I have completed the installation and results given below.

When I run cmake -version:

kk@kk-Lenovo-ideapad-320-15ISK:~/cmake-3.9.0$ cmake -version 
cmake version 3.5.1

CMake suite maintained and supported by Kitware (kitware.com/cmake).
kk@kk-Lenovo-ideapad-320-15ISK:~/cmake-3.9.0$ 

And when I run /opt/cmake/bin/cmake -version

kk@kk-Lenovo-ideapad-320-15ISK:~/cmake-3.9.0$ /opt/cmake/bin/cmake --version
cmake version 3.9.0

CMake suite maintained and supported by Kitware (kitware.com/cmake).
kk@kk-Lenovo-ideapad-320-15ISK:~/cmake-3.9.0$

And issue/error with the application build remains the same as before.

Could you please help me to update cmake or fix this existing version issue.

Thank you

KK

Upvotes: 0

Views: 517

Answers (2)

Benny
Benny

Reputation: 179

@john answer is correct, but it could affect the existing ROS system, as the first entry of the PATH-variable would be used. So you would need to "unexport" the PATH again to the old settings to be save with the ROS system.

Assuming your script "setup.sh" is some kind of build-script, which does build your software with cmake.

You should save the current PATH variable in your script first, like

ORIGINAL_PATH=${PATH}

Now export the new PATH variable as @john already mentioned, like

export PATH=/opt/cmake/bin:${PATH}

After the run of setup.sh (again build-script assumed) you should restore the old PATH-variable, so your build-script does not change the user-global settings.

export PATH=${ORIGINAL_PATH}

Upvotes: 1

john
john

Reputation: 87944

This just sounds like a PATH issue. You've got to change the PATH variable so that Setup.sh finds your cmake before the earlier version. Try this before you run Setup.sh

export PATH=/opt/cmake/bin:$PATH

Upvotes: 1

Related Questions