facebook / wangle

Wangle is a framework providing a set of common client/server abstractions for building services in a consistent, modular, and composable way.
Apache License 2.0
3.04k stars 536 forks source link

Build Fail: 'openssl/ssl.h' file not found #40

Closed huntzhan closed 8 years ago

huntzhan commented 8 years ago

System: OS X 10.11.4

openssl is installed by homebrew, brew install openssl.

CMake command-line options: cmake -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl/ .

Following log shows that cmake found openssl successfully:

$ cd wangle
$ cmake -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl/ .
-- The C compiler identification is AppleClang 7.3.0.7030029
-- The CXX compiler identification is AppleClang 7.3.0.7030029
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found Folly: /usr/local/include  
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - found
-- Found Threads: TRUE  
-- Boost version: 1.60.0
-- Found the following Boost libraries:
--   system
--   thread
--   filesystem
--   chrono
--   date_time
--   atomic
-- Found OpenSSL: /usr/local/opt/openssl/lib/libssl.dylib;/usr/local/opt/openssl/lib/libcrypto.dylib (found version "1.0.2g")
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/haoxun/Temp/wangle/wangle

But, make complains that <openssl/ssl.h> not found:

$ make
Scanning dependencies of target wangle
[  1%] Building CXX object CMakeFiles/wangle.dir/acceptor/Acceptor.cpp.o
In file included from /Users/haoxun/Temp/wangle/wangle/acceptor/Acceptor.cpp:10:
In file included from /Users/haoxun/Temp/wangle/wangle/../wangle/acceptor/Acceptor.h:12:
In file included from /Users/haoxun/Temp/wangle/wangle/../wangle/acceptor/ServerSocketConfig.h:13:
In file included from /Users/haoxun/Temp/wangle/wangle/../wangle/ssl/SSLContextConfig.h:14:
/usr/local/include/folly/io/async/SSLContext.h:26:10: fatal error: 'openssl/ssl.h' file not found
#include <openssl/ssl.h>
         ^
1 error generated.
make[2]: *** [CMakeFiles/wangle.dir/acceptor/Acceptor.cpp.o] Error 1
make[1]: *** [CMakeFiles/wangle.dir/all] Error 2
make: *** [all] Error 2

I've check the CMakeCache.txt, seems there's nothing wrong:

//Path to a library.
OPENSSL_CRYPTO_LIBRARY:FILEPATH=/usr/local/opt/openssl/lib/libcrypto.dylib

//Path to a file.
OPENSSL_INCLUDE_DIR:PATH=/usr/local/opt/openssl/include

//No help, variable specified on the command line.
OPENSSL_ROOT_DIR:UNINITIALIZED=/usr/local/opt/openssl/

//Path to a library.
OPENSSL_SSL_LIBRARY:FILEPATH=/usr/local/opt/openssl/lib/libssl.dylib

OPENSSL_INCLUDE_DIR detected by cmake is correct, of course:

$ cd /usr/local/opt/openssl/include
$ tree
.
└── openssl
    ├── aes.h
    ├── asn1.h
    ├── asn1_mac.h
    ├── asn1t.h
    ├── bio.h
    ├── blowfish.h
    ├── bn.h
    ├── buffer.h
    ├── camellia.h
    ├── cast.h
    ├── cmac.h
    ├── cms.h
    ├── comp.h
    ├── conf.h
    ├── conf_api.h
    ├── crypto.h
    ├── des.h
    ├── des_old.h
    ├── dh.h
    ├── dsa.h
    ├── dso.h
    ├── dtls1.h
    ├── e_os2.h
    ├── ebcdic.h
    ├── ec.h
    ├── ecdh.h
    ├── ecdsa.h
    ├── engine.h
    ├── err.h
    ├── evp.h
    ├── hmac.h
    ├── idea.h
    ├── krb5_asn.h
    ├── kssl.h
    ├── lhash.h
    ├── md4.h
    ├── md5.h
    ├── mdc2.h
    ├── modes.h
    ├── obj_mac.h
    ├── objects.h
    ├── ocsp.h
    ├── opensslconf.h
    ├── opensslv.h
    ├── ossl_typ.h
    ├── pem.h
    ├── pem2.h
    ├── pkcs12.h
    ├── pkcs7.h
    ├── pqueue.h
    ├── rand.h
    ├── rc2.h
    ├── rc4.h
    ├── ripemd.h
    ├── rsa.h
    ├── safestack.h
    ├── seed.h
    ├── sha.h
    ├── srp.h
    ├── srtp.h
    ├── ssl.h
    ├── ssl2.h
    ├── ssl23.h
    ├── ssl3.h
    ├── stack.h
    ├── symhacks.h
    ├── tls1.h
    ├── ts.h
    ├── txt_db.h
    ├── ui.h
    ├── ui_compat.h
    ├── whrlpool.h
    ├── x509.h
    ├── x509_vfy.h
    └── x509v3.h

1 directory, 75 files

In conclusion, I guess there's something wrong in the CMakeLists.txt.