Skip to content

chore: automatically detect openssl on macos#485

Open
Spockkk0225 wants to merge 4 commits into
alibaba:mainfrom
Spockkk0225:chore-detect-openssl
Open

chore: automatically detect openssl on macos#485
Spockkk0225 wants to merge 4 commits into
alibaba:mainfrom
Spockkk0225:chore-detect-openssl

Conversation

@Spockkk0225
Copy link
Copy Markdown
Collaborator

@Spockkk0225 Spockkk0225 commented Jun 4, 2026

While building on macos, it will detect real OpenSSL path and set OPENSSL_ROOT_DIR to brpc.

# macOS: auto-detect Homebrew OpenSSL path (arm64 uses /opt/homebrew, x86_64 uses /usr/local)
if (APPLE AND NOT OPENSSL_ROOT_DIR)
    execute_process(
        COMMAND brew --prefix openssl@3
        OUTPUT_VARIABLE BREW_OPENSSL_PREFIX
        OUTPUT_STRIP_TRAILING_WHITESPACE
        ERROR_QUIET
    )
    if (BREW_OPENSSL_PREFIX AND EXISTS "${BREW_OPENSSL_PREFIX}")
        set(OPENSSL_ROOT_DIR "${BREW_OPENSSL_PREFIX}")
        message(STATUS "Using Homebrew OpenSSL: ${OPENSSL_ROOT_DIR}")
    endif()
endif()

fix #484

Comment thread CMakeLists.txt Outdated

find_package(Threads REQUIRED)

# macOS: auto-detect Homebrew OpenSSL path (arm64 uses /opt/homebrew, x86_64 uses /usr/local)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There seems to be multiple find_package(OpenSSL) in our CMakeLists, maybe we should replace all find_package(OpenSSL) with a new macro, which ensure OpenSSL in correctly found.
https://github.com/search?q=repo%3Aalibaba%2Fneug+find_package%28OpenSSL&type=code

zhanglei1949
zhanglei1949 previously approved these changes Jun 4, 2026
Copy link
Copy Markdown
Member

@zhanglei1949 zhanglei1949 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@zhanglei1949 zhanglei1949 self-requested a review June 4, 2026 10:10
Comment thread CMakeLists.txt Outdated
find_package(Threads REQUIRED)

# macOS: auto-detect Homebrew OpenSSL path (arm64 uses /opt/homebrew, x86_64 uses /usr/local)
if (APPLE AND NOT OPENSSL_ROOT_DIR)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should do find_package(OpenSSL) if OPENSSL_ROOT_DIR 1is not specified, then set the prefix to OPENSSL_ROOT_DIR. This should be done in BuildBrpcxxx.cmake

Copy link
Copy Markdown
Member

@zhanglei1949 zhanglei1949 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Homebrew has various installation path on macos_x86_64 and macos_arm64

2 participants