Repository: spack/spack

Issue:
Error installing ISAAC (Header-Only, CMake)
When installing the *header-only* lib ISAAC ~~, which adds `cuda` only as a dependency to trigger it properly for further packages, *without* cuda as `spack install isaac~cuda`~~ it fails on dev as of 4553b14 with:

```
==> Building isaac [CMakePackage]
==> Executing phase : 'cmake'
==> Error: ProcessError: Command exited with status 1:
    'cmake' 'lib' '-DCMAKE_INSTALL_PREFIX:PATH=/home/huebl/src/spack/opt/spack/linux-ubuntu14-x86_64/gcc-4.9.4/isaac-1.3.0-jzcorqen6kzdxtmadagngp4c427ezl73' '-DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo' '-DCMAKE_VERBOSE_MAKEFILE:BOOL=ON' '-DCMAKE_INSTALL_RPATH_USE_LINK_PATH:BOOL=FALSE' '-DCMAKE_INSTALL_RPATH:STRING=/home/huebl/src/spack/opt/spack/linux-ubuntu14-x86_64/gcc-4.9.4/isaac-1.3.0-jzcorqen6kzdxtmadagngp4c427ezl73/lib:/home/huebl/src/spack/opt/spack/linux-ubuntu14-x86_64/gcc-4.9.4/isaac-1.3.0-jzcorqen6kzdxtmadagngp4c427ezl73/lib64:/home/huebl/src/spack/opt/spack/linux-ubuntu14-x86_64/gcc-4.9.4/boost-1.63.0-bmtnfubo2dxn3guljshax3m4e2u3lglo/lib:/home/huebl/src/spack/opt/spack/linux-ubuntu14-x86_64/gcc-4.9.4/bzip2-1.0.6-syidqu3x4z355sx5af5ny7okyuhed53q/lib:/home/huebl/src/spack/opt/spack/linux-ubuntu14-x86_64/gcc-4.9.4/zlib-1.2.11-q4s2ymg5cupvjutwgdkiklljvsyfhrpf/lib:/home/huebl/src/spack/opt/spack/linux-ubuntu14-x86_64/gcc-4.9.4/icet-2.1.1-4qdinyo3wuas27azfuhxec6ypmdhv3i2/lib:/home/huebl/src/spack/opt/spack/linux-ubuntu14-x86_64/gcc-4.9.4/openmpi-2.1.1-472ow5qjauqtelugdtre6mzqw4sz6dhq/lib:/home/huebl/src/spack/opt/spack/linux-ubuntu14-x86_64/gcc-4.9.4/hwloc-1.11.7-2dmlsfml3ll6tqrhuysm2sz4kvaktutf/lib:/home/huebl/src/spack/opt/spack/linux-ubuntu14-x86_64/gcc-4.9.4/libpciaccess-0.13.4-a6t5336vlegdoaly3qq6opmlmd6zbhzz/lib:/home/huebl/src/spack/opt/spack/linux-ubuntu14-x86_64/gcc-4.9.4/libxml2-2.9.4-qhrsnhlkmv2d26xnmz777fsliwqepbd5/lib:/home/huebl/src/spack/opt/spack/linux-ubuntu14-x86_64/gcc-4.9.4/xz-5.2.3-x5bmsfrloulpquxn23qh25uvmvnpbovy/lib:/home/huebl/src/spack/opt/spack/linux-ubuntu14-x86_64/gcc-4.9.4/jansson-2.9-sy2abdelpa5bauao5fimruuta6js5uss/lib:/home/huebl/src/spack/opt/spack/linux-ubuntu14-x86_64/gcc-4.9.4/libjpeg-turbo-1.5.0-p5tj52s2ouwl5ajv4ed5krd6rg7bebyz/lib'
/home/huebl/src/spack/lib/spack/spack/build_systems/cmake.py:149, in cmake:
     144      def cmake(self, spec, prefix):
     145          """Runs ``cmake`` in the build directory"""
     146          options = [self.root_cmakelists_dir] + self.std_cmake_args + \
     147              self.cmake_args()
     148          with working_dir(self.build_directory, create=True):
  >> 149              inspect.getmodule(self).cmake(*options)

# log:
==> 'cmake' 'lib' '-DCMAKE_INSTALL_PREFIX:PATH=/home/huebl/src/spack/opt/spack/linux-ubuntu14-x86_64/gcc-4.9.4/isaac-1.3.0-jzcorqen6kzdxtmadagngp4c427ezl73' '-DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo' '-DCMAKE_VERBOSE_MAKEFILE:BOOL=ON' '-DCMAKE_INSTALL_RPATH_USE_LINK_PATH:BOOL=FALSE' '-DCMAKE_INSTALL_RPATH:STRING=/home/huebl/src/spack/opt/spack/linux-ubuntu14-x86_64/gcc-4.9.4/isaac-1.3.0-jzcorqen6kzdxtmadagngp4c427ezl73/lib:/home/huebl/src/spack/opt/spack/linux-ubuntu14-x86_64/gcc-4.9.4/isaac-1.3.0-jzcorqen6kzdxtmadagngp4c427ezl73/lib64:/home/huebl/src/spack/opt/spack/linux-ubuntu14-x86_64/gcc-4.9.4/boost-1.63.0-bmtnfubo2dxn3guljshax3m4e2u3lglo/lib:/home/huebl/src/spack/opt/spack/linux-ubuntu14-x86_64/gcc-4.9.4/bzip2-1.0.6-syidqu3x4z355sx5af5ny7okyuhed53q/lib:/home/huebl/src/spack/opt/spack/linux-ubuntu14-x86_64/gcc-4.9.4/zlib-1.2.11-q4s2ymg5cupvjutwgdkiklljvsyfhrpf/lib:/home/huebl/src/spack/opt/spack/linux-ubuntu14-x86_64/gcc-4.9.4/icet-2.1.1-4qdinyo3wuas27azfuhxec6ypmdhv3i2/lib:/home/huebl/src/spack/opt/spack/linux-ubuntu14-x86_64/gcc-4.9.4/openmpi-2.1.1-472ow5qjauqtelugdtre6mzqw4sz6dhq/lib:/home/huebl/src/spack/opt/spack/linux-ubuntu14-x86_64/gcc-4.9.4/hwloc-1.11.7-2dmlsfml3ll6tqrhuysm2sz4kvaktutf/lib:/home/huebl/src/spack/opt/spack/linux-ubuntu14-x86_64/gcc-4.9.4/libpciaccess-0.13.4-a6t5336vlegdoaly3qq6opmlmd6zbhzz/lib:/home/huebl/src/spack/opt/spack/linux-ubuntu14-x86_64/gcc-4.9.4/libxml2-2.9.4-qhrsnhlkmv2d26xnmz777fsliwqepbd5/lib:/home/huebl/src/spack/opt/spack/linux-ubuntu14-x86_64/gcc-4.9.4/xz-5.2.3-x5bmsfrloulpquxn23qh25uvmvnpbovy/lib:/home/huebl/src/spack/opt/spack/linux-ubuntu14-x86_64/gcc-4.9.4/jansson-2.9-sy2abdelpa5bauao5fimruuta6js5uss/lib:/home/huebl/src/spack/opt/spack/linux-ubuntu14-x86_64/gcc-4.9.4/libjpeg-turbo-1.5.0-p5tj52s2ouwl5ajv4ed5krd6rg7bebyz/lib'
CMake Error: The source directory "/tmp/huebl/spack-stage/spack-stage-Mm6zef/isaac-1.3.0/spack-build/lib" does not exist.
```

Is this an error in our cmake install of `ISAAC` or in spack's `build_systems/cmake.py`?
As a header-only lib, we don't create a `lib/` on install and only copy `include/`s.

**update:** also happens with CUDA as of `spack install isaac` with the same error.


Discussion:
`Dockerfile` to reproduce via `docker build .`:
```
FROM       ubuntu:14.04

# general environment for docker
ENV        HOME /home
ENV        DEBIAN_FRONTEND noninteractive

# spack environment
ENV        PATH "$HOME/src/spack/bin:$PATH"

# install minimal spack dependencies
#   also adds gfortran for spack's openmpi package
RUN        apt-get update \
           && apt-get install -y --no-install-recommends \
              autoconf \
              ca-certificates \
              curl \
              gfortran \
              git \
              build-essential \
              python \
           && rm -rf /var/lib/apt/lists/*

# install spack
RUN        git clone --depth 50 https://github.com/llnl/spack.git \
           $HOME/src/spack/

# install PIConGPU dependencies
RUN        spack install isaac
```
The reason lies (same with `isaac-server`) in the `root_cmakelists_dir` variable.

For some reason, it's not relative to the repo root any more but needs to start with `../` to get out of the `spack-build/` dir.

Is this intended or did this accidentally change?
oh, or should I write `self.stage.source_path + relative_path` there?

```python
def root_cmakelists_dir(self):
    """Directory where to find the root CMakeLists.txt"""
    return self.stage.source_path
```

Resolving patch:
diff --git a/var/spack/repos/builtin/packages/isaac-server/package.py b/var/spack/repos/builtin/packages/isaac-server/package.py
--- a/var/spack/repos/builtin/packages/isaac-server/package.py
+++ b/var/spack/repos/builtin/packages/isaac-server/package.py
@@ -31,7 +31,9 @@ class IsaacServer(CMakePackage):
     homepage = "http://computationalradiationphysics.github.io/isaac/"
     url      = "https://github.com/ComputationalRadiationPhysics/isaac/archive/v1.3.0.tar.gz"
 
-    root_cmakelists_dir = 'server'
+    @property
+    def root_cmakelists_dir(self):
+        return join_path(self.stage.source_path, 'server')
 
     version('develop', branch='dev',
             git='https://github.com/ComputationalRadiationPhysics/isaac.git')
diff --git a/var/spack/repos/builtin/packages/isaac/package.py b/var/spack/repos/builtin/packages/isaac/package.py
--- a/var/spack/repos/builtin/packages/isaac/package.py
+++ b/var/spack/repos/builtin/packages/isaac/package.py
@@ -31,7 +31,9 @@ class Isaac(CMakePackage):
     homepage = "http://computationalradiationphysics.github.io/isaac/"
     url      = "https://github.com/ComputationalRadiationPhysics/isaac/archive/v1.3.0.tar.gz"
 
-    root_cmakelists_dir = 'lib'
+    @property
+    def root_cmakelists_dir(self):
+        return join_path(self.stage.source_path, 'lib')
 
     version('develop', branch='dev',
             git='https://github.com/ComputationalRadiationPhysics/isaac.git')


Test patch: