Details
-
Bug
-
Resolution: Done
-
P3: Somewhat important
-
Qt Creator 4.3.0
Description
Please see the attached demo project. Make sure that you are using cmake < 3.7 (I tested without server mode, just to eliminate another source of errors).
The following steps (assuming the demo project) reproduce the issue:
- Run (manually) cmake . in the extracted tests directory (make sure to use make as generator)
- Open the project in Qt-Creator and choose a new kit (not the detected temporary one) and use a kit with ninja as generator.
Trying to run this will result in:
Running "/home/florian/sources/cmake-3.6.3-Linux-x86_64/bin/cmake /home/florian/sources/cmake-3.6.3-Linux-x86_64/tests '-GCodeBlocks - Ninja' -DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_CXX_COMPILER:STRING=/usr/bin/clang++ -DCMAKE_C_COMPILER:STRING=/usr/bin/clang '-DCMAKE_PREFIX_PATH:STRING=%{Qt:QT_INSTALL_PREFIX}' -DQT_QMAKE_EXECUTABLE:STRING=" in /tmp/QtCreator-FlUb1d/qtc-cmake-XXzad8pP.
CMake Error: Error: generator : Ninja
Does not match the generator used previously: Unix Makefiles
Either remove the CMakeCache.txt file and CMakeFiles directory or choose a different binary directory.
*** cmake process exited with exit code 1.
This error message makes absolute sense since cmake detects the existing CMakeCache.txt and tries to reuse it, but the enduser might not realize that the source directory is at fault.
I'd like to suggest the error message to be improved for the case where a CmakeCache.txt or CMakeFiles already exists in the source directory (since it is not going to end well in any case) – or maybe flat out refuse to operate if the source directory is configured and one tries an out of source build.
To make matters worse:
- Change the generator to Unix Makefiles without extra generator and try to rerun cmake. It will work fine but will write the build files to the (existing) source configuration:
Running "/home/florian/sources/cmake-3.6.3-Linux-x86_64/bin/cmake /home/florian/sources/cmake-3.6.3-Linux-x86_64/tests '-GUnix Makefiles' -DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_CXX_COMPILER:STRING=/usr/bin/clang++ -DCMAKE_C_COMPILER:STRING=/usr/bin/clang '-DCMAKE_PREFIX_PATH:STRING=%{Qt:QT_INSTALL_PREFIX}' -DQT_QMAKE_EXECUTABLE:STRING=" in /tmp/QtCreator-FlUb1d/qtc-cmake-XXzad8pP. -- The C compiler identification is Clang 3.8.1 -- The CXX compiler identification is Clang 3.8.1 -- Check for working C compiler: /usr/bin/clang -- Check for working C compiler: /usr/bin/clang -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Detecting C compile features -- Detecting C compile features - done -- Check for working CXX compiler: /usr/bin/clang++ -- Check for working CXX compiler: /usr/bin/clang++ -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Detecting CXX compile features -- Detecting CXX compile features - done -- Configuring done -- Generating done -- Build files have been written to: /home/florian/sources/cmake-3.6.3-Linux-x86_64/tests CMake Warning: Manually-specified variables were not used by the project: CMAKE_PREFIX_PATH QT_QMAKE_EXECUTABLE
If you restart QtC now it will obviously not find a Cache in the configured build dir and running CMake does not help either. The clue ends up in the general messages:
-- Build files have been written to: /home/florian/sources/cmake-3.6.3-Linux-x86_64/tests
Note: None of this is an actual/real bug in QtC or CMake (maybe the latter since CMake does not allow you to specify source & build dir but only one and tries to be clever.), but the user experience could be better, especially for newcomers who are messing around and execute cmake in the wrong locations or whatnot.