Skip to content

Commit

Permalink
Fix OpenSSL dependency in CMake (#2447)
Browse files Browse the repository at this point in the history
  • Loading branch information
steven-johnson authored Jul 31, 2024
1 parent ed1ce97 commit 97b9086
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 3 deletions.
31 changes: 28 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ jobs:
docker exec emscripten emcc -v
docker exec emscripten emcmake cmake -B emscripten -DWERROR=ON
docker exec -w /src/emscripten emscripten make -j $(nproc)
wasi:
name: wasi
runs-on: ubuntu-latest
Expand Down Expand Up @@ -162,10 +162,35 @@ jobs:
python -m pip install -U setuptools wheel pip
python -m pip install "cmake==${WABT_CMAKE_VER}.*"
cmake --version
- name: Configure WABT
- name: configure (OpenSSL)
run: cmake -G Ninja -S . -B out -DCMAKE_BUILD_TYPE=Release
- name: build
- name: build (OpenSSL)
run: cmake --build out
- name: install (OpenSSL)
run: cmake --install out --prefix install

- name: configure (PicoSHA2)
run: cmake -G Ninja -S . -B out-picosha -DCMAKE_BUILD_TYPE=Release -DUSE_INTERNAL_SHA256=ON
- name: build (PicoSHA2)
run: cmake --build out-picosha
- name: install (PicoSHA2)
run: cmake --install out-picosha --prefix install-picosha

- name: test CMake package (OpenSSL)
run: >
ctest --build-and-test scripts/example-project example-openssl
--build-generator Ninja
--build-options -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=$PWD/install
--test-command ctest
- name: test CMake package (PicoSHA2)
run: >
ctest --build-and-test scripts/example-project example-picosha
--build-generator Ninja
--build-options -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=$PWD/install-picosha
--test-command ctest
- name: unittests
run: cmake --build out --target run-unittests
- name: c-api-tests
Expand Down
11 changes: 11 additions & 0 deletions scripts/example-project/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
cmake_minimum_required(VERSION 3.16)
project(example CXX)

enable_testing()

find_package(wabt REQUIRED)

add_executable(example example.cpp)
target_link_libraries(example PRIVATE wabt::wabt)

add_test(NAME example COMMAND example)
3 changes: 3 additions & 0 deletions scripts/example-project/example.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#include <wabt/ir.h>

int main () {}
5 changes: 5 additions & 0 deletions scripts/wabt-config.cmake.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
cmake_minimum_required(VERSION 3.8)
@PACKAGE_INIT@

if ("@HAVE_OPENSSL_SHA_H@")
include(CMakeFindDependencyMacro)
find_dependency(OpenSSL)
endif ()

include("${CMAKE_CURRENT_LIST_DIR}/wabt-targets.cmake")
check_required_components(wabt)

0 comments on commit 97b9086

Please sign in to comment.