Add QT_BEGIN/END_NAMESPACE to forward declaration of Qt classes and
add namespace define to compiler commands for qrc_*.cpp files
Details
- Reviewers
vkrause - Commits
- R216:96466afebf63: Fix building with namespaced Qt
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.
data/CMakeLists.txt | ||
---|---|---|
62 ↗ | (On Diff #51644) | 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 ;)
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.
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.
data/CMakeLists.txt | ||
---|---|---|
68 | This is causing a build issue (at least) with CMake 3.10:
OBJECT targets must not link to anything [1]
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 |