一. 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