Repository: spack/spack

Issue:
r@3.5.0 +X +external-lapack ^intel-mkl
Hi all, having an issue installing with R with X support and specifically cairo pdf support. Running the following:

```
[root@gosset:~]# uname -r
3.10.0-693.21.1.el7.x86_64
[root@gosset:~]# cat /etc/redhat-release
CentOS Linux release 7.4.1708 (Core)
[root@gosset:~]# spack --version
0.12.0
```

Compile is generating the following error:

```
make[7]: Entering directory `/mnt/beegfs/spackroot/var/spack/stage/r-3.5.0-r6gj4fvdxmjbevpx3wagkh5nwtgucyxf/R-3.5.0/src/library/grDevices/src/cairo'
making cairoBM.d from cairoBM.c
In file included from cairoBM.h:51:0,
                 from cairoBM.c:60:
/usr/include/cairo/cairo-pdf.h:91:3: error: #error Cairo was not compiled with support for the pdf backend
 # error Cairo was not compiled with support for the pdf backend
   ^~~~~
make[7]: *** [cairoBM.d] Error 1
make[7]: Leaving directory `/mnt/beegfs/spackroot/var/spack/stage/r-3.5.0-r6gj4fvdxmjbevpx3wagkh5nwtgucyxf/R-3.5.0/src/library/grDevices/src/cairo'
make[6]: *** [cairodevice] Error 2
make[6]: Leaving directory `/mnt/beegfs/spackroot/var/spack/stage/r-3.5.0-r6gj4fvdxmjbevpx3wagkh5nwtgucyxf/R-3.5.0/src/library/grDevices/src'
make[5]: *** [all] Error 2
make[5]: Leaving directory `/mnt/beegfs/spackroot/var/spack/stage/r-3.5.0-r6gj4fvdxmjbevpx3wagkh5nwtgucyxf/R-3.5.0/src/library/grDevices/src'
make[4]: *** [mksrc] Error 1
make[4]: Leaving directory `/mnt/beegfs/spackroot/var/spack/stage/r-3.5.0-r6gj4fvdxmjbevpx3wagkh5nwtgucyxf/R-3.5.0/src/library/grDevices'
make[3]: *** [all] Error 2
make[3]: Leaving directory `/mnt/beegfs/spackroot/var/spack/stage/r-3.5.0-r6gj4fvdxmjbevpx3wagkh5nwtgucyxf/R-3.5.0/src/library/grDevices'
make[2]: *** [R] Error 1
make[2]: Leaving directory `/mnt/beegfs/spackroot/var/spack/stage/r-3.5.0-r6gj4fvdxmjbevpx3wagkh5nwtgucyxf/R-3.5.0/src/library'
make[1]: *** [R] Error 1
make[1]: Leaving directory `/mnt/beegfs/spackroot/var/spack/stage/r-3.5.0-r6gj4fvdxmjbevpx3wagkh5nwtgucyxf/R-3.5.0/src'
make: *** [R] Error 1

```

It looks to be referencing the systems host cairo installation: /usr/include/cairo
This doesn't appear to be the desired behavior, as cairo is installed under the $SPACK_ROOT/opt. This is still the case after explicitly loading the cairo package:

```
[root@gosset:~]# module list

Currently Loaded Modules:
  1) gcc/7.4.0   2) cairo/1.16.0

```

I dont think it's pkg-config oriented, because the module load prepends the cflags appropriately:

```
[root@gosset:~]# module purge
[root@gosset:~]# pkg-config --cflags cairo-pdf
-I/usr/include/cairo -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng15 -I/usr/include/libdrm
[root@gosset:~]# module load gcc cairo
[root@gosset:~]# pkg-config --cflags cairo-pdf
-I/mnt/beegfs/spackroot/opt/spack/linux-centos7-x86_64/gcc-7.4.0/cairo-1.16.0-jeocqqxc7fn7m5oo5ugepyu4tcyowmmo/include/cairo -I/usr/include/cairo -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng15

```




Discussion:
You need to build R with X support `spack install r+X`, which will pull in Cairo with X support and Pango with X support and *etc*....

So I used:

spack install  r@3.5.0 +X +external-lapack ^intel-mkl

That should pull the pango, and Cairo dependancies, or am I missing something?

Resolving patch:
diff --git a/var/spack/repos/builtin/packages/r/package.py b/var/spack/repos/builtin/packages/r/package.py
--- a/var/spack/repos/builtin/packages/r/package.py
+++ b/var/spack/repos/builtin/packages/r/package.py
@@ -60,7 +60,7 @@ class R(AutotoolsPackage):
     depends_on('bzip2')
     depends_on('libtiff')
     depends_on('jpeg')
-    depends_on('cairo')
+    depends_on('cairo+pdf')
     depends_on('cairo+X', when='+X')
     depends_on('cairo~X', when='~X')
     depends_on('pango')


Test patch: