2022-07-08 14:08:21 +00:00
|
|
|
# SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
# Copyright (C) 2022 Eneas Ulir de Queiroz
|
|
|
|
|
|
|
|
cmake_minimum_required(VERSION 2.8.12 FATAL_ERROR)
|
|
|
|
project(uencrypt LANGUAGES C)
|
|
|
|
|
|
|
|
option(USE_WOLFSSL "Use WolfSSL as crypto provider" OFF)
|
2023-02-17 11:12:40 +00:00
|
|
|
option(USE_MBEDTLS "Use mbedTLS as crypto provider" OFF)
|
|
|
|
if (USE_MBEDTLS)
|
|
|
|
if (USE_WOLFSSL)
|
|
|
|
message(WARNING "USE_MBEDTLS and USE_WOLFSSL are both set. Building with USE_MBEDTLS.")
|
|
|
|
endif()
|
|
|
|
add_definitions(-DUSE_MBEDTLS)
|
|
|
|
find_library(MBEDCRYPTO_LIBRARY mbedcrypto REQUIRED)
|
|
|
|
set(CRYPTO_LIBRARIES ${MBEDCRYPTO_LIBRARY})
|
2023-02-19 02:19:31 +00:00
|
|
|
set(CRYPTO_SOURCES ${PROJECT_NAME}-mbedtls.c)
|
2022-07-08 14:08:21 +00:00
|
|
|
else()
|
2023-02-19 02:19:31 +00:00
|
|
|
set(CRYPTO_SOURCES ${PROJECT_NAME}-openssl.c)
|
2023-02-17 11:12:40 +00:00
|
|
|
if (USE_WOLFSSL)
|
|
|
|
add_definitions(-DUSE_WOLFSSL)
|
|
|
|
find_library(WOLFSSL_LIBRARY wolfssl REQUIRED)
|
|
|
|
set(CRYPTO_LIBRARIES ${WOLFSSL_LIBRARY})
|
|
|
|
else()
|
|
|
|
find_package(OpenSSL REQUIRED)
|
|
|
|
set(CRYPTO_LIBRARIES ${OPENSSL_CRYPTO_LIBRARY})
|
|
|
|
endif()
|
2022-07-08 14:08:21 +00:00
|
|
|
endif()
|
2023-02-19 02:19:31 +00:00
|
|
|
add_executable(${PROJECT_NAME} ${PROJECT_NAME}.c ${PROJECT_NAME}.h ${CRYPTO_SOURCES})
|
2022-07-08 14:08:21 +00:00
|
|
|
|
|
|
|
target_link_libraries(${PROJECT_NAME} ${CRYPTO_LIBRARIES})
|
|
|
|
|
|
|
|
install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION bin)
|