diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6602085..e5a9e44 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -17,17 +17,6 @@ jobs: fetch-depth: 0 submodules: true - - name: Install ubuntu build tools #这部分是安装依赖 - if: matrix.os == 'ubuntu-latest' - run: | - sudo apt-get update - sudo apt-get install -y build-essential cmake - - - name: Install macos build tools #这部分是安装依赖 - if: matrix.os == 'macos-latest' - run: | - brew install cmake openssl - - name: Create Unix Release File if: matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest' run: | diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a36c208..d0335a0 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -17,17 +17,6 @@ jobs: with: submodules: true - - name: Install macos build tools #这部分是安装依赖 - if: matrix.os == 'macos-latest' - run: | - wget https://www.openssl.org/source/openssl-1.1.1w.tar.gz - tar -xvf openssl-1.1.1w.tar.gz - cd openssl-1.1.1w - ./config --prefix=/usr/local/openssl - make - sudo make install - export PATH=/usr/local/openssl/bin:$PATH - - name: Run in windows if: matrix.os == 'windows-latest' run: | diff --git a/src/lib/CMakeLists.txt b/src/lib/CMakeLists.txt index 33be644..e118052 100644 --- a/src/lib/CMakeLists.txt +++ b/src/lib/CMakeLists.txt @@ -15,9 +15,17 @@ option(ENABLE_SSL "Enable SSL" on) # ssl if(ENABLE_SSL) if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") - # for author local mac - include_directories(/opt/homebrew/Cellar/openssl@3/3.3.2/include) - link_directories(/opt/homebrew/Cellar/openssl@3/3.3.2/lib) + set(OPENSSL_VERSION "") + execute_process( + COMMAND brew list --versions openssl + OUTPUT_VARIABLE OPENSSL_VERSION_OUTPUT + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + string(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+" OPENSSL_VERSION "${OPENSSL_VERSION_OUTPUT}") + message(STATUS "OpenSSL version: ${OPENSSL_VERSION}") + + include_directories(/opt/homebrew/Cellar/openssl@3/${OPENSSL_VERSION}/include) + link_directories(/opt/homebrew/Cellar/openssl@3/${OPENSSL_VERSION}/lib) endif() add_definitions(-DCPPNET_OPENSSL) link_libraries(-lssl -lcrypto) diff --git a/src/test/CMakeLists.txt b/src/test/CMakeLists.txt index fb4995f..bda1321 100644 --- a/src/test/CMakeLists.txt +++ b/src/test/CMakeLists.txt @@ -16,9 +16,18 @@ option(ENABLE_SSL "Enable SSL" on) # ssl if(ENABLE_SSL) if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") + set(OPENSSL_VERSION "") + execute_process( + COMMAND brew list --versions openssl + OUTPUT_VARIABLE OPENSSL_VERSION_OUTPUT + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + string(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+" OPENSSL_VERSION "${OPENSSL_VERSION_OUTPUT}") + message(STATUS "OpenSSL version: ${OPENSSL_VERSION}") + # for author local mac - include_directories(/opt/homebrew/Cellar/openssl@3/3.3.2/include) - link_directories(/opt/homebrew/Cellar/openssl@3/3.3.2/lib) + include_directories(/opt/homebrew/Cellar/openssl@3/${OPENSSL_VERSION}/include) + link_directories(/opt/homebrew/Cellar/openssl@3/${OPENSSL_VERSION}/lib) endif() add_definitions(-DCPPNET_OPENSSL) link_libraries(-lssl -lcrypto)