[CDRIVER-2493] Better handle OpenSSL on macOS in CMake Created: 05/Feb/18  Updated: 28/Oct/23  Resolved: 20/Feb/18

Status: Closed
Project: C Driver
Component/s: docs
Affects Version/s: 1.9.2
Fix Version/s: 1.10.0

Type: Improvement Priority: Minor - P4
Reporter: Kevin Albertson Assignee: Kevin Albertson
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Epic Link: Remove Autotools

 Description   

When building with OpenSSL on macOS you may run into some non-obvious issues.

Copied from our C Driver Development guide:

Use OpenSSL on macOS:

brew install openssl
cmake -DENABLE_SSL=OPENSSL -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl/lib -DOPENSSL_INCLUDE_DIR=/usr/local/opt/openssl/include .
make

You may need to rm -rf CMakeCache.txt CMakeFiles/ in order to clear the default Darwin SSL CMake configuration from a previous build

Looking at our CMakeLists.txt file it looks like ENABLE_SSL=OPENSSL is the only necessary define. It might be worth printing out a message if the OS is macOS and ENABLE_SSL=OPENSSL is defined without OPENSSL_ROOT_DIR or OPENSSL_INCLUDE_DIR.

In my case, CMake was including OpenSSL from one directory I was trying to build against in
but it was trying to link it from another. The solution was to define OPENSSL_ROOT_DIR to the OpenSSL directory I wanted to link to.



 Comments   
Comment by Githook User [ 20/Feb/18 ]

Author:

{'email': 'kevin.albertson@10gen.com', 'name': 'Kevin Albertson', 'username': 'kevinAlbs'}

Message: CDRIVER-2493 warning for mac users using OpenSSL
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/5aed98d813d464d952200b848adb1d92720d33b9

Generated at Wed Feb 07 21:15:23 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.