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
|
|
|
|
# install into a directory inside our own build directory.
|
|
|
|
#
|
|
|
|
|
|
|
|
set(MbedTLS_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../..")
|
|
|
|
set(MbedTLS_INSTALL_DIR "${CMAKE_CURRENT_BINARY_DIR}/mbedtls")
|
|
|
|
set(MbedTLS_BINARY_DIR "${MbedTLS_INSTALL_DIR}${CMAKE_FILES_DIRECTORY}")
|
|
|
|
|
|
|
|
execute_process(
|
|
|
|
COMMAND "${CMAKE_COMMAND}"
|
|
|
|
"-H${MbedTLS_SOURCE_DIR}"
|
|
|
|
"-B${MbedTLS_BINARY_DIR}"
|
|
|
|
"-DENABLE_PROGRAMS=NO"
|
|
|
|
"-DENABLE_TESTING=NO"
|
2023-09-28 09:40:22 +00:00
|
|
|
# Turn on generated files explicitly in case this is a release
|
|
|
|
"-DGEN_FILES=ON"
|
2021-03-25 16:03:25 +00:00
|
|
|
"-DCMAKE_INSTALL_PREFIX=${MbedTLS_INSTALL_DIR}")
|
|
|
|
|
|
|
|
execute_process(
|
|
|
|
COMMAND "${CMAKE_COMMAND}"
|
|
|
|
--build "${MbedTLS_BINARY_DIR}"
|
|
|
|
--target install)
|
|
|
|
|
|
|
|
#
|
|
|
|
# Locate the package.
|
|
|
|
#
|
|
|
|
|
2022-11-19 18:34:01 +00:00
|
|
|
list(INSERT CMAKE_PREFIX_PATH 0 "${MbedTLS_INSTALL_DIR}")
|
2021-03-25 16:03:25 +00:00
|
|
|
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_install cmake_package_install.c)
|
|
|
|
target_link_libraries(cmake_package_install
|
2024-10-25 14:01:14 +00:00
|
|
|
MbedTLS::tfpsacrypto MbedTLS::mbedtls MbedTLS::mbedx509)
|