[Interest] Rebuilding cmake project (in Qt Creator) fails - build directories write-protected?

Till Oliver Knoll till.oliver.knoll at gmail.com
Tue Jan 5 20:09:33 CET 2021


Am 31.12.20 um 16:02 schrieb Till Oliver Knoll:
> Am 31.12.20 um 15:29 schrieb James DeLisle:
>>
>> There are some on-going peculiarities with CMake and translation
>> files, as evidenced here:
>>
>> https://bugreports.qt.io/browse/QTBUG-76410
>> <https://bugreports.qt.io/browse/QTBUG-76410>
>>
> Thanks for your reply! In fact, the problem is not only related to
> translation files (but it occurs there first during a build). In fact,
> I "commented out" the generation of translation (*.ts) files and the
> problem also occured later on during a "rebuild" (at least with my
> actual project).
>

Oh dear: the problem also occurs on macOS 10.14 "Mojave", with a simple
"Qt Widgets application" (as generated from scratch by Qt Creator, with
a single QMainWindow and a translation file (as added by the "New
project" wizard using Cmake):

19:42:58: Führe Schritte für Projekt MainWindow aus...
19:42:58: Starte:
"/Users/tknoll/Qt/Tools/CMake/CMake.app/Contents/bin/cmake" --build .
--target all
[1/5 13.6/sec] Generating
/Users/tknoll/resources/work/Qt/MainWindow/MainWindow_de_DE.ts
FAILED: /Users/tknoll/resources/work/Qt/MainWindow/MainWindow_de_DE.ts
CMakeFiles/MainWindow_de_DE.ts_lst_file
cd
/Users/tknoll/resources/work/Qt/build-MainWindow-Desktop_Qt_5_15_2_clang_64bit-Debug
&& /Users/tknoll/Qt/5.15.2/clang_64/bin/lupdate
@/Users/tknoll/resources/work/Qt/build-MainWindow-Desktop_Qt_5_15_2_clang_64bit-Debug/CMakeFiles/MainWindow_de_DE.ts_lst_file
-ts /Users/tknoll/resources/work/Qt/MainWindow/MainWindow_de_DE.ts
lupdate error: List file
'/Users/tknoll/resources/work/Qt/build-MainWindow-Desktop_Qt_5_15_2_clang_64bit-Debug/CMakeFiles/MainWindow_de_DE.ts_lst_file'
is not readable.
ninja: build stopped: subcommand failed.
19:42:58: Der Prozess
"/Users/tknoll/Qt/Tools/CMake/CMake.app/Contents/bin/cmake" wurde mit
dem Rückgabewert 1 beendet.
Fehler beim Erstellen/Deployment des Projekts MainWindow (Kit: Desktop
Qt 5.15.2 clang 64bit)
Bei der Ausführung von Schritt "Erstellen"
19:42:58: Verstrichene Zeit: 00:00.


Again the same as on Windows:

  FAILED: /Users/tknoll/resources/work/Qt/MainWindow/MainWindow_de_DE.ts
CMakeFiles/MainWindow_de_DE.ts_lst_file 


$> ls -la
total 200
drwxr-xr-x  11 tknoll  staff    352  5 Jan 19:49 .
drwxr-xr-x  15 tknoll  staff    480  4 Jan 17:41 ..
drwxr-xr-x   3 tknoll  staff     96  4 Jan 17:35 .cmake
-rw-r--r--   1 tknoll  staff  40536  5 Jan 19:48 .ninja_deps
-rw-r--r--   1 tknoll  staff   1613  5 Jan 19:49 .ninja_log
-rw-r--r--   1 tknoll  staff  13589  5 Jan 19:48 CMakeCache.txt
drwxr-xr-x  11 tknoll  staff    352  5 Jan 19:49 CMakeFiles
drwxr-xr-x   3 tknoll  staff     96  4 Jan 17:59 MainWindow.app
drwxr-xr-x   8 tknoll  staff    256  5 Jan 19:49 MainWindow_autogen
-rw-r--r--   1 tknoll  staff  33441  5 Jan 19:48 build.ninja
-rw-r--r--   1 tknoll  staff   1562  4 Jan 17:35 cmake_install.cmake

Now at this point I don't see anything special about the CMakeFiles
directory (located in the "build" directory). In fact - unlike as on
Windows 10 - I can delete the entire
build-MainWindow-Desktop_Qt_5_15_2_clang_64bit-Debug folder without
problems.

Of at this point there is no MainWindow_de_DE.ts_lst_file in that directory:


$> ls -la
total 64
drwxr-xr-x  11 tknoll  staff    352  5 Jan 19:51 .
drwxr-xr-x  11 tknoll  staff    352  5 Jan 19:51 ..
drwxr-xr-x   6 tknoll  staff    192  5 Jan 19:51 3.19.0
-rw-r--r--   1 tknoll  staff  15382  5 Jan 19:51 CMakeOutput.log
drwxr-xr-x   2 tknoll  staff     64  5 Jan 19:51 CMakeTmp
drwxr-xr-x   3 tknoll  staff     96  5 Jan 19:51 MainWindow.dir
drwxr-xr-x   5 tknoll  staff    160  5 Jan 19:51 MainWindow_autogen.dir
-rw-r--r--   1 tknoll  staff    589  5 Jan 19:51 TargetDirectories.txt
-rw-r--r--   1 tknoll  staff    287  5 Jan 19:51 clean_additional.cmake
-rw-r--r--   1 tknoll  staff     85  5 Jan 19:51 cmake.check_cache
-rw-r--r--   1 tknoll  staff   2415  5 Jan 19:51 rules.ninja

That explains the "not readable" (follow-up) error message then.

Or in other words: the generated CMakeLists.txt (generated by Qt Creator
4.14.0) simply does not work, neither on Windows nor on macOS (at least
not on Mojave".

There is no other cmake in the PATH (I specifically uninstalled an older
version with "brew uninstall cmake". In fact, there is no cmake at all
in the PATH right now (I am exclusively building from within Qt Creator
for the time being).

Now at this point, if I do:

* Clear CMake configuration

* Run CMake

and build again (with CTRL / CMD + B) then it works with the translation
file:

20:00:54: Running steps for project MainWindow...
20:00:54: Starting:
"/Users/tknoll/Qt/Tools/CMake/CMake.app/Contents/bin/cmake" --build .
--target all
[1/6 2.5/sec] Automatic MOC and UIC for target MainWindow
[2/6 4.4/sec] Generating
/Users/tknoll/resources/work/Qt/MainWindow/MainWindow_de_DE.ts
Scanning directory '/Users/tknoll/resources/work/Qt/MainWindow'...
Updating '../MainWindow/MainWindow_de_DE.ts'...
    Found 1 source text(s) (1 new and 0 already existing)
[3/6 1.1/sec] Building CXX object
CMakeFiles/MainWindow.dir/MainWindow_autogen/mocs_compilation.cpp.o
[4/6 1.4/sec] Building CXX object CMakeFiles/MainWindow.dir/MainWindow.cpp.o
[5/6 1.7/sec] Building CXX object CMakeFiles/MainWindow.dir/main.cpp.o
[6/6 2.0/sec] Linking CXX executable
MainWindow.app/Contents/MacOS/MainWindow

But lo and behold: on macOS the simple "MainWindow" app does not even link!

  Undefined symbols for architecture x86_64:
  "std::terminate()", referenced from:
      ___clang_call_terminate in MainWindow.cpp.o


(etc.)

It turns out that an added

target_link_options(MainWindow PRIVATE -lc++)

links against the - apparently "forgotten" - C++ library and the
application links and runs properly.

I have also looked at the above issue by now, which seems to be a
problem with CMake projects also deleting the *.ts files when doing a
"clean project". So there might be some connection...


All this leaves me think that the whole CMake integration is still a big
construction site, at least as far as Qt 5.15.2 and latest Qt Creator is
concerned (btw the reaons why I stayed with Qt 5.15 for now - and not Qt
6 - is because I wanted to keep "the numbers of unknowns low". The new
"unknown" being CMake for me obviously).

Does anyone have more luck with CMake, at least with Qt 6 perhaps? It
seems I have to dig into the CMake documentation more closely than I
intended to after all and apply all the *tricks with CMake and Qt*
spread all over the Internet *sigh*... ;)


Thanks,
  Oliver

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20210105/5e616114/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_signature
Type: application/pgp-signature
Size: 203 bytes
Desc: OpenPGP digital signature
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20210105/5e616114/attachment.sig>


More information about the Interest mailing list