Review Request 123179: workaround Vc cmake issue

Yue Liu yue.liu at mail.com
Mon Mar 30 08:54:55 BST 2015


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://git.reviewboard.kde.org/r/123179/
-----------------------------------------------------------

(Updated March 30, 2015, 7:54 a.m.)


Review request for Calligra and Boudewijn Rempt.


Repository: calligra


Description
-------

Currently building pigment with vc 0.7.4 enabled would fail on systems not putting qt5 headers and kf5 headers in /usr/include. This is because of vc's cmake macro `ko_compile_for_all_implementations_no_scalar`, which I found resulted in this piece in CMake-generated ninja code:
```
build libs/pigment/KoOptimizedCompositeOpFactoryPerArch_AVX.cpp.o: CUSTOM_COMMAND /home/yue/Dev/calligra/src/calligra/libs/pigment/compositeops/KoOptimizedCompositeOpFactoryPerArch.cpp /home/yue/Dev/calligra/src/calligra/libs/pigment/compositeops/KoOptimizedCompositeOpFactoryPerArch.cpp || libs/koplugin/libkoplugin.so libs/pigment/pigmentcms_automoc libs/version/libkoversion.so
  COMMAND = cd /home/yue/Dev/calligra/build/libs/pigment && /usr/bin/clang++ -std=c++0x -fno-exceptions -Wall -Wextra -Wcast-align -Wchar-subscripts -Wformat-security -Wno-long-long -Wpointer-arith -Wundef -Wnon-virtual-dtor -Woverloaded-virtual -Werror=return-type -O2 -g -DNDEBUG -Wno-local-type-template-args -Wno-unnamed-type-template-args -ffp-contract=fast -mtune=core2 -fPIC -I/home/yue/Dev/calligra/src/calligra/interfaces -I/home/yue/Dev/calligra/build -I/home/yue/Dev/calligra/src/calligra -I/home/yue/Dev/calligra/src/calligra/libs/version -I/home/yue/Dev/calligra/build/libs/version -I/home/yue/Dev/calligra/src/calligra/libs/koplugin -I/home/yue/Dev/calligra/src/calligra/libs/version -I/home/yue/Dev/calligra/build/libs/version -I/home/yue/Dev/calligra/src/calligra/libs/pigment -I/home/yue/Dev/calligra/src/calligra/libs/pigment/compositeops -I/home/yue/Dev/calligra/src/calligra/libs/pigment/resources -I/usr/include -I/usr/include -I/usr/include/OpenEXR -I/usr/include -mavx -DVC_IMPL=AVX -c -oKoOptimizedCompositeOpFactoryPerArch_AVX.cpp.o /home/yue/Dev/calligra/src/calligra/libs/pigment/compositeops/KoOptimizedCompositeOpFactoryPerArch.cpp
  DESC = Building CXX object KoOptimizedCompositeOpFactoryPerArch_AVX.cpp.o
```

Which is very different from ninja code generated by CMake's add_library function:
```
build libs/pigment/CMakeFiles/pigmentcms.dir/compositeops/KoOptimizedCompositeOpFactory.cpp.o: CXX_COMPILER /home/yue/Dev/calligra/src/calligra/libs/pigment/compositeops/KoOptimizedCompositeOpFactory.cpp || cmake_order_depends_target_pigmentcms
  DEFINES = -DBOOST_ALL_NO_LIB -DCAN_USE_QTWEBKIT -DKCOREADDONS_LIB -DKGUIADDONS_LIB -DQT_CORE_LIB -DQT_DBUS_LIB -DQT_DISABLE_DEPRECATED_BEFORE=0 -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_NO_DEBUG -DQT_PRINTSUPPORT_LIB -DQT_USE_FAST_CONCATENATION -DQT_USE_FAST_OPERATOR_PLUS -DQT_WIDGETS_LIB -DQT_XML_LIB -DSHOULD_BUILD_FONT_CONVERSION -D_GNU_SOURCE -D_LARGEFILE64_SOURCE -Dpigmentcms_EXPORTS
  DEP_FILE = libs/pigment/CMakeFiles/pigmentcms.dir/compositeops/KoOptimizedCompositeOpFactory.cpp.o.d
  FLAGS = -std=c++0x -fno-exceptions -Wall -Wextra -Wcast-align -Wchar-subscripts -Wformat-security -Wno-long-long -Wpointer-arith -Wundef -Wnon-virtual-dtor -Woverloaded-virtual -Werror=return-type -O2 -g -DNDEBUG -fPIC -fvisibility=hidden -fvisibility-inlines-hidden -Ilibs/pigment -I/home/yue/Dev/calligra/src/calligra/libs/pigment -I/home/yue/Dev/calligra/src/calligra/interfaces -I. -I/home/yue/Dev/calligra/src/calligra -I/home/yue/Dev/calligra/src/calligra/libs/version -Ilibs/version -I/home/yue/Dev/calligra/src/calligra/libs/koplugin -I/home/yue/Dev/calligra/src/calligra/libs/pigment/compositeops -I/home/yue/Dev/calligra/src/calligra/libs/pigment/resources -Ilibs/koplugin -I/usr/include/OpenEXR -isystem /usr/include/qt -isystem /usr/include/qt/QtCore -isystem /usr/lib/qt/mkspecs/linux-g++ -isystem /usr/include/KF5/KDELibs4Support -isystem /usr/include/KF5/KDELibs4Support/KDE -isystem /usr/include/KF5 -isystem /usr/include/qt/QtWidgets -isystem /usr/include/qt/QtGui -isystem /usr/include/qt/QtDBus -isystem /usr/include/qt/QtPrintSupport -isystem /usr/include/KF5/KCoreAddons -isystem /usr/include/KF5/KCrash -isystem /usr/include/KF5/KWidgetsAddons -isystem /usr/include/KF5/KConfigCore -isystem /usr/include/KF5/KConfigWidgets -isystem /usr/include/KF5/KCodecs -isystem /usr/include/KF5/KConfigGui -isystem /usr/include/qt/QtXml -isystem /usr/include/KF5/KAuth -isystem /usr/include/KF5/KIOCore -isystem /usr/include/KF5/KService -isystem /usr/include/KF5/KIOFileWidgets -isystem /usr/include/KF5/KIOWidgets -isystem /usr/include/KF5/KJobWidgets -isystem /usr/include/qt/QtNetwork -isystem /usr/include/KF5/KCompletion -isystem /usr/include/KF5/KBookmarks -isystem /usr/include/KF5/KItemViews -isystem /usr/include/KF5/KXmlGui -isystem /usr/include/KF5/Solid -isystem /usr/include/KF5/KI18n -isystem /usr/include/KF5/KNotifications -isystem /usr/include/KF5/KIconThemes -isystem /usr/include/KF5/KWindowSystem -isystem /usr/include/KF5/KGuiAddons -isystem /usr/include/KF5/KUnitConversion -isystem /usr/include/KF5/KTextWidgets -isystem /usr/include/KF5/SonnetUi -isystem /usr/include/KF5/KParts -isystem /usr/include/KF5/KItemModels -isystem /usr/include/KF5/KEmoticons
  OBJECT_DIR = libs/pigment/CMakeFiles/pigmentcms.dir
  OBJECT_FILE_DIR = libs/pigment/CMakeFiles/pigmentcms.dir/compositeops
  TARGET_COMPILE_PDB = libs/pigment/CMakeFiles/pigmentcms.dir/
  TARGET_PDB = libs/pigment/libpigmentcms.pdb
```

It seems vc's `ko_compile_for_all_implementations_no_scalar` macro used its own method to generate compiler command and arguments, which only has include directories defined in `add_directories`, but Qt5/KF5 include directories are added through `target_link_libraries`, which is described in [KF5 porting notes](https://community.kde.org/Frameworks/Porting_Notes#Build_System) and [CMake doc](http://www.cmake.org/cmake/help/v3.2/prop_tgt/INTERFACE_SYSTEM_INCLUDE_DIRECTORIES.html).

I think it's something should be fixed in Vc, for now we need to manually add Qt5/KF5 include directories in `add_directories`, and be careful about the order of those directories, if conflicting headers exists between `/usr/include` and other non-standard path, for example kdelibs4's `kdebug.h` is in `/usr/include`, KF5KDELibs4Support's `kdebug.h` is in `/usr/include/KF5/KDELibs4Support`, while a different non-cnflicting header is located in `/usr/include` and its include directory is added before KDELibs4Support include directory, then compiler will try `/usr/include` first when looking for KDELibs4Support's headers. That issue doesn't exist if compiler arguments are constructed by CMake's `add_library` because CMake will automatically remove any `/usr/include` include directory, as shown in the second piece of ninja code.


Diffs (updated)
-----

  libs/pigment/CMakeLists.txt ae6651b82b8a26ed40d6f1ab4590ce13f753f8d9 

Diff: https://git.reviewboard.kde.org/r/123179/diff/


Testing (updated)
-------

Build successful on arch linux


Thanks,

Yue Liu

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/calligra-devel/attachments/20150330/5ead2ab4/attachment.htm>


More information about the calligra-devel mailing list