microsoft / cpprestsdk

The C++ REST SDK is a Microsoft project for cloud-based client-server communication in native code using a modern asynchronous C++ API design. This project aims to help C++ developers connect to and interact with services.
Other
8.02k stars 1.66k forks source link

Build fails not finding openssl on GitHub MacOS runner #1798

Open srihari-vistrian opened 4 months ago

srihari-vistrian commented 4 months ago

I am using the CPPRESTSDK (awesome sdk BTW) in my project and including it using CPM module and having issues building it on the GitHub MacOS runner:

brew install uses a different location on the GitHub MacOS runner:

==> Downloading https://ghcr.io/v2/homebrew/core/openssl/3/manifests/3.3.1
Already downloaded: /Users/runner/Library/Caches/Homebrew/downloads/667f7ac7d51b399107e055b7908f1922fcabba24c7d9d22f2b2d90a07c7c079c--openssl@3-3.3.1.bottle_manifest.json
==> Fetching openssl@3
==> Downloading https://ghcr.io/v2/homebrew/core/openssl/3/blobs/sha256:d57cf59ebcfa7755895707f5eab2c07cbcc177b1c1803d160a8633db99b110ba
Already downloaded: /Users/runner/Library/Caches/Homebrew/downloads/adc91e5c9214d2a6579d48e7e22a1e2ff02ed8666053389c10e35d7a4fe9d93b--openssl@3--3.3.1.arm64_sonoma.bottle.tar.gz
==> Reinstalling openssl@3 
==> Pouring openssl@3--3.3.1.arm64_sonoma.bottle.tar.gz
Warning: These files were overwritten during the `brew link` step:
/opt/homebrew/bin/openssl
Warning: These files were overwritten during the `brew link` step:

They have been backed up to: /Users/runner/Library/Caches/Homebrew/Backup
==> Summary
🍺  /opt/homebrew/Cellar/openssl@3/3.3.1: 6,982 files, 32.5MB
==> Downloading https://ghcr.io/v2/homebrew/core/boost/manifests/1.85.0
==> Fetching boost
==> Downloading https://ghcr.io/v2/homebrew/core/boost/blobs/sha256:01c57670b0218a69dccf37142a2f79b5836350114c694adef930f2116df8d7eb
==> Reinstalling boost 
==> Pouring boost--1.85.0.arm64_sonoma.bottle.tar.gz
🍺  /opt/homebrew/Cellar/boost/1.85.0: 16,161 files, 510.6MB

However, find openssl code looks in a different location:

if(APPLE)
      if(NOT DEFINED OPENSSL_ROOT_DIR)
        # Prefer a homebrew version of OpenSSL over the one in /usr/lib
        file(GLOB OPENSSL_ROOT_DIR /usr/local/Cellar/openssl*/*)
        # Prefer the latest (make the latest one first)
        list(REVERSE OPENSSL_ROOT_DIR)
        list(GET OPENSSL_ROOT_DIR 0 OPENSSL_ROOT_DIR)
      endif()
      # This should prevent linking against the system provided 0.9.8y
      message(STATUS "OPENSSL_ROOT_DIR = ${OPENSSL_ROOT_DIR}")
      set(_OPENSSL_VERSION "")
    endif()

resulting in the error:

CMake Error at cpm_modules/cpprestsdk/c5f4252565747efa760d9e9fc0557931fe620899/Release/cmake/cpprest_find_openssl.cmake:40 (list):
-- OPENSSL_ROOT_DIR = 
  list GET given empty list
Call Stack (most recent call first):
  cpm_modules/cpprestsdk/c5f4252565747efa760d9e9fc0557931fe620899/Release/src/CMakeLists.txt:130 (cpprest_find_openssl)