Repository: spack/spack

Issue:
cmake@3.6.1 fails to build, cmake@3.7.2
With a copy of spack/devel cloned yesterday, `cmake@3.6.1` fails to build on my usual CentOS7 devel machine (though it has melted down and been reimaged).  It built previously, but I've been doing other things for the past few weeks and can't easily identify when it broke.

There seems to be some incompatibility with OpenSSL (which perhaps should be providing type info for`ctx`).  I was attempting to install it as:

```
spack install cmake@3.6.1
```

I'm not worried, I'm going to bump up to `cmake@3.7.2`, which seems to build just fine.

@tgamblin or ..., please feel free to close this unless it piques your interest.

**BUT**, just in case someone else stumbles into this, here are the bits around the errors from `.../spack-stage/spack-stage-I4GjA0/cmake-3.6.1/spack-build.out`.

```
[ 52%] Building C object Utilities/cmcurl/lib/CMakeFiles/cmcurl.dir/inet_pton.c.o
Scanning dependencies of target cmsysTestsCxx
In file included from /tmp/hartzelg/spack-stage/spack-stage-I4GjA0/cmake-3.6.1/Utilities/cmlibarchive/libarchive/archive_cryptor.c:32:0:
/tmp/hartzelg/spack-stage/spack-stage-I4GjA0/cmake-3.6.1/Utilities/cmlibarchive/libarchive/archive_cryptor_private.h:107:17: error: field ‘ctx’ has incomplete type
  EVP_CIPHER_CTX ctx;
                 ^
make[2]: *** [Utilities/cmlibarchive/libarchive/CMakeFiles/cmlibarchive.dir/archive_cryptor.c.o] Error 1
make[2]: *** Waiting for unfinished jobs....
[ 52%] Building C object Source/kwsys/CMakeFiles/cmsysTestDynload.dir/testDynload.c.o
```

and 

```
[ 56%] Building CXX object Source/kwsys/CMakeFiles/cmsysTestsCxx.dir/testDynamicLoader.cxx.o
/tmp/hartzelg/spack-stage/spack-stage-I4GjA0/cmake-3.6.1/Utilities/cmlibarchive/libarchive/archive_hmac.c: In function ‘__hmac_sha1_cleanup’:
/tmp/hartzelg/spack-stage/spack-stage-I4GjA0/cmake-3.6.1/Utilities/cmlibarchive/libarchive/archive_hmac.c:203:24: error: dereferencing pointer to incomplete type ‘archive_hmac_sha1_ctx {aka struct hmac_ctx_st}’
  memset(ctx, 0, sizeof(*ctx));
                        ^
make[2]: *** [Utilities/cmlibarchive/libarchive/CMakeFiles/cmlibarchive.dir/archive_hmac.c.o] Error 1
[ 56%] Building C object Utilities/cmcurl/lib/CMakeFiles/cmcurl.dir/tftp.c.o
[ 56%] Building C object Utilities/cmcurl/lib/CMakeFiles/cmcurl.dir/splay.c.o
```

and finally

```
[ 64%] Building C object Utilities/cmcurl/lib/CMakeFiles/cmcurl.dir/vtls/axtls.c.o
[ 64%] Building C object Utilities/cmcurl/lib/CMakeFiles/cmcurl.dir/vtls/cyassl.c.o
In file included from /tmp/hartzelg/spack-stage/spack-stage-I4GjA0/cmake-3.6.1/Utilities/cmlibarchive/libarchive/archive_read_support_format_zip.c:58:0:
/tmp/hartzelg/spack-stage/spack-stage-I4GjA0/cmake-3.6.1/Utilities/cmlibarchive/libarchive/archive_cryptor_private.h:107:17: error: field ‘ctx’ has incomplete type
  EVP_CIPHER_CTX ctx;
                 ^
[ 64%] Building C object Utilities/cmcurl/lib/CMakeFiles/cmcurl.dir/vtls/schannel.c.o
[ 65%] Building C object Utilities/cmcurl/lib/CMakeFiles/cmcurl.dir/vtls/gskit.c.o
[ 65%] Building C object Utilities/cmcurl/lib/CMakeFiles/cmcurl.dir/vtls/darwinssl.c.o
/tmp/hartzelg/spack-stage/spack-stage-I4GjA0/cmake-3.6.1/Utilities/cmlibarchive/libarchive/archive_read_support_format_zip.c:206:24: error: field ‘hctx’ has incomplete type
  archive_hmac_sha1_ctx hctx;
                        ^
make[2]: *** [Utilities/cmlibarchive/libarchive/CMakeFiles/cmlibarchive.dir/archive_read_support_format_zip.c.o] Error 1
[ 65%] Built target cmsysTestDynload
In file included from /tmp/hartzelg/spack-stage/spack-stage-I4GjA0/cmake-3.6.1/Utilities/cmlibarchive/libarchive/archive_write_set_format_zip.c:52:0:
/tmp/hartzelg/spack-stage/spack-stage-I4GjA0/cmake-3.6.1/Utilities/cmlibarchive/libarchive/archive_cryptor_private.h:107:17: error: field ‘ctx’ has incomplete type
  EVP_CIPHER_CTX ctx;
                 ^
/tmp/hartzelg/spack-stage/spack-stage-I4GjA0/cmake-3.6.1/Utilities/cmlibarchive/libarchive/archive_write_set_format_zip.c:142:24: error: field ‘hctx’ has incomplete type
  archive_hmac_sha1_ctx hctx;
                        ^
/tmp/hartzelg/spack-stage/spack-stage-I4GjA0/cmake-3.6.1/Utilities/cmlibarchive/libarchive/archive_write_set_format_zip.c: In function ‘is_winzip_aes_encryption_supported’:
/tmp/hartzelg/spack-stage/spack-stage-I4GjA0/cmake-3.6.1/Utilities/cmlibarchive/libarchive/archive_write_set_format_zip.c:1650:24: error: storage size of ‘hctx’ isn’t known
  archive_hmac_sha1_ctx hctx;
                        ^
make[2]: *** [Utilities/cmlibarchive/libarchive/CMakeFiles/cmlibarchive.dir/archive_write_set_format_zip.c.o] Error 1
make[1]: *** [Utilities/cmlibarchive/libarchive/CMakeFiles/cmlibarchive.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
/tmp/hartzelg/spack-stage/spack-stage-I4GjA0/cmake-3.6.1/Utilities/cmcurl/lib/vtls/openssl.c: In function ‘get_cert_chain’:
/tmp/hartzelg/spack-stage/spack-stage-I4GjA0/cmake-3.6.1/Utilities/cmcurl/lib/vtls/openssl.c:2482:13: error: dereferencing pointer to incomplete type ‘X509 {aka struct x509_st}’
     cinf = x->cert_info;
             ^
/tmp/hartzelg/spack-stage/spack-stage-I4GjA0/cmake-3.6.1/Utilities/cmcurl/lib/vtls/openssl.c:2484:30: error: dereferencing pointer to incomplete type ‘X509_CINF {aka struct x509_cinf_st}’
     j = asn1_object_dump(cinf->signature->algorithm, bufp, CERTBUFFERSIZE);
                              ^
/tmp/hartzelg/spack-stage/spack-stage-I4GjA0/cmake-3.6.1/Utilities/cmcurl/lib/vtls/openssl.c:2510:20: error: dereferencing pointer to incomplete type ‘EVP_PKEY {aka struct evp_pkey_st}’
       switch(pubkey->type) {
                    ^
make[2]: *** [Utilities/cmcurl/lib/CMakeFiles/cmcurl.dir/vtls/openssl.c.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [Utilities/cmcurl/lib/CMakeFiles/cmcurl.dir/all] Error 2
[ 65%] Linking CXX executable cmsysTestsCxx
[ 65%] Built target cmsysTestsCxx
make: *** [all] Error 2
```


Discussion:
Looks like it has to do with the OpenSSL version.

https://cmake.org/pipermail/cmake/2016-November/064631.html

i have `cmake@3.7.1` build with `openssl@1.0.2j`. Probably `cmake` should specify version dependency in `openssl`
something like
```
    depends_on("openssl@:1.0.99", when='@:3.6.9+openssl')
    depends_on("openssl", when='@3.7:+openssl')
```
@hartzell feel free to add a PR if this direction works for you.

Resolving patch:
diff --git a/var/spack/repos/builtin/packages/cmake/package.py b/var/spack/repos/builtin/packages/cmake/package.py
--- a/var/spack/repos/builtin/packages/cmake/package.py
+++ b/var/spack/repos/builtin/packages/cmake/package.py
@@ -63,7 +63,8 @@ class Cmake(Package):
     depends_on('qt',             when='+qt')
     depends_on('python@2.7.11:', when='+doc', type='build')
     depends_on('py-sphinx',      when='+doc', type='build')
-    depends_on('openssl',        when='+openssl')
+    depends_on("openssl", when='+openssl')
+    depends_on("openssl@:1.0.99", when='@:3.6.9+openssl')
     depends_on('ncurses',        when='+ncurses')
 
     # Cannot build with Intel, should be fixed in 3.6.2


Test patch: