Repository: conan-io/conan-center-index

Issue:
[bug] xorg/system: xorg-xft component pulls in /usr/include/freetype2 and other sys includes
I'd just like to say, I wonder how deep in the dependency graph we / conan should drill down?
This is getting pretty deep, any deeper and conan will be compiling X11 and the kernel !

I'm trying to build Qt6 from the CCI recipe, which includes freetype in the dependency graph.
I've boobytrapped the /usr/include/freetype2/ft2build.h to detect when the conan/cmake is bringing in system includes instead of the conan supplied files.

ie at the top of /usr/include/freetype2/ft2build.h, I added `#error "should not use system includes`

So while Qt6 is building, I am checking the compiler arguments.
The /usr/include/freetype2 dir is always in the command line params, but often we "get away with it" because of the includedir ordering.    ie the conan include folders are listed before the xkbcommon-derived includes.

But, the include dir order is inconsistent (probably because of the order of requirements declared for each Qt module?).

It seems to be that xkbcommon has a pkg requirement for xorg-xft, and that isn't provided by conan CCI so it brings in /usr/include/freetype2
See below for xft.pc

### Package and Environment Details (include every applicable attribute)
  * Package Name/Version: **xkbcommon/1.4.0**
  * Operating System+version: **Linux Ubuntu 20.04**
  * Compiler+version: **GCC 11**
  * Docker image: **-**
  * Conan version: **conan 1.48.0**
  * Python version: **Python 3.8.10**


### xkbcommon's xft.pc
<details><summary>Click to expand log</summary>
```
prefix=/build/conandata/conan-data/xorg/system/_/_/package/5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9
includedir=/usr/include/uuid
includedir2=/usr/include/freetype2
includedir3=/usr/include/libpng16

Name: xorg-xft
Description: Conan package: xorg-xft
Version: 2.3.3
Libs: -lXft 
Cflags: -I"${includedir}" -I"${includedir2}" -I"${includedir3}"
```
</details>


### Log of compiler cmd with freetype2 include ahead of conan includes
<details><summary>Click to expand log</summary>
```
Look for the "HERE IS" in the block of text, to help spot the includes.

[733/1326] /usr/lib/ccache/g++-11 -DENABLE_PIXMAN_DRAWHELPERS -DGui_EXPORTS -DHAS_FCHOWN -DHAS_STICKY_DIR_BIT -DMD4C_USE_UTF8 -DQT_ASCII_CAST_WARNINGS -DQT_BUILDING_QT -DQT_BUILD_GUI_LIB -DQT_CORE_LIB -DQT_DEPRECATED_WARNINGS -DQT_DEPRECATED_WARNINGS_SINCE=0x060000 -DQT_DISABLE_DEPRECATED_BEFORE=0x050000 -DQT_MOC_COMPAT -DQT_NO_CAST_TO_ASCII -DQT_NO_DEBUG -DQT_NO_EXCEPTIONS -DQT_NO_FOREACH -DQT_NO_JAVA_STYLE_ITERATORS -DQT_NO_NARROWING_CONVERSIONS_IN_CONNECT -DQT_NO_USING_NAMESPACE -DQT_QPA_DEFAULT_PLATFORM_NAME=\"xcb\" -DQT_USE_QSTRINGBUILDER -D_BSD_SOURCE -D_DEFAULT_SOURCE -D_GLIBCXX_USE_CXX11_ABI=1 -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -I/build/msrap2/deps/conan-center-index/recipes/qt/6.x.x/build/qtbase/src/gui/Gui_autogen/include -I/build/conandata/conan-data/double-conversion/3.2.0/_/_/package/45c3dac76374a750236d109a39e2d0dce48c6dee/include -I/build/conandata/conan-data/icu/71.1/_/_/package/707056c44dd22d3e5a4838bb69c725f49d9e6f3e/include -I/build/conandata/conan-data/libjpeg-turbo/2.1.2/_/_/package/052722dba4d2b11057af2ccf04d274f5403ab446/include -I/build/conandata/conan-data/sqlite3/3.38.1/_/_/package/04f3d9990d7147f15e756850b09b524e7a9fa495/include -I/build/conandata/conan-data/zstd/1.5.2/_/_/package/64040fc111a2f8984571d56d7700e5b3c833091b/include -I/build/conandata/conan-data/openssl/1.1.1n/_/_/package/d8e005ad3b462a6816372c83828697b59f046649/include -I/usr/include/uuid    --------- HERE IS THE FIRST FREETYPE INCLUDE ---------    -I/usr/include/freetype2 -I/usr/include/libpng16 -I/build/conandata/conan-data/libxml2/2.9.13/_/_/package/0998548b2c6c7bb9e3a0c4b2211b82848c5b47ac/include -I/build/conandata/conan-data/libxml2/2.9.13/_/_/package/0998548b2c6c7bb9e3a0c4b2211b82848c5b47ac/include/libxml2 -I/build/conandata/conan-data/libiconv/1.16/_/_/package/d8e005ad3b462a6816372c83828697b59f046649/include -I/build/msrap2/deps/conan-center-index/recipes/qt/6.x.x/build/qtbase/include -I/build/msrap2/deps/conan-center-index/recipes/qt/6.x.x/build/qtbase/include/QtGui -I/build/msrap2/deps/conan-center-index/recipes/qt/6.x.x/src/qt6/qtbase/src/gui -I/build/msrap2/deps/conan-center-index/recipes/qt/6.x.x/build/qtbase/src/gui -I/build/msrap2/deps/conan-center-index/recipes/qt/6.x.x/src/qt6/qtbase/src/gui/../3rdparty/VulkanMemoryAllocator -I/build/msrap2/deps/conan-center-index/recipes/qt/6.x.x/build/qtbase/include/QtGui/6.2.4 -I/build/msrap2/deps/conan-center-index/recipes/qt/6.x.x/build/qtbase/include/QtGui/6.2.4/QtGui -I/build/msrap2/deps/conan-center-index/recipes/qt/6.x.x/src/qt6/qtbase/src/gui/../3rdparty/md4c -I/build/msrap2/deps/conan-center-index/recipes/qt/6.x.x/build/qtbase/include/QtCore -I/build/msrap2/deps/conan-center-index/recipes/qt/6.x.x/src/qt6/qtbase/mkspecs/linux-g++ -I/build/msrap2/deps/conan-center-index/recipes/qt/6.x.x/build/qtbase/src/corelib -I/build/msrap2/deps/conan-center-index/recipes/qt/6.x.x/build/qtbase/include/QtCore/6.2.4 -I/build/msrap2/deps/conan-center-index/recipes/qt/6.x.x/build/qtbase/include/QtCore/6.2.4/QtCore -isystem /build/conandata/conan-data/fontconfig/2.13.93/_/_/package/49eb93b2bd5546053215176ecd70adc03ad2a1f9/include -isystem /build/conandata/conan-data/harfbuzz/4.2.1/_/_/package/925c2f5d2139ad32ce6919cebb31e0e4b471c286/include -isystem /build/conandata/conan-data/harfbuzz/4.2.1/_/_/package/925c2f5d2139ad32ce6919cebb31e0e4b471c286/include/harfbuzz -isystem /build/conandata/conan-data/xkbcommon/1.4.0/_/_/package/90ac0e490deadebc3367d8e7827398d34f9dec8a/include -isystem --------- HERE IS THE CONAN FREETYPE INCLUDE --------- /build/conandata/conan-data/freetype/2.11.1/_/_/package/c30166e730fb8c7c165c20fa134eb41e092fa263/include -isystem /build/conandata/conan-data/freetype/2.11.1/_/_/package/c30166e730fb8c7c165c20fa134eb41e092fa263/include/freetype2 -isystem /build/conandata/conan-data/expat/2.4.8/_/_/package/e9397626dc70ac22e096a6e4fcd768c3d16c095a/include -isystem /build/conandata/conan-data/libuuid/1.0.3/_/_/package/d8e005ad3b462a6816372c83828697b59f046649/include -isystem /build/conandata/conan-data/libuuid/1.0.3/_/_/package/d8e005ad3b462a6816372c83828697b59f046649/include/uuid -isystem /build/conandata/conan-data/glib/2.72.0/_/_/package/ce8514b42952964ade3ad32e80d857e8a57e2e0d/include -isystem /build/conandata/conan-data/glib/2.72.0/_/_/package/ce8514b42952964ade3ad32e80d857e8a57e2e0d/include/gio-unix-2.0 -isystem /build/conandata/conan-data/glib/2.72.0/_/_/package/ce8514b42952964ade3ad32e80d857e8a57e2e0d/include/glib-2.0 -isystem /build/conandata/conan-data/glib/2.72.0/_/_/package/ce8514b42952964ade3ad32e80d857e8a57e2e0d/lib/glib-2.0/include -isystem /build/conandata/conan-data/libpng/1.6.37/_/_/package/1134e4336c7a26c424832456faca8bbd1f3765ae/include -isystem /build/conandata/conan-data/brotli/1.0.9/_/_/package/d8e005ad3b462a6816372c83828697b59f046649/include -isystem /build/conandata/conan-data/brotli/1.0.9/_/_/package/d8e005ad3b462a6816372c83828697b59f046649/include/brotli -isystem /build/conandata/conan-data/libffi/3.4.2/_/_/package/d8e005ad3b462a6816372c83828697b59f046649/include -isystem /build/conandata/conan-data/pcre/8.45/_/_/package/9d6b7901d27181a99ebcb6baeb85c8901850d1b5/include -isystem /build/conandata/conan-data/libelf/0.8.13/_/_/package/d8e005ad3b462a6816372c83828697b59f046649/include/libelf -isystem /build/conandata/conan-data/libelf/0.8.13/_/_/package/d8e005ad3b462a6816372c83828697b59f046649/include -isystem /build/conandata/conan-data/libmount/2.36.2/_/_/package/d8e005ad3b462a6816372c83828697b59f046649/include -isystem /build/conandata/conan-data/libmount/2.36.2/_/_/package/d8e005ad3b462a6816372c83828697b59f046649/include/libmount -isystem /build/conandata/conan-data/libselinux/3.3/_/_/package/57c104a27db76aeebabfafc2cd13d53242461c8b/include -isystem /build/conandata/conan-data/pcre2/10.37/_/_/package/ca6da468706a2ed1112e0ce60ee4ef7e3df22afd/include -isystem /build/conandata/conan-data/zlib/1.2.12/_/_/package/d8e005ad3b462a6816372c83828697b59f046649/include -isystem /build/conandata/conan-data/bzip2/1.0.8/_/_/package/938364ead48216bc0d9f3c562bf7bd1efbe00322/include -m64 -DNDEBUG -O3 -fPIC -fvisibility=hidden -fvisibility-inlines-hidden -D_DEFAULT_SOURCE -D_BSD_SOURCE -DHAS_FCHOWN -DHAS_STICKY_DIR_BIT -Wall -Wextra -fno-exceptions -fPIC -Wsuggest-override -std=c++17 -Winvalid-pch -include /build/msrap2/deps/conan-center-index/recipes/qt/6.x.x/build/qtbase/src/gui/CMakeFiles/Gui.dir/cmake_pch.hxx -MD -MT qtbase/src/gui/CMakeFiles/Gui.dir/text/qcssparser.cpp.o -MF qtbase/src/gui/CMakeFiles/Gui.dir/text/qcssparser.cpp.o.d -o qtbase/src/gui/CMakeFiles/Gui.dir/text/qcssparser.cpp.o -c /build/msrap2/deps/conan-center-index/recipes/qt/6.x.x/src/qt6/qtbase/src/gui/text/qcssparser.cpp
```

</details>



Discussion:
@paulharris  please appear in my notifications list...
The issue is conan package xorg/system is using pkg_config to introduce system includes for xft,
which sucks in:
- /usr/include/uuid
- /usr/include/freetype2
- /usr/include/libpng16

All of which are also provided by conan packages, when building Qt.
But these includes are added to GCC's command line prior to the conan includes,
so the build is inconsistent ...
Yeah, This is a known shortcoming, for which I don't have a solution in mind. maybe @jgsogo @uilianries @SpaceIm  have an idea?

related: https://github.com/conan-io/conan-center-index/issues/1207
Should we just provide an xft package?
As #1207 says, just keep cutting closer to the OS...
that could be a step in the right direction. But we had some problems in the past when we tried to create conan packages for [all xorg-dev packages](https://github.com/bincrafters/conan-x11). It did not work correctly due to conan packages using a different version than the distribution. I asked for this on https://gitlab.freedesktop.org/xorg/lib/libxft/-/issues/11

Also related: https://github.com/conan-io/conan-center-index/issues/6880
also also related: https://github.com/conan-io/conan-center-index/blob/master/recipes/imagemagick/all/conanfile.py#L330-L340

Resolving patch:
diff --git a/recipes/xorg/all/conanfile.py b/recipes/xorg/all/conanfile.py
--- a/recipes/xorg/all/conanfile.py
+++ b/recipes/xorg/all/conanfile.py
@@ -1,5 +1,6 @@
 from conans import ConanFile, tools
 from conans.errors import ConanException, ConanInvalidConfiguration
+import os
 
 required_conan_version = ">=1.32"
 
@@ -46,7 +47,7 @@ def system_requirements(self):
             if tools.os_info.with_apt:
                 packages = ["libx11-dev", "libx11-xcb-dev", "libfontenc-dev", "libice-dev", "libsm-dev", "libxau-dev", "libxaw7-dev",
                             "libxcomposite-dev", "libxcursor-dev", "libxdamage-dev", "libxdmcp-dev", "libxext-dev", "libxfixes-dev", 
-                            "libxft-dev", "libxi-dev", "libxinerama-dev", "libxkbfile-dev", "libxmu-dev", "libxmuu-dev", 
+                            "libxi-dev", "libxinerama-dev", "libxkbfile-dev", "libxmu-dev", "libxmuu-dev",
                             "libxpm-dev", "libxrandr-dev", "libxrender-dev", "libxres-dev", "libxss-dev", "libxt-dev", "libxtst-dev", 
                             "libxv-dev", "libxvmc-dev", "libxxf86vm-dev", "xtrans-dev", "libxcb-render0-dev",
                             "libxcb-render-util0-dev", "libxcb-xkb-dev", "libxcb-icccm4-dev", "libxcb-image0-dev",
@@ -58,36 +59,37 @@ def system_requirements(self):
                     packages.append( "libxcb-util0-dev" )
                 else:
                     packages.append( "libxcb-util-dev" )
-            elif tools.os_info.with_yum or tools.os_info.with_dnf:
+            elif tools.os_info.with_yum or tools.os_info.with_dnf or tools.os_info.with_zypper:
                 packages = ["libxcb-devel", "libfontenc-devel", "libXaw-devel", "libXcomposite-devel",
-                            "libXcursor-devel", "libXdmcp-devel", "libXft-devel", "libXtst-devel", "libXinerama-devel",
+                            "libXcursor-devel", "libXdmcp-devel", "libXtst-devel", "libXinerama-devel",
                             "libxkbfile-devel", "libXrandr-devel", "libXres-devel", "libXScrnSaver-devel", "libXvMC-devel",
                             "xorg-x11-xtrans-devel", "xcb-util-wm-devel", "xcb-util-image-devel", "xcb-util-keysyms-devel",
                             "xcb-util-renderutil-devel", "libXdamage-devel", "libXxf86vm-devel", "libXv-devel",
-                            "xkeyboard-config-devel", "xcb-util-devel", "libuuid-devel"]
+                            "xcb-util-devel", "libuuid-devel"]
+                packages.append("xkeyboard-config" if tools.os_info.with_zypper else "xkeyboard-config-devel")
             elif tools.os_info.with_pacman:
                 packages = ["libxcb", "libfontenc", "libice", "libsm", "libxaw", "libxcomposite", "libxcursor",
-                            "libxdamage", "libxdmcp", "libxft", "libxtst", "libxinerama", "libxkbfile", "libxrandr", "libxres",
+                            "libxdamage", "libxdmcp", "libxtst", "libxinerama", "libxkbfile", "libxrandr", "libxres",
                             "libxss", "libxvmc", "xtrans", "xcb-util-wm", "xcb-util-image","xcb-util-keysyms", "xcb-util-renderutil",
                             "libxxf86vm", "libxv", "xkeyboard-config", "xcb-util", "util-linux-libs"]
-            elif tools.os_info.with_zypper:
-                packages = ["xorg-x11-devel", "xcb-util-wm-devel", "xcb-util-image-devel", "xcb-util-keysyms-devel",
-                            "xcb-util-renderutil-devel", "xkeyboard-config", "xcb-util-devel", "libuuid-devel"]
             else:
                 self.output.warn("Do not know how to install 'xorg' for {}.".format(tools.os_info.linux_distro))
         
         elif tools.os_info.is_freebsd and self.settings.os == "FreeBSD":
             packages = ["libX11", "libfontenc", "libice", "libsm", "libxaw", "libxcomposite", "libxcursor",
-                        "libxdamage", "libxdmcp", "libxft", "libxtst", "libxinerama", "libxkbfile", "libxrandr", "libxres",
+                        "libxdamage", "libxdmcp", "libxtst", "libxinerama", "libxkbfile", "libxrandr", "libxres",
                         "libXScrnSaver", "libxvmc", "xtrans", "xcb-util-wm", "xcb-util-image", "xcb-util-keysyms", "xcb-util-renderutil",
                         "libxxf86vm", "libxv", "xkeyboard-config", "xcb-util"]
         if packages:
             package_tool = tools.SystemPackageTool(conanfile=self, default_mode="verify")
             package_tool.install_packages(update=True, packages=packages)
+    
+    def package(self):
+        tools.mkdir(os.path.join(self.package_folder, "include")) # to satisfy KB-H071
 
     def package_info(self):
         for name in ["x11", "x11-xcb", "fontenc", "ice", "sm", "xau", "xaw7",
-                     "xcomposite", "xcursor", "xdamage", "xdmcp", "xext", "xfixes", "xft", "xi",
+                     "xcomposite", "xcursor", "xdamage", "xdmcp", "xext", "xfixes", "xi",
                      "xinerama", "xkbfile", "xmu", "xmuu", "xpm", "xrandr", "xrender", "xres",
                      "xscrnsaver", "xt", "xtst", "xv", "xvmc", "xxf86vm", "xtrans",
                      "xcb-xkb", "xcb-icccm", "xcb-image", "xcb-keysyms", "xcb-randr", "xcb-render",


Test patch: