Fix building with namespaced Qt
ClosedPublic

Authored by davschul on Feb 14 2019, 6:56 AM.

Details

Summary

Add QT_BEGIN/END_NAMESPACE to forward declaration of Qt classes and
add namespace define to compiler commands for qrc_*.cpp files

Diff Detail

Repository
R216 Syntax Highlighting
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
davschul created this revision.Feb 14 2019, 6:56 AM
Restricted Application added projects: Kate, Frameworks. · View Herald TranscriptFeb 14 2019, 6:56 AM
Restricted Application added subscribers: kde-frameworks-devel, kwrite-devel. · View Herald Transcript
davschul requested review of this revision.Feb 14 2019, 6:56 AM
davschul added inline comments.Feb 14 2019, 7:00 AM
data/CMakeLists.txt
68

This seems like an overkill, but I'm new to CMAKE and it seems that this was the only way to get the -DQT_NAMESPACE= option added to the compiler command for the qrc_syntax-data.cpp and qrc_theme-data.cpp. Is there a simpler solution to achieve this?

I think target_link_libraries is the right way to fix it, that's OK.
I am not that into the QT_.... macro magic, perhaps Volker can comment if that is ok ;)

vkrause accepted this revision.Feb 14 2019, 8:16 AM

Looks good to me, thanks!

This revision is now accepted and ready to land.Feb 14 2019, 8:16 AM
This revision was automatically updated to reflect the committed changes.
cullmann reopened this revision.Feb 21 2019, 12:41 PM

Hmm, there is one issue:

With older cmake, aka

cmake version 3.10.2

I get now:

CMake Error at data/CMakeLists.txt:68 (target_link_libraries):

Object library target "SyntaxHighlightingData" may not link to anything.
This revision is now accepted and ready to land.Feb 21 2019, 12:41 PM

Okay I've tested it with 3.12.2 and there were no issues.
I'm not familiar enough with cmake to tell whether there is a simpler version for what I try to achieve here. I just need the -D QT_NAMESPACE compiler options. Is there someone in the community who might know how to make it in a more elegant way.
If not I do not need that target_link_libraries part in Qt Creator, because we still only support building via qmake or qbs. It was just to be complete here. So it could be removed without breaking our use case, but it would break namespace builds for any one else.

No problem, I just reopened it that I remember to take a look again at it myself.
I just run into this issue wanting to land some patches on a openSUSE Leap machine.

cgiboudeaux added inline comments.
data/CMakeLists.txt
68

This is causing a build issue (at least) with CMake 3.10:

CMake Error at data/CMakeLists.txt:68 (target_link_libraries):

Object library target "SyntaxHighlightingData" may not link to anything.

OBJECT targets must not link to anything [1]

An object library compiles source files but does not archive or link their object files into a library.

The CMake doc < 3.11 also mentions "Object libraries cannot be linked."

[1] https://cmake.org/cmake/help/v3.14/command/add_library.html#object-libraries

cullmann closed this revision.Apr 16 2019, 6:34 PM

The build issue got fixed.