ubuntu 安装/升级 cmake (& cmake-gui)

尹乐邦
2023-12-01

一. cmake-gui需要 qt4,需要先安装qt4

sudo apt-get install qt4*

有时候需要qt4,qt5共存,设置默认qt版本的方法:
1.查看系统已安装的qt

ls -l /usr/lib/x86_64-linux-gnu/qt*

显示如下:

/usr/lib/x86_64-linux-gnu/qt4:
total 12
drwxr-xr-x  2 root root 4096 8月  22 19:10 bin
drwxr-xr-x  3 root root 4096 8月  22 19:09 imports
drwxr-xr-x 16 root root 4096 5月  17  2018 plugins

/usr/lib/x86_64-linux-gnu/qt5:
total 16
drwxr-xr-x  2 root root 4096 7月  20  2016 bin
drwxr-xr-x  2 root root 4096 7月  20  2016 libexec
drwxr-xr-x 16 root root 4096 7月  20  2016 plugins
drwxr-xr-x 11 root root 4096 7月  20  2016 qml

/usr/lib/x86_64-linux-gnu/qtchooser:
total 0
lrwxrwxrwx 1 root root 50 5月  17  2018 4.conf -> ../../../share/qtchooser/qt4-x86_64-linux-gnu.conf
lrwxrwxrwx 1 root root 50 2月  12  2019 5.conf -> ../../../share/qtchooser/qt5-x86_64-linux-gnu.conf
lrwxrwxrwx 1 root root 50 4月   5  2016 default.conf -> ../../../share/qtchooser/qt4-x86_64-linux-gnu.conf
lrwxrwxrwx 1 root root 50 5月  17  2018 qt4.conf -> ../../../share/qtchooser/qt4-x86_64-linux-gnu.conf
lrwxrwxrwx 1 root root 50 2月  12  2019 qt5.conf -> ../../../share/qtchooser/qt5-x86_64-linux-gnu.conf

/usr/lib/x86_64-linux-gnu/qt-default:
total 4
drwxr-xr-x 2 root root 4096 7月  20  2016 qtchooser
frizy@frizy:~$ cat /usr/lib/x86_64-linux-gnu/qt-default/
cat: /usr/lib/x86_64-linux-gnu/qt-default/: Is a directory
frizy@frizy:~$ cat /usr/lib/x86_64-linux-gnu/qt-default/qtchooser/default.conf 
/usr/lib/x86_64-linux-gnu/qt4/bin
/usr/lib/x86_64-linux-gnu
frizy@frizy:~$ ls -l /usr/lib/x86_64-linux-gnu/qt*
/usr/lib/x86_64-linux-gnu/qt4:
total 12
drwxr-xr-x  2 root root 4096 8月  22 19:10 bin
drwxr-xr-x  3 root root 4096 8月  22 19:09 imports
drwxr-xr-x 16 root root 4096 5月  17  2018 plugins

/usr/lib/x86_64-linux-gnu/qt5:
total 16
drwxr-xr-x  2 root root 4096 7月  20  2016 bin
drwxr-xr-x  2 root root 4096 7月  20  2016 libexec
drwxr-xr-x 16 root root 4096 7月  20  2016 plugins
drwxr-xr-x 11 root root 4096 7月  20  2016 qml

/usr/lib/x86_64-linux-gnu/qtchooser:
total 0
lrwxrwxrwx 1 root root 50 5月  17  2018 4.conf -> ../../../share/qtchooser/qt4-x86_64-linux-gnu.conf
lrwxrwxrwx 1 root root 50 2月  12  2019 5.conf -> ../../../share/qtchooser/qt5-x86_64-linux-gnu.conf
lrwxrwxrwx 1 root root 50 4月   5  2016 default.conf -> ../../../share/qtchooser/qt4-x86_64-linux-gnu.conf
lrwxrwxrwx 1 root root 50 5月  17  2018 qt4.conf -> ../../../share/qtchooser/qt4-x86_64-linux-gnu.conf
lrwxrwxrwx 1 root root 50 2月  12  2019 qt5.conf -> ../../../share/qtchooser/qt5-x86_64-linux-gnu.conf

/usr/lib/x86_64-linux-gnu/qt-default:
total 4
drwxr-xr-x 2 root root 4096 7月  20  2016 qtchooser

查看默认的qt版本:

cat /usr/lib/x86_64-linux-gnu/qt-default/qtchooser/default.conf

显示如下:

/usr/lib/x86_64-linux-gnu/qt4/bin
/usr/lib/x86_64-linux-gnu

更改 /usr/lib/x86_64-linux-gnu/qt-default/qtchooser/default.conf 里第一行qt4 / qt5 切换默认的qt版本。

二.下载cmake源码

https://cmake.org/download/
Unix/Linux Source (has \n line feeds)

三.卸载旧版本cmake

sudo apt-get remover cmake*

四.编译安装新版本

tar xvf cmake-3.*.tar.gz
cd cmake-3.*
./configure --qt-gui
make -j4
sudo make install

四.检查

cmake --version
cmake-gui --version
 类似资料: