Skip to content

Commit

Permalink
Fixed OpenSSL includes not found under macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
COM8 committed May 20, 2024
1 parent 49a8ed1 commit e29695e
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 34 deletions.
66 changes: 33 additions & 33 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on: [push, workflow_dispatch, pull_request] # Trigger for every push as well as
# Repeat up to 5 times to deal with flaky tests.
env:
CTEST_OPTIONS: "-V --repeat until-pass:5"
MACOS_OPENSSL_ROOT_DIR: "/opt/homebrew/Cellar/openssl@3/3.3.0"

jobs:
ubuntu-clang-openssl:
Expand Down Expand Up @@ -239,41 +240,30 @@ jobs:
build-type: Release
run-test: true
ctest-options: ${{ env.CTEST_OPTIONS }}

macos-clang-openssl:

macos-clang-ssl:
strategy:
matrix:
buildType: [Debug, Release]
runs-on: macos-latest
steps:
- name: Install OpenSSL
run: |
brew install openssl
echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> /Users/runner/.bash_profile
source ~/.bash_profile
- name: Checkout
uses: actions/checkout@v3
- name: "Build & Test"
env:
CPR_BUILD_TESTS: ON
CPR_BUILD_TESTS_SSL: ON
CPR_FORCE_OPENSSL_BACKEND: ON
OPENSSL_ROOT_DIR: "/usr/local/opt/openssl"
OPENSSL_LIBRARIES: "/usr/local/opt/openssl/lib"
LDFLAGS: "-L/usr/local/opt/openssl/lib"
CPPFLAGS: "-I/usr/local/opt/openssl/include"
PKG_CONFIG_PATH: "/usr/local/opt/openssl/lib/pkgconfig"
CPR_BUILD_TESTS_SSL: OFF
uses: ashutoshvarma/action-cmake-build@master
with:
build-dir: ${{ github.workspace }}/build
source-dir: ${{ github.workspace }}
cc: clang
cxx: clang++
build-type: Release
build-type: ${{ matrix.buildType }}
run-test: true
ctest-options: ${{ env.CTEST_OPTIONS }}

macos-clang-ssl:
strategy:
matrix:
buildType: [Debug, Release]
macos-clang-darwinssl:
runs-on: macos-latest
steps:
- name: Checkout
Expand All @@ -282,26 +272,38 @@ jobs:
env:
CPR_BUILD_TESTS: ON
CPR_BUILD_TESTS_SSL: OFF
CPR_FORCE_DARWINSSL_BACKEND: ON
uses: ashutoshvarma/action-cmake-build@master
with:
build-dir: ${{ github.workspace }}/build
source-dir: ${{ github.workspace }}
cc: clang
cxx: clang++
build-type: ${{ matrix.buildType }}
build-type: Release
run-test: true
ctest-options: ${{ env.CTEST_OPTIONS }}

macos-clang-darwinssl:
macos-clang-openssl:
runs-on: macos-latest
steps:
- name: Install OpenSSL
run: |
brew install openssl
echo 'export PATH="${{ env.MACOS_OPENSSL_ROOT_DIR }}/bin:$PATH"' >> /Users/runner/.bash_profile
source ~/.bash_profile
brew info openssl
- name: Checkout
uses: actions/checkout@v3
- name: "Build & Test"
env:
CPR_BUILD_TESTS: ON
CPR_BUILD_TESTS_SSL: OFF
CPR_FORCE_DARWINSSL_BACKEND: ON
CPR_BUILD_TESTS_SSL: ON
CPR_FORCE_OPENSSL_BACKEND: ON
OPENSSL_ROOT_DIR: "${{ env.MACOS_OPENSSL_ROOT_DIR }}"
OPENSSL_LIBRARIES: "${{ env.MACOS_OPENSSL_ROOT_DIR }}/lib"
LDFLAGS: "-L${{ env.MACOS_OPENSSL_ROOT_DIR }}/lib"
CPPFLAGS: "-I${{ env.MACOS_OPENSSL_ROOT_DIR }}/include"
PKG_CONFIG_PATH: "${{ env.MACOS_OPENSSL_ROOT_DIR }}/lib/pkgconfig"
uses: ashutoshvarma/action-cmake-build@master
with:
build-dir: ${{ github.workspace }}/build
Expand All @@ -311,7 +313,7 @@ jobs:
build-type: Release
run-test: true
ctest-options: ${{ env.CTEST_OPTIONS }}

macos-clang-openssl-boost:
runs-on: macos-latest
steps:
Expand All @@ -320,21 +322,19 @@ jobs:
- name: Install OpenSSL
run: |
brew install openssl
echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> /Users/runner/.bash_profile
source ~/.bash_profile
- name: Checkout
uses: actions/checkout@v3
- name: "Build & Test"
env:
CPR_BUILD_TESTS: ON
CPR_BUILD_TESTS_SSL: ON
CPR_USE_BOOST_FILESYSTEM: ON
CPR_FORCE_OPENSSL_BACKEND: ON
OPENSSL_ROOT_DIR: "/usr/local/opt/openssl"
OPENSSL_LIBRARIES: "/usr/local/opt/openssl/lib"
LDFLAGS: "-L/usr/local/opt/openssl/lib"
CPPFLAGS: "-I/usr/local/opt/openssl/include"
PKG_CONFIG_PATH: "/usr/local/opt/openssl/lib/pkgconfig"
CPR_USE_BOOST_FILESYSTEM: ON
OPENSSL_ROOT_DIR: "${{ env.MACOS_OPENSSL_ROOT_DIR }}"
OPENSSL_LIBRARIES: "${{ env.MACOS_OPENSSL_ROOT_DIR }}/lib"
LDFLAGS: "-L${{ env.MACOS_OPENSSL_ROOT_DIR }}/lib"
CPPFLAGS: "-I${{ env.MACOS_OPENSSL_ROOT_DIR }}/include"
PKG_CONFIG_PATH: "${{ env.MACOS_OPENSSL_ROOT_DIR }}/lib/pkgconfig"
uses: ashutoshvarma/action-cmake-build@master
with:
build-dir: ${{ github.workspace }}/build
Expand All @@ -343,4 +343,4 @@ jobs:
cxx: clang++
build-type: Release
run-test: true
ctest-options: ${{ env.CTEST_OPTIONS }}
ctest-options: ${{ env.CTEST_OPTIONS }}
5 changes: 4 additions & 1 deletion cmake/mongoose.CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,8 @@ target_include_directories(mongoose PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
if(ENABLE_SSL_TESTS)
# Enable mongoose SSL
target_compile_definitions(mongoose PUBLIC MG_ENABLE_OPENSSL)
target_link_libraries(mongoose PRIVATE OpenSSL::SSL)
target_link_libraries(mongoose PUBLIC OpenSSL::SSL)

# Fix macOS and Windows invalid OpenSSL include path
target_include_directories(mongoose PUBLIC "${OPENSSL_INCLUDE_DIR}")
endif()

0 comments on commit e29695e

Please sign in to comment.