Once you have both the cmake and the cmake3 package installed on your machine, you can use update-alternatives to switch between both packages.
Use the alternatives command to register both installations:
$ sudo alternatives --install /usr/local/bin/cmake cmake /usr/bin/cmake 10 \
--slave /usr/local/bin/ctest ctest /usr/bin/ctest \
--slave /usr/local/bin/cpack cpack /usr/bin/cpack \
--slave /usr/local/bin/ccmake ccmake /usr/bin/ccmake \
--family cmake
$ sudo alternatives --install /usr/local/bin/cmake cmake /usr/bin/cmake3 20 \
--slave /usr/local/bin/ctest ctest /usr/bin/ctest3 \
--slave /usr/local/bin/cpack cpack /usr/bin/cpack3 \
--slave /usr/local/bin/ccmake ccmake /usr/bin/ccmake3 \
--family cmake
After these two commands, cmake3 will be invoked by default, when you enter cmake from a bash prompt or start a bash script. The commands also take care of registering a few secondary commands like ctest which need to be switched along with cmake.
If you need to switch back to cmake 2.8 as the default, run the following command:
$ sudo alternatives --config cmake
There are 2 programs which provide 'cmake'.
Selection Command
-----------------------------------------------
1 cmake (/usr/bin/cmake)
*+ 2 cmake (/usr/bin/cmake3)
Enter to keep the current selection[+], or type selection number: 1
Answer from sakra on Stack OverflowOnce you have both the cmake and the cmake3 package installed on your machine, you can use update-alternatives to switch between both packages.
Use the alternatives command to register both installations:
$ sudo alternatives --install /usr/local/bin/cmake cmake /usr/bin/cmake 10 \
--slave /usr/local/bin/ctest ctest /usr/bin/ctest \
--slave /usr/local/bin/cpack cpack /usr/bin/cpack \
--slave /usr/local/bin/ccmake ccmake /usr/bin/ccmake \
--family cmake
$ sudo alternatives --install /usr/local/bin/cmake cmake /usr/bin/cmake3 20 \
--slave /usr/local/bin/ctest ctest /usr/bin/ctest3 \
--slave /usr/local/bin/cpack cpack /usr/bin/cpack3 \
--slave /usr/local/bin/ccmake ccmake /usr/bin/ccmake3 \
--family cmake
After these two commands, cmake3 will be invoked by default, when you enter cmake from a bash prompt or start a bash script. The commands also take care of registering a few secondary commands like ctest which need to be switched along with cmake.
If you need to switch back to cmake 2.8 as the default, run the following command:
$ sudo alternatives --config cmake
There are 2 programs which provide 'cmake'.
Selection Command
-----------------------------------------------
1 cmake (/usr/bin/cmake)
*+ 2 cmake (/usr/bin/cmake3)
Enter to keep the current selection[+], or type selection number: 1
Creating this symbolic link after installing cmake3 on Centos 7 worked for me:
sudo ln -s /usr/bin/cmake3 /usr/bin/cmake
You don't say but what versions are you getting and what versions do you expect?
What repositories do I have?
You can find out what repositories your system is configured to query using this command:
$ yum repolist | expand
Loaded plugins: fastestmirror, priorities, refresh-packagekit
Loading mirror speeds from cached hostfile
* base: centos.mirror.constant.com
* epel: mirror.steadfast.net
* extras: mirror.symnds.com
* updates: bay.uchicago.edu
77 packages excluded due to repository priority protections
repo id repo name status
base CentOS-6 - Base 6,297+70
epel Extra Packages for Enterprise Linux 6 - x86_64 10,246
extras CentOS-6 - Extras 7+7
updates CentOS-6 - Updates 314
repolist: 16,864
Package info
You can query any package whether it's installed or not using yum info <pkg>.
$ yum info cmake
Loaded plugins: fastestmirror, priorities, refresh-packagekit
Loading mirror speeds from cached hostfile
* base: centos.mirror.constant.com
* epel: mirror.steadfast.net
* extras: mirror.symnds.com
* updates: bay.uchicago.edu
77 packages excluded due to repository priority protections
Installed Packages
Name : cmake
Arch : x86_64
Version : 2.6.4
Release : 5.el6
Size : 18 M
Repo : installed
From repo : base
Summary : Cross-platform make system
URL : http://www.cmake.org
License : BSD
Description : CMake is used to control the software compilation process using simple
: platform and compiler independent configuration files. CMake generates
: native makefiles and workspaces that can be used in the compiler
: environment of your choice. CMake is quite sophisticated: it is possible
: to support complex environments requiring system configuration, pre-processor
: generation, code generation, and template instantiation.
Package's URL
You can find out where a RPM is being downloaded from using the repoquery command.
$ repoquery --location cmake
http://centos.mirrors.hoobly.com/6.5/os/x86_64/Packages/cmake-2.6.4-5.el6.x86_64.rpm
Which is part of this repository:
$ repoquery -i cmake | grep Repos
Repository : base
So this is a base repository to the CentOS distro that's providing this package.
What other repositories have it?
You can query what repositories contain a specific package (at least most of the major repos) using pkgs.org.
- http://pkgs.org/search/?query=cmake&type=smart
According to this list the EPEL repo has the latest version pre-built. The version of this package is as follows: cmake 28-2.8.11.2-1.
I needed cmake 2.8 on CentOS 6.5, but my attempts at using yum would also always keep cmake at 2.6 even though I tried adding repos that seemingly contained the correct version. It's kind of hacky, but I was able to get what I needed by executing the following commands as root:
wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
rpm -ivh epel-release-6.8.noarch.rpm
yum install cmake28
cd /usr/bin
mv cmake cmake26
mv ccmake ccmake26
mv cpack cpack26
mv ctest ctest26
ln -s cmake28 cmake
ln -s ccmake28 ccmake
ln -s cpack28 cpack
ln -s ctest28 ctest