bitwiseworks / qtbase-os2

Port of Qt Base module version 5 to OS/2
Other
10 stars 2 forks source link

cmake: Make sure -lcx is used when linking for projects involving Qt libs. #134

Open dmik opened 2 years ago

dmik commented 2 years ago

As https://github.com/bitwiseworks/qtbase-os2/issues/133 showed, It seems that -lcx doesn't reach the linker command line when linking against Qt libraries in cmake projects. This leads to mmap which is used by QtCore being completely broken (and several other minor things that rely on LIBCx startup code).

Looking at qmake config files, I see that -lcx is in fact added to any app built with qmake - we don't check if Qt libs are involved or not. Perhaps, we should actually check that and not add it if no library actually needing it is used.

As for cmake, the Qt build system generates .cmake "include" files (used when corresponding libraries are used) based on qmake config files. However, it doesn't take -lcx or places it in a wrong place. This needs an investigation.

StevenLevine commented 2 years ago

@dmik do you still need the testcase requested in #133 or are the cppcheck sources good enough? If so, I will have @GreggK push his source modifications to https://github.com/Greggk/cppcheck. Our gcc is a bit old to build the unforked sources out of the box. Gregg needed to adjust a few include paths in the sources. If you are going to use cppcheck as a testcase, I will ask Gregg to push these modifications. We will leave the cmake and qmake mods unpushed for now.

Silvan, to be clear, I never suggested that all Qt apps be built with libcx. What I asked was if our cmake port should be smart enough to detect when libcx is needed. For example, the cppcheck project can build two executables. cppcheck-gui needs libcx because it's build with Qt and uses the QFile class and the code will use mmap via QFile::map on platforms that support it. cppcheck.exe in not built with Qt and does not use mmap, so it is fine without libcx.