Skip to content

Commit e29695e

Browse files
committed
Fixed OpenSSL includes not found under macOS
1 parent 49a8ed1 commit e29695e

File tree

2 files changed

+37
-34
lines changed

2 files changed

+37
-34
lines changed

.github/workflows/ci.yml

+33-33
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ on: [push, workflow_dispatch, pull_request] # Trigger for every push as well as
55
# Repeat up to 5 times to deal with flaky tests.
66
env:
77
CTEST_OPTIONS: "-V --repeat until-pass:5"
8+
MACOS_OPENSSL_ROOT_DIR: "/opt/homebrew/Cellar/openssl@3/3.3.0"
89

910
jobs:
1011
ubuntu-clang-openssl:
@@ -239,41 +240,30 @@ jobs:
239240
build-type: Release
240241
run-test: true
241242
ctest-options: ${{ env.CTEST_OPTIONS }}
242-
243-
macos-clang-openssl:
243+
244+
macos-clang-ssl:
245+
strategy:
246+
matrix:
247+
buildType: [Debug, Release]
244248
runs-on: macos-latest
245249
steps:
246-
- name: Install OpenSSL
247-
run: |
248-
brew install openssl
249-
echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> /Users/runner/.bash_profile
250-
source ~/.bash_profile
251250
- name: Checkout
252251
uses: actions/checkout@v3
253252
- name: "Build & Test"
254253
env:
255254
CPR_BUILD_TESTS: ON
256-
CPR_BUILD_TESTS_SSL: ON
257-
CPR_FORCE_OPENSSL_BACKEND: ON
258-
OPENSSL_ROOT_DIR: "/usr/local/opt/openssl"
259-
OPENSSL_LIBRARIES: "/usr/local/opt/openssl/lib"
260-
LDFLAGS: "-L/usr/local/opt/openssl/lib"
261-
CPPFLAGS: "-I/usr/local/opt/openssl/include"
262-
PKG_CONFIG_PATH: "/usr/local/opt/openssl/lib/pkgconfig"
255+
CPR_BUILD_TESTS_SSL: OFF
263256
uses: ashutoshvarma/action-cmake-build@master
264257
with:
265258
build-dir: ${{ github.workspace }}/build
266259
source-dir: ${{ github.workspace }}
267260
cc: clang
268261
cxx: clang++
269-
build-type: Release
262+
build-type: ${{ matrix.buildType }}
270263
run-test: true
271264
ctest-options: ${{ env.CTEST_OPTIONS }}
272265

273-
macos-clang-ssl:
274-
strategy:
275-
matrix:
276-
buildType: [Debug, Release]
266+
macos-clang-darwinssl:
277267
runs-on: macos-latest
278268
steps:
279269
- name: Checkout
@@ -282,26 +272,38 @@ jobs:
282272
env:
283273
CPR_BUILD_TESTS: ON
284274
CPR_BUILD_TESTS_SSL: OFF
275+
CPR_FORCE_DARWINSSL_BACKEND: ON
285276
uses: ashutoshvarma/action-cmake-build@master
286277
with:
287278
build-dir: ${{ github.workspace }}/build
288279
source-dir: ${{ github.workspace }}
289280
cc: clang
290281
cxx: clang++
291-
build-type: ${{ matrix.buildType }}
282+
build-type: Release
292283
run-test: true
293284
ctest-options: ${{ env.CTEST_OPTIONS }}
294285

295-
macos-clang-darwinssl:
286+
macos-clang-openssl:
296287
runs-on: macos-latest
297288
steps:
289+
- name: Install OpenSSL
290+
run: |
291+
brew install openssl
292+
echo 'export PATH="${{ env.MACOS_OPENSSL_ROOT_DIR }}/bin:$PATH"' >> /Users/runner/.bash_profile
293+
source ~/.bash_profile
294+
brew info openssl
298295
- name: Checkout
299296
uses: actions/checkout@v3
300297
- name: "Build & Test"
301298
env:
302299
CPR_BUILD_TESTS: ON
303-
CPR_BUILD_TESTS_SSL: OFF
304-
CPR_FORCE_DARWINSSL_BACKEND: ON
300+
CPR_BUILD_TESTS_SSL: ON
301+
CPR_FORCE_OPENSSL_BACKEND: ON
302+
OPENSSL_ROOT_DIR: "${{ env.MACOS_OPENSSL_ROOT_DIR }}"
303+
OPENSSL_LIBRARIES: "${{ env.MACOS_OPENSSL_ROOT_DIR }}/lib"
304+
LDFLAGS: "-L${{ env.MACOS_OPENSSL_ROOT_DIR }}/lib"
305+
CPPFLAGS: "-I${{ env.MACOS_OPENSSL_ROOT_DIR }}/include"
306+
PKG_CONFIG_PATH: "${{ env.MACOS_OPENSSL_ROOT_DIR }}/lib/pkgconfig"
305307
uses: ashutoshvarma/action-cmake-build@master
306308
with:
307309
build-dir: ${{ github.workspace }}/build
@@ -311,7 +313,7 @@ jobs:
311313
build-type: Release
312314
run-test: true
313315
ctest-options: ${{ env.CTEST_OPTIONS }}
314-
316+
315317
macos-clang-openssl-boost:
316318
runs-on: macos-latest
317319
steps:
@@ -320,21 +322,19 @@ jobs:
320322
- name: Install OpenSSL
321323
run: |
322324
brew install openssl
323-
echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> /Users/runner/.bash_profile
324-
source ~/.bash_profile
325325
- name: Checkout
326326
uses: actions/checkout@v3
327327
- name: "Build & Test"
328328
env:
329329
CPR_BUILD_TESTS: ON
330330
CPR_BUILD_TESTS_SSL: ON
331-
CPR_USE_BOOST_FILESYSTEM: ON
332331
CPR_FORCE_OPENSSL_BACKEND: ON
333-
OPENSSL_ROOT_DIR: "/usr/local/opt/openssl"
334-
OPENSSL_LIBRARIES: "/usr/local/opt/openssl/lib"
335-
LDFLAGS: "-L/usr/local/opt/openssl/lib"
336-
CPPFLAGS: "-I/usr/local/opt/openssl/include"
337-
PKG_CONFIG_PATH: "/usr/local/opt/openssl/lib/pkgconfig"
332+
CPR_USE_BOOST_FILESYSTEM: ON
333+
OPENSSL_ROOT_DIR: "${{ env.MACOS_OPENSSL_ROOT_DIR }}"
334+
OPENSSL_LIBRARIES: "${{ env.MACOS_OPENSSL_ROOT_DIR }}/lib"
335+
LDFLAGS: "-L${{ env.MACOS_OPENSSL_ROOT_DIR }}/lib"
336+
CPPFLAGS: "-I${{ env.MACOS_OPENSSL_ROOT_DIR }}/include"
337+
PKG_CONFIG_PATH: "${{ env.MACOS_OPENSSL_ROOT_DIR }}/lib/pkgconfig"
338338
uses: ashutoshvarma/action-cmake-build@master
339339
with:
340340
build-dir: ${{ github.workspace }}/build
@@ -343,4 +343,4 @@ jobs:
343343
cxx: clang++
344344
build-type: Release
345345
run-test: true
346-
ctest-options: ${{ env.CTEST_OPTIONS }}
346+
ctest-options: ${{ env.CTEST_OPTIONS }}

cmake/mongoose.CMakeLists.txt

+4-1
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,8 @@ target_include_directories(mongoose PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
88
if(ENABLE_SSL_TESTS)
99
# Enable mongoose SSL
1010
target_compile_definitions(mongoose PUBLIC MG_ENABLE_OPENSSL)
11-
target_link_libraries(mongoose PRIVATE OpenSSL::SSL)
11+
target_link_libraries(mongoose PUBLIC OpenSSL::SSL)
12+
13+
# Fix macOS and Windows invalid OpenSSL include path
14+
target_include_directories(mongoose PUBLIC "${OPENSSL_INCLUDE_DIR}")
1215
endif()

0 commit comments

Comments
 (0)