Repository: spack/spack

Issue:
Installation issue: qt-base on macOS arm64
### Steps to reproduce the issue

```console
$ spack spec -I qt-base
Input spec
--------------------------------
 -   qt-base

Concretized
--------------------------------
 -   qt-base@6.3.2%apple-clang@14.0.0+accessibility~dbus+framework~gtk+gui~ipo+network~opengl+shared+sql+widgets build_system=cmake build_type=RelWithDebInfo arch=darwin-monterey-m1
[+]      ^at-spi2-core@2.40.1%apple-clang@14.0.0~strip build_system=meson buildtype=debugoptimized default_library=shared arch=darwin-monterey-m1
[+]          ^dbus@1.12.8%apple-clang@14.0.0 build_system=generic arch=darwin-monterey-m1
[+]              ^docbook-xml@4.4%apple-clang@14.0.0 build_system=generic arch=darwin-monterey-m1
[+]              ^docbook-xsl@1.79.2%apple-clang@14.0.0 build_system=generic patches=a92c397 arch=darwin-monterey-m1
[+]              ^libsm@1.2.3%apple-clang@14.0.0 build_system=autotools arch=darwin-monterey-m1
[+]                  ^libice@1.0.9%apple-clang@14.0.0 build_system=autotools arch=darwin-monterey-m1
[+]          ^fixesproto@5.0%apple-clang@14.0.0 build_system=autotools arch=darwin-monterey-m1
[+]              ^util-macros@1.19.3%apple-clang@14.0.0 build_system=autotools arch=darwin-monterey-m1
[+]          ^gettext@0.21.1%apple-clang@14.0.0+bzip2+curses+git~libunistring+libxml2+tar+xz build_system=autotools arch=darwin-monterey-m1
[+]              ^tar@1.34%apple-clang@14.0.0 build_system=autotools zip=pigz arch=darwin-monterey-m1
[+]                  ^pigz@2.7%apple-clang@14.0.0 build_system=makefile arch=darwin-monterey-m1
[+]          ^glib@2.74.1%apple-clang@14.0.0~libmount build_system=generic tracing=none arch=darwin-monterey-m1
[+]              ^libelf@0.8.13%apple-clang@14.0.0 build_system=autotools arch=darwin-monterey-m1
[+]          ^gobject-introspection@1.72.0%apple-clang@14.0.0~strip build_system=meson buildtype=debugoptimized default_library=shared arch=darwin-monterey-m1
[+]              ^bison@3.8.2%apple-clang@14.0.0 build_system=autotools arch=darwin-monterey-m1
[+]              ^flex@2.6.3%apple-clang@14.0.0+lex~nls build_system=autotools arch=darwin-monterey-m1
[+]                  ^findutils@4.9.0%apple-clang@14.0.0 build_system=autotools patches=440b954 arch=darwin-monterey-m1
[+]              ^sed@4.8%apple-clang@14.0.0 build_system=autotools arch=darwin-monterey-m1
[+]          ^inputproto@2.3.2%apple-clang@14.0.0 build_system=autotools arch=darwin-monterey-m1
[+]          ^libx11@1.7.0%apple-clang@14.0.0 build_system=autotools arch=darwin-monterey-m1
[+]              ^kbproto@1.0.7%apple-clang@14.0.0 build_system=autotools arch=darwin-monterey-m1
[+]              ^libxcb@1.14%apple-clang@14.0.0 build_system=autotools arch=darwin-monterey-m1
[+]                  ^libpthread-stubs@0.4%apple-clang@14.0.0 build_system=autotools arch=darwin-monterey-m1
[+]                  ^libxau@1.0.8%apple-clang@14.0.0 build_system=autotools arch=darwin-monterey-m1
[+]                  ^libxdmcp@1.1.2%apple-clang@14.0.0 build_system=autotools arch=darwin-monterey-m1
[+]                  ^xcb-proto@1.14.1%apple-clang@14.0.0 build_system=autotools arch=darwin-monterey-m1
[+]              ^xextproto@7.3.0%apple-clang@14.0.0 build_system=autotools arch=darwin-monterey-m1
[+]              ^xproto@7.0.31%apple-clang@14.0.0 build_system=autotools arch=darwin-monterey-m1
[+]              ^xtrans@1.3.5%apple-clang@14.0.0 build_system=autotools arch=darwin-monterey-m1
[+]          ^libxi@1.7.6%apple-clang@14.0.0 build_system=autotools arch=darwin-monterey-m1
[+]              ^libxext@1.3.3%apple-clang@14.0.0 build_system=autotools arch=darwin-monterey-m1
[+]              ^libxfixes@5.0.2%apple-clang@14.0.0 build_system=autotools arch=darwin-monterey-m1
[+]          ^libxtst@1.2.2%apple-clang@14.0.0 build_system=autotools arch=darwin-monterey-m1
[+]          ^meson@0.64.0%apple-clang@14.0.0 build_system=python_pip patches=0f0b1bd arch=darwin-monterey-m1
[+]              ^py-pip@22.2.2%apple-clang@14.0.0 build_system=generic arch=darwin-monterey-m1
[+]              ^py-setuptools@59.4.0%apple-clang@14.0.0 build_system=generic arch=darwin-monterey-m1
[+]              ^py-wheel@0.37.1%apple-clang@14.0.0 build_system=generic arch=darwin-monterey-m1
[+]          ^recordproto@1.14.2%apple-clang@14.0.0 build_system=autotools arch=darwin-monterey-m1
[+]      ^cmake@3.25.0%apple-clang@14.0.0~doc+ncurses+ownlibs~qt build_system=generic build_type=Release arch=darwin-monterey-m1
[+]          ^ncurses@6.3%apple-clang@14.0.0~symlinks+termlib abi=none build_system=autotools arch=darwin-monterey-m1
[+]      ^double-conversion@3.1.5%apple-clang@14.0.0~ipo build_system=cmake build_type=RelWithDebInfo arch=darwin-monterey-m1
[+]      ^fontconfig@2.13.94%apple-clang@14.0.0 build_system=autotools arch=darwin-monterey-m1
[+]          ^apple-libuuid@1353.100.2%apple-clang@14.0.0 build_system=bundle arch=darwin-monterey-m1
[+]          ^font-util@1.3.2%apple-clang@14.0.0 build_system=autotools fonts=encodings,font-adobe-100dpi,font-adobe-75dpi,font-adobe-utopia-100dpi,font-adobe-utopia-75dpi,font-adobe-utopia-type1,font-alias,font-arabic-misc,font-bh-100dpi,font-bh-75dpi,font-bh-lucidatypewriter-100dpi,font-bh-lucidatypewriter-75dpi,font-bh-type1,font-bitstream-100dpi,font-bitstream-75dpi,font-bitstream-speedo,font-bitstream-type1,font-cronyx-cyrillic,font-cursor-misc,font-daewoo-misc,font-dec-misc,font-ibm-type1,font-isas-misc,font-jis-misc,font-micro-misc,font-misc-cyrillic,font-misc-ethiopic,font-misc-meltho,font-misc-misc,font-mutt-misc,font-schumacher-misc,font-screen-cyrillic,font-sun-misc,font-winitzki-cyrillic,font-xfree86-type1 arch=darwin-monterey-m1
[+]              ^autoconf@2.69%apple-clang@14.0.0 build_system=autotools patches=35c4492,7793209,a49dd5b arch=darwin-monterey-m1
[+]              ^automake@1.16.5%apple-clang@14.0.0 build_system=autotools arch=darwin-monterey-m1
[+]              ^bdftopcf@1.0.5%apple-clang@14.0.0 build_system=autotools arch=darwin-monterey-m1
[+]                  ^fontsproto@2.1.3%apple-clang@14.0.0 build_system=autotools arch=darwin-monterey-m1
[+]                  ^libxfont@1.5.2%apple-clang@14.0.0 build_system=autotools arch=darwin-monterey-m1
[+]              ^mkfontdir@1.0.7%apple-clang@14.0.0 build_system=autotools arch=darwin-monterey-m1
[+]              ^mkfontscale@1.1.2%apple-clang@14.0.0 build_system=autotools arch=darwin-monterey-m1
[+]                  ^libfontenc@1.1.3%apple-clang@14.0.0 build_system=autotools arch=darwin-monterey-m1
[+]          ^gnuconfig@2021-08-14%apple-clang@14.0.0 build_system=generic arch=darwin-monterey-m1
[+]          ^gperf@3.1%apple-clang@14.0.0 build_system=autotools arch=darwin-monterey-m1
[+]      ^freetype@2.11.1%apple-clang@14.0.0 build_system=autotools arch=darwin-monterey-m1
[+]          ^bzip2@1.0.8%apple-clang@14.0.0~debug~pic+shared build_system=generic arch=darwin-monterey-m1
[+]              ^diffutils@3.8%apple-clang@14.0.0 build_system=autotools arch=darwin-monterey-m1
[+]      ^harfbuzz@5.1.0%apple-clang@14.0.0~coretext~graphite2~strip build_system=meson buildtype=debugoptimized default_library=shared arch=darwin-monterey-m1
[+]          ^cairo@1.16.0%apple-clang@14.0.0~X~fc+ft+gobject+pdf~png~svg build_system=autotools patches=7c4da77 arch=darwin-monterey-m1
[+]              ^libtool@2.4.7%apple-clang@14.0.0 build_system=autotools arch=darwin-monterey-m1
[+]              ^m4@1.4.19%apple-clang@14.0.0+sigsegv build_system=autotools patches=9dc5fbd,bfdffa7 arch=darwin-monterey-m1
[+]                  ^libsigsegv@2.13%apple-clang@14.0.0 build_system=autotools arch=darwin-monterey-m1
[+]              ^pixman@0.40.0%apple-clang@14.0.0 build_system=autotools arch=darwin-monterey-m1
[+]      ^icu4c@67.1%apple-clang@14.0.0 build_system=autotools cxxstd=11 arch=darwin-monterey-m1
[+]      ^libjpeg-turbo@2.1.3%apple-clang@14.0.0 build_system=generic arch=darwin-monterey-m1
[+]          ^nasm@2.15.05%apple-clang@14.0.0 build_system=autotools arch=darwin-monterey-m1
[+]      ^libpng@1.6.37%apple-clang@14.0.0 build_system=autotools arch=darwin-monterey-m1
[+]      ^libproxy@0.4.17%apple-clang@14.0.0~ipo~perl+python build_system=cmake build_type=RelWithDebInfo arch=darwin-monterey-m1
[+]      ^libxml2@2.10.1%apple-clang@14.0.0~python build_system=autotools arch=darwin-monterey-m1
[+]          ^libiconv@1.16%apple-clang@14.0.0 build_system=autotools libs=shared,static arch=darwin-monterey-m1
[+]          ^xz@5.2.7%apple-clang@14.0.0~pic build_system=autotools libs=shared,static arch=darwin-monterey-m1
[+]      ^ninja@1.11.1%apple-clang@14.0.0 build_system=generic arch=darwin-monterey-m1
[+]          ^re2c@2.2%apple-clang@14.0.0 build_system=generic arch=darwin-monterey-m1
[+]      ^openssl@1.1.1s%apple-clang@14.0.0~docs~shared build_system=generic certs=mozilla arch=darwin-monterey-m1
[+]          ^ca-certificates-mozilla@2022-10-11%apple-clang@14.0.0 build_system=generic arch=darwin-monterey-m1
[+]          ^perl@5.36.0%apple-clang@14.0.0+cpanm+shared+threads build_system=generic arch=darwin-monterey-m1
[+]              ^berkeley-db@18.1.40%apple-clang@14.0.0+cxx~docs+stl build_system=autotools patches=26090f4,b231fcc arch=darwin-monterey-m1
[+]      ^pcre2@10.39%apple-clang@14.0.0~jit+multibyte build_system=autotools arch=darwin-monterey-m1
[+]      ^pkgconf@1.8.0%apple-clang@14.0.0 build_system=autotools arch=darwin-monterey-m1
[+]      ^python@3.10.8%apple-clang@14.0.0+bz2+crypt+ctypes+dbm~debug+libxml2+lzma~nis~optimizations+pic+pyexpat+pythoncmd+readline+shared+sqlite3+ssl~tkinter+uuid+zlib build_system=generic patches=0d98e93,7d40923,f2fd060 arch=darwin-monterey-m1
[+]          ^expat@2.4.8%apple-clang@14.0.0~libbsd build_system=autotools arch=darwin-monterey-m1
[+]          ^gdbm@1.23%apple-clang@14.0.0 build_system=autotools arch=darwin-monterey-m1
[+]          ^libffi@3.4.2%apple-clang@14.0.0 build_system=autotools arch=darwin-monterey-m1
[+]          ^libxcrypt@4.4.31%apple-clang@14.0.0~obsolete_api build_system=autotools arch=darwin-monterey-m1
[+]          ^readline@8.1.2%apple-clang@14.0.0 build_system=autotools arch=darwin-monterey-m1
[+]      ^sqlite@3.39.4%apple-clang@14.0.0+column_metadata+dynamic_extensions+fts~functions+rtree build_system=autotools arch=darwin-monterey-m1
[+]      ^zlib@1.2.13%apple-clang@14.0.0+optimize+pic+shared build_system=makefile arch=darwin-monterey-m1
[+]      ^zstd@1.5.2%apple-clang@14.0.0+programs build_system=makefile compression=none libs=shared,static arch=darwin-monterey-m1
```


### Error message

```
CMake Error at cmake/QtBuildInformation.cmake:472 (message):
  Feature "libproxy": Forcing to "ON" breaks its condition:

      Libproxy_FOUND

  Condition values dump:

      Libproxy_FOUND = "0"
...
ERROR: Feature "libproxy": Forcing to "ON" breaks its condition:
    Libproxy_FOUND
Condition values dump:
    Libproxy_FOUND = "0"
```

### Information on your system

* **Spack:** 0.20.0.dev0 (684ae1106efee53d2925da43bf2864178d71378e)
* **Python:** 3.10.8
* **Platform:** darwin-monterey-m1
* **Concretizer:** clingo


### Additional information

* [spack-build-out.txt](https://github.com/spack/spack/files/10058500/spack-build-out.txt)
* [spack-build-env-mods.txt](https://github.com/spack/spack/files/10058501/spack-build-env-mods.txt)

@wdconinc @sethrj 

### General information

- [X] I have run `spack debug report` and reported the version of Spack/Python/Platform
- [X] I have run `spack maintainers <name-of-the-package>` and **@mentioned** any maintainers
- [X] I have uploaded the build log and environment files
- [X] I have searched the issues of this repo and believe this is not a duplicate


Discussion:
As a workaround, `qt-base~network` seems to build fine. Ideally we should fix `qt-base+network`. If we can't fix that, we should consider adding a conflict or defaulting to False. This will also minimize the number of dependencies and speed up build times.
I think the reason why `libproxy` is not found on macOS is that `FindLibproxy..cmake` relies on PkgConfig. But on macOS, using PkgConfig is disabled unless explicitly requested otherwise with `FEATURE_pkg_config`.

But it seems that `libproxy` would not be used on macOS regardless, as `src/network/CMakeLists.txt` does not use libproxy if `MACOS` is set.

The next hurdle is linking against the GSS framework: [QTBUG-114537](https://bugreports.qt.io/browse/QTBUG-114537). Until fixed upstream, this probably requires a patch against qt-base.

I also had problems with the `at-spi2-core` dependency if `+accessibility` and with `+dbus`, as both rely on `dbus`. And dbus did not build because of unbuildable `xmlto` due to a missing `getopt` with support for long options.

Resolving patch:
diff --git a/var/spack/repos/builtin/packages/qt-base/package.py b/var/spack/repos/builtin/packages/qt-base/package.py
--- a/var/spack/repos/builtin/packages/qt-base/package.py
+++ b/var/spack/repos/builtin/packages/qt-base/package.py
@@ -36,7 +36,7 @@ def get_list_url(qualname):
     # Default dependencies for all qt-* components
     generator("ninja")
     depends_on("cmake@3.16:", type="build")
-    depends_on("pkgconfig", type="build")
+    depends_on("pkgconfig", type="build", when="platform=linux")
     depends_on("python", type="build")
 
     # List of unnecessary directories in src/3rdparty
@@ -125,8 +125,7 @@ class QtBase(QtPackage):
     depends_on("zstd")
     with when("platform=linux"):
         depends_on("libdrm")
-
-    depends_on("at-spi2-core", when="+accessibility")
+        depends_on("at-spi2-core", when="+accessibility")
     depends_on("dbus", when="+dbus")
     depends_on("gl", when="+opengl")
     depends_on("sqlite", when="+sql")
@@ -143,12 +142,24 @@ class QtBase(QtPackage):
             depends_on("libxrender")
 
     with when("+network"):
-        depends_on("libproxy")
         depends_on("openssl")
+        with when("platform=linux"):
+            depends_on("libproxy")
 
     # Qt6 requires newer compilers: see https://github.com/spack/spack/issues/34418
     conflicts("%gcc@:7")
 
+    # ensure that Qt links against GSS framework on macOS: https://bugreports.qt.io/browse/QTBUG-114537
+    with when("@6.3.2:6.5.1"):
+        patch(
+            "https://github.com/qt/qtbase/commit/c3d3e7312499189dde2ff9c0cb14bd608d6fd1cd.patch?full_index=1",
+            sha256="85c16db15406b0094831bb57016dab7e0c0fd0978b082a1dc103c87334db7915",
+        )
+        patch(
+            "https://github.com/qt/qtbase/commit/1bf144ba78ff10d712b4de55d2797b9256948a1d.patch?full_index=1",
+            sha256="e4d9f1aee0566558e77eef5609b63c1fde3f3986bea1b9d5d7930b297f916a5e",
+        )
+
     @property
     def archive_files(self):
         """Save both the CMakeCache and the config summary."""
@@ -206,7 +217,9 @@ def define_feature(key, variant=None):
         if "+dbus" in spec:
             features.append("dbus_linked")
         if "+network" in spec:
-            features += ["openssl_linked", "openssl", "libproxy"]
+            features.extend(["openssl_linked", "openssl"])
+            if sys.platform == "linux":
+                features.append("libproxy")
         for k in features:
             define("FEATURE_" + k, True)
 


Test patch: