2023-09-12 15:27:24 +00:00
|
|
|
cmake_minimum_required(VERSION 3.5.1)
|
2021-03-25 16:03:25 +00:00
|
|
|
|
|
|
|
#
|
|
|
|
# Simulate configuring and building Mbed TLS as the user might do it. We'll
|
|
|
|
# skip installing it, and use the build directory directly instead.
|
|
|
|
#
|
|
|
|
|
|
|
|
set(MbedTLS_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../..")
|
|
|
|
set(MbedTLS_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/mbedtls")
|
|
|
|
|
|
|
|
execute_process(
|
|
|
|
COMMAND "${CMAKE_COMMAND}"
|
|
|
|
"-H${MbedTLS_SOURCE_DIR}"
|
|
|
|
"-B${MbedTLS_BINARY_DIR}"
|
|
|
|
"-DENABLE_PROGRAMS=NO"
|
2023-09-28 09:40:22 +00:00
|
|
|
"-DENABLE_TESTING=NO"
|
|
|
|
# Turn on generated files explicitly in case this is a release
|
|
|
|
"-DGEN_FILES=ON")
|
2021-03-25 16:03:25 +00:00
|
|
|
|
|
|
|
execute_process(
|
|
|
|
COMMAND "${CMAKE_COMMAND}"
|
|
|
|
--build "${MbedTLS_BINARY_DIR}")
|
|
|
|
|
|
|
|
#
|
|
|
|
# Locate the package.
|
|
|
|
#
|
|
|
|
|
|
|
|
set(MbedTLS_DIR "${MbedTLS_BINARY_DIR}/cmake")
|
|
|
|
find_package(MbedTLS REQUIRED)
|
|
|
|
|
|
|
|
#
|
|
|
|
# At this point, the Mbed TLS targets should have been imported, and we can now
|
|
|
|
# link to them from our own program.
|
|
|
|
#
|
|
|
|
|
|
|
|
add_executable(cmake_package cmake_package.c)
|
|
|
|
target_link_libraries(cmake_package
|
2024-10-25 14:01:14 +00:00
|
|
|
MbedTLS::tfpsacrypto MbedTLS::mbedtls MbedTLS::mbedx509)
|