14

I tried downloading https://cmake.org/files/v3.11/cmake-3.11.0.tar.gz and building it, but there is no cmake-gui in ./bin subfolder after build. Is cmake-gui supplied in another source archive?

1

5 Answers 5

6

Two options here:

  • cmake-gui is packaged as cmake-qt-gui. Install it with:

    sudo apt-get install cmake-qt-gui
    
  • If you really need to build it from source do the following:

    sudo apt-get update
    sudo apt-get build-dep cmake-qt-gui
    wget https://cmake.org/files/v3.11/cmake-3.11.0.tar.gz
    
    tar -xzf cmake-3.11.0.tar.gz
    cd cmake-3.11.0/
    ./configure --qt-gui
    make -j5
    bin/cmake-gui
    
3
  • 2
    No, packages contain outdated cmake, which doesn't support boost 1.66 for example...
    – stiv
    Mar 29, 2018 at 8:46
  • 5
    Installing cmake-qt-gui with apt after having compiled cmake from sources would lead to the following kind of error: Some packages could not be installed. This may mean that you have requested an impossible situation or if you are using the unstable distribution that some required packages have not yet been created or been moved out of Incoming. The following information may help to resolve the situation: The following packages have unmet dependencies: cmake-qt-gui : Depends: cmake (= 3.5.1-1ubuntu3) E: Unable to correct problems, you have held broken packages.
    – s.k
    Aug 23, 2018 at 6:39
  • this fails because of: By not providing "FindQt5Widgets.cmake" in CMAKE_MODULE_PATH this project has asked CMake to find a package configuration file provided by "Qt5Widgets", but CMake did not find one.
    – stiv
    Feb 11, 2021 at 20:17
3

tested with cmake 3.20.1 on ubuntu 18.04 LTS

check installation of Qt5 before compiling (sudo apt install qt5-default)

if you already have cmake of lower version

cd cmake-3.20.1
mkdir build
cd build
cmake -D BUILD_QtDialog=ON ..
make -j2
sudo apt remove cmake # remove current cmake
sudo make install

else if no cmake in your system

cd cmake-3.20.1
./bootstrap --qt-gui
make -j2
sudo make install
2

Nothing else depends on cmake (probably) so it's a leaf node. Uninstall the deb. Get the latest source from https://cmake.org/ and unpack the tarball somewhere, cd into it.

./bootstrap --qt-gui
make
make install

Assuming you have the QT dev stuff installed. You end up with both regular command-line cmake and cmake-qui. Start them from the command line by typing cmake or cmake-gui, I don't know about adding to menus.

0
1

Just in case you can't build cmake-gui because of problems with QT5 widgets, try the following:

apt install qt5-default

0

Process

  • In this particular process I decided to configure the latest version of cmake, with the apt version of cmake (sorry if this is confusing).

  • cmake-gui is compiled with the same repository as the cmake command line tool, but the default build configuration for cmake is not set up to build cmake-gui (neither the curses interface or the Qt interface).

  • To build cmake with cmake-gui, it's necessary to set some variables in the cmake build script. You might normally do this through the UI, but it's also possible to set these variables by manually editing CMakeCache.txt in the build directory, which is what I will show how to do in this answer.

  • CMake requires Qt, but it can't find it automatically, one of the things we need to do is show where the Qt CMake scripts are.

1. Install Qt (if you don't have it already)

  • Download the installer from Qt's website. In my case, I selected the latest version of 5.12 (at the time of writing, 5.12.7) and I installed it with all default settings.

  • You'll need to make an account with Qt to download the installer using this method; the account is free for open source users (which you are if you are using this to just build cmake for your own use; if you plan on using Qt for anything else you should verify if you can use this version).

  • I installed Qt to a folder named Qt in my home directory.

  • This installation process will take a while.

  • I think Qt might be available through apt, but for my purposes I needed the full download for another project, so I had it here anyway.

2. git clone the cmake sources from their git repository to somewhere (e.g., your home directory).

git clone https://gitlab.kitware.com/cmake/cmake.git

3. Make a build directory

cd cmake
mkdir build
cd build
cmake ..

That will, among other things, place a file named CMakeCache.txt in your build folder.

4. Edit CMakeCache.txt to configure the ui

  • Open this file in your text editor, and edit the following lines to enable the qt ui (I found these by searching for qt).

  • Note that you need to replace with where your qt directory is, in my case was just /home/jrh/Qt5.12.11.

  • For example the Qt5Core_DIR directory for me (running Qt 5.12.11) was /home/jrh/Qt5.12.11/5.12.11/gcc_64/lib/cmake/Qt5Core

  • I would advise against using relative paths or ~.

//Build Qt dialog for CMake
BUILD_QtDialog:BOOL=ON

QT_QMAKE_EXECUTABLE:FILEPATH=<path to Qt>/<qt version>/gcc_64/bin/qmake

//The directory containing a CMake configuration file for Qt5Core.
Qt5Core_DIR:PATH=<path to Qt>/<qt version>/gcc_64/lib/cmake/Qt5Core

//The directory containing a CMake configuration file for Qt5Widgets.
Qt5Widgets_DIR:PATH=<path to Qt>/<qt version>/gcc_64/lib/cmake/Qt5Widgets

//The directory containing a CMake configuration file for Qt5.
//FYI: This folder should contain a file named Qt5Config.cmake
Qt5_DIR:PATH=<path to Qt>/<qt version>/gcc_64/lib/cmake/Qt5

5. Re-run cmake .. in the build directory

cmake ..

6. Compile cmake (in the build directory)

Where N is the number of cores you want to compile, in my case I typed make -j10.

make -jN

7. Install the built cmake

  • You may be tempted to remove the apt version of cmake before doing this, but it appears that (for some reason), the install part of the cmake requires cmake to be installed to... install cmake.
sudo make install

8. Final operations

  • sudo make install does not replace the version of cmake stored in /usr/bin, unfortunately.

  • There may be a cleaner way to accomplish this step.

  • Use cmake --version to verify if you need to do this, if it gives the version that came with apt (for me at the time of writing, 3.10.2), you will need to do this.

  • You should also verify that your version of cmake is in /usr/local/bin/

I needed to do the following:

Rename the apt installed cmake binary

sudo mv /usr/bin/cmake /usr/bin/cmake_old

Link our built version of cmake into /usr/bin/

sudo ln -s /usr/local/bin/cmake /usr/bin/cmake
  • I was not expecting to need to link the new version of cmake into /usr/bin/, since /usr/local/bin should be in PATH; for some reason, it would stubbornly only look for cmake in /usr/bin, and give me an error saying that /usr/bin/cmake was not found even though the latest version of cmake was available in /usr/local/bin.

  • I guess it's possible that a reset of bash or a reboot could have fixed the need for linking, but I am not sure.

Type cmake-gui to start the UI

A screenshot of cmake-gui

Cool!

Notes

  • Tested on Ubuntu Mate 18.04.1 x86_64
  • Cmake version I am trying to install: this commit, there's no particular significance to this, I just cloned the latest. I also used this for CMake 3.23.2 which was the latest stable version as of the time of this edit (5/26/22).
  • I originally wrote this guide for Qt 5.12.7, I am not sure if it's just a coincidence or not, but when I tried it with Qt 5.12.11 the only thing I had to change was in that version I also had to set Qt5_DIR.
  • CMake provides a ./configure script in addition to the "build cmake with cmake" option but since the configure script just pretty much runs cmake anyway, I don't think there is much point in going that route.
  • If you started out this process by running the ./configure route, note that it appears to set the build directory to the root of the source code directory. The good news is that you do not need to start the build over if you started with ./configure, CMakeCache.txt should be present in the root of the source code directory, and you can edit it then continue with the instructions as documented in this post.
  • It's my opinion that this method should work if you are using the apt version of cmake to configure the latest version of cmake during this entire process. If this doesn't work, let me know in the comments.
  • In my case (like the OP), I am looking to go back and build cmake-gui after already installing building the latest version of cmake from source.
  • Thus, in the (IMO unlikely) chance that the part of the script that builds cmake-gui needs the latest version of cmake to build cmake, but the rest of the build was OK with the apt version, to exactly replicate the steps I did here, you could build cmake with the apt version, then re-configure with the latest built version of cmake, and build again.
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .