QtCreator v2 doesn't recognize CMake v3

183 views Asked by At

Similar questions on Stack Overflow didn't quite concern this particular problem or didn't provide a solution*.

When importing an existing CMake-project QtCreator keeps asking for path to the cmake executable. Upon entering an incorrect path the entry will be marked in red font. Upon entering the correct path, the font is put back to normal, but the "Next" button will remain disabled. Thus the Import dialog doesn't let the user continue, so one can only cancel the import.

Specific versions used:

  • QtCreator v2.8.1
  • CMake v3.2.2
  • Gentoo Linux (which considers the above package versions as stable and installs them from source-code)

*: Most similar questions was: Importing a CMake project in QtCreator, but no solution was provided. Maybe a bugreport was written, but that was over 2 and a half years ago and the most recent QtCreator v2 is 2.8.1 from almost 2 years ago.

1

There are 1 answers

1
Sigi Schwartz On

I compared the QtCreator source code of v2.8.1 against the most recent v3.4.1, specifically the code for handling this CMake-path dialog and the check for the executable.

Turns out it doesn't just check if the executable exists, but also checks version and feature information provided by the command cmake --help and a couple of other help-commands. Most importantly it checks the CMake version that the output of the cmake --help should provide. But CMake v3 doesn't provide that info anymore like v2 did.

Of course, since all these tools are open source one could modify the QtCreator or CMake source code to fix this issue. Or one could just provide an executable wrapped around the real CMake-executable that just does again provide all required infos.

A little shell-script did the trick for me:

#!/bin/dash
if [ $# -eq 1 ] && [ "--help" = $1 ]; then
    cmake --version
fi
cmake "$@"
exit 0

After configuring QtCreator in menu Tools => Options... => Build & Run => CMake to use the above shell script the project import went flawless.