cmake_minimum_required(VERSION 3.2)

project(mbedtls)

set(DOWNLOAD_DIR "@MBEDTLS_DOWNLOAD_DIR@")
set(SOURCE_DIR "@MBEDTLS_SOURCE_DIR@")
set(BINARY_DIR "@MBEDTLS_BINARY_DIR@")
set(INSTALL_DIR "@MBEDTLS_INSTALL_DIR@")
set(CMAKE_ARGS "@MBEDTLS_CMAKE_ARGS@")
set(LOGGING "@MBEDTLS_LOGGING@")

include(ExternalProject)

ExternalProject_Add(
        mbedtls
        GIT_REPOSITORY        "https://github.com/ARMmbed/mbedtls.git"
        GIT_TAG               "v2.25.0" # Reset to origin/master if issue https://github.com/ARMmbed/mbedtls/issues/4233 if fixed
        BUILD_ALWAYS          OFF
        DOWNLOAD_DIR          "${DOWNLOAD_DIR}"
        SOURCE_DIR            "${SOURCE_DIR}"
        BINARY_DIR            "${BINARY_DIR}"
        INSTALL_DIR           "${INSTALL_DIR}"
        CMAKE_ARGS            ${CMAKE_ARGS}
        CONFIGURE_COMMAND     ""
        UPDATE_COMMAND        ""
        BUILD_COMMAND         ""
        INSTALL_COMMAND       ""
        LOG_DOWNLOAD          ${LOGGING}
        LOG_UPDATE            ${LOGGING}
        LOG_PATCH             ${LOGGING}
        LOG_CONFIGURE         ${LOGGING}
        LOG_BUILD             ${LOGGING}
        LOG_INSTALL           ${LOGGING}
        LOG_TEST              ${LOGGING}
        LOG_MERGED_STDOUTERR  ${LOGGING}
        LOG_OUTPUT_ON_FAILURE ${LOGGING}
)
