Skip to content

Commit

Permalink
Allow the user to build oqs-provider as a static library.
Browse files Browse the repository at this point in the history
This commit removes the `SHARED` argument of the `add_library`.
By doing so, we let the user choose the build type of library.

By default, CMake will build a static library. Thus, [`BUILD_SHARED_LIBS`]
must be used to switch to a shared library.

`oqs-provider` as a static library allows us to use the provider without
having to store its shared library somewhere. In addition, it happens that
some operating systems prohibit the use of `dlopen`/`dlsym`.

To load `oqs-provider` when it is embedded into a library of a binary, one
can use the [`OSSL_PROVIDER_add_builtin`] API from OpenSSL 3.

[`BUILD_SHARED_LIBS`]: https://cmake.org/cmake/help/latest/variable/BUILD_SHARED_LIBS.html
[`OSSL_PROVIDER_add_builtin`]: https://www.openssl.org/docs/man3.1/man3/OSSL_PROVIDER_add_builtin.html
  • Loading branch information
thb-sb committed Jun 29, 2023
1 parent 6b34839 commit e239fea
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion oqsprov/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ set(PROVIDER_SOURCE_FILES
set(PROVIDER_HEADER_FILES
oqs_prov.h oqs_endecoder_local.h
)
add_library(oqsprovider SHARED ${PROVIDER_SOURCE_FILES})
add_library(oqsprovider ${PROVIDER_SOURCE_FILES})
if (USE_ENCODING_LIB)
add_dependencies(oqsprovider encoder)
endif()
Expand Down
4 changes: 2 additions & 2 deletions scripts/fullbuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,9 @@ if [ ! -f "_build/lib/oqsprovider.$SHLIBEXT" ]; then
BUILD_TYPE=""
# for omitting public key in private keys add -DNOPUBKEY_IN_PRIVKEY=ON
if [ -z "$OPENSSL_INSTALL" ]; then
cmake -DOPENSSL_ROOT_DIR=$(pwd)/.local $BUILD_TYPE -S . -B _build && cmake --build _build
cmake -DOPENSSL_ROOT_DIR=$(pwd)/.local $BUILD_TYPE -S . -B _build -DBUILD_SHARED_LIBS=ON && cmake --build _build
else
cmake -DOPENSSL_ROOT_DIR=$OPENSSL_INSTALL $BUILD_TYPE -S . -B _build && cmake --build _build
cmake -DOPENSSL_ROOT_DIR=$OPENSSL_INSTALL $BUILD_TYPE -S . -B _build -DBUILD_SHARED_LIBS=ON && cmake --build _build
fi
if [ $? -ne 0 ]; then
echo "provider build failed. Exiting."
Expand Down

0 comments on commit e239fea

Please sign in to comment.