Menu

#28 Properly link quazip_static against its dependencies

Unstable_(example)
open
None
5
2016-09-06
2016-09-06
No

From the looks of r256, it appears that the target_link_libraries() call in quazip/CMakeLists.txt was modified with the intention of linking both ${QUAZIP_LIB_TARGET_NAME} and quazip_static against all required libraries.

However, target_link_libraries()'s syntax is such that the first argument is the library that all other arguments will be linked against. In other words, libquazip(5).so will link against quazip_static, which is not what is desired.

Not only is this not what's desired, but the build actually fails by default when building quazip_static:

[  6%] Building CXX object quazip/CMakeFiles/quazip_static.dir/JlCompress.cpp.o
In file included from /usr/include/qt5/QtCore/qchar.h:37:0,
                 from /usr/include/qt5/QtCore/qstring.h:41,
                 from /usr/include/qt5/QtCore/QString:1,
                 from /tmp/quazip-0.7.2/quazip/quazip.h:28,
                 from /tmp/quazip-0.7.2/quazip/JlCompress.h:29,
                 from /tmp/quazip-0.7.2/quazip/JlCompress.cpp:26:
/usr/include/qt5/QtCore/qglobal.h:1087:4: error: #error "You must build your code with position independent code if Qt was built with -reduce-relocations. " "Compile your code with -fPIC (-fPIE is not enough)."
 #  error "You must build your code with position independent code if Qt was built with -reduce-relocations. "\

This should be solved automatically if quazip_static is linked against ${QTCORE_LIBRARIES}, as the Qt5::Core target takes care of making sure targets depending on it pass -fPIC as required.

The other targets are not really needed, but are passed to target_link_libraries() for completion.

1 Attachments

Discussion

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.