CMake generally works great with macOS Homebrew. However, CMake FindOpenSSL may fail when OpenSSL was installed via:
brew install openssl
A simple fix when configuring a CMake project is to specify OPENSSL_ROOT_DIR:
cmake -B build -DOPENSSL_ROOT_DIR=$(brew --prefix firstname.lastname@example.org)
then build and test as usual. This is necessary because at this time the OpenSSL world is gradually transitioning from OpenSSL 1.1 to 3, and Homebrew uses subdirectory to isolate the OpenSSL installs. CMake does not recursively search as that would in general not have a stopping condition and at least significantly slow down the search performance.