-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
68 lines (60 loc) · 2.95 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#
# file: CMakeLists.txt
#
# This is the main CMakeLists.txt for mbed-TLS integration with distortos
#
# author: Copyright (C) 2019 Kamil Szczygiel http://www.distortec.com http://www.freddiechopin.info
#
# This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not
# distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
cmake_minimum_required(VERSION 3.8)
project(mbed-TLS-integration)
if(NOT DEFINED MBED_TLS_DIRECTORY)
message(SEND_ERROR "Variable with path to mbed TLS directory - MBED_TLS_DIRECTORY - is not defined")
endif()
if(NOT IS_DIRECTORY "${MBED_TLS_DIRECTORY}")
message(SEND_ERROR "Path to mbed TLS directory - MBED_TLS_DIRECTORY = ${MBED_TLS_DIRECTORY} - is not valid")
endif()
if(NOT EXISTS "${MBED_TLS_DIRECTORY}/CMakeLists.txt")
message(SEND_ERROR "Path to mbed TLS directory - MBED_TLS_DIRECTORY = ${MBED_TLS_DIRECTORY} - does not contain "
"CMakeLists.txt")
endif()
if(NOT DEFINED MBED_TLS_CONFIGURATION_H_DIRECTORY)
message(SEND_ERROR "Variable with path to mbed-TLS-configuration.h - MBED_TLS_CONFIGURATION_H_DIRECTORY - is not "
"defined")
endif()
if(NOT IS_DIRECTORY "${MBED_TLS_CONFIGURATION_H_DIRECTORY}")
message(SEND_ERROR "Path to mbed-TLS-configuration.h - MBED_TLS_CONFIGURATION_H_DIRECTORY = "
"${MBED_TLS_CONFIGURATION_H_DIRECTORY} - is not valid")
endif()
if(NOT EXISTS "${MBED_TLS_CONFIGURATION_H_DIRECTORY}/mbed-TLS-configuration.h")
message(SEND_ERROR "Path to mbed-TLS-configuration.h - MBED_TLS_CONFIGURATION_H_DIRECTORY = "
"${MBED_TLS_CONFIGURATION_H_DIRECTORY} - does not contain mbed-TLS-configuration.h")
endif()
add_library(mbed-TLS-interface-library INTERFACE)
target_compile_definitions(mbed-TLS-interface-library INTERFACE
MBEDTLS_CONFIG_FILE="mbed-TLS-configuration-0.h")
target_include_directories(mbed-TLS-interface-library INTERFACE
${CMAKE_CURRENT_LIST_DIR}/include
${MBED_TLS_CONFIGURATION_H_DIRECTORY})
target_link_libraries(mbed-TLS-interface-library INTERFACE
distortos::distortos)
set(libs mbed-TLS-interface-library)
add_subdirectory("${MBED_TLS_DIRECTORY}" mbed-TLS EXCLUDE_FROM_ALL)
add_library(mbed-TLS-object-library OBJECT
${CMAKE_CURRENT_LIST_DIR}/mbedTlsThreading.cpp)
target_link_libraries(mbed-TLS-object-library PRIVATE
$<TARGET_PROPERTY:mbedtls,INTERFACE_LINK_LIBRARIES>)
target_sources(mbedtls INTERFACE
$<TARGET_OBJECTS:mbed-TLS-object-library>)
distortosAppendToSavedConfiguration(ENABLE_PROGRAMS)
distortosAppendToSavedConfiguration(ENABLE_TESTING)
distortosAppendToSavedConfiguration(ENABLE_ZLIB_SUPPORT)
distortosAppendToSavedConfiguration(INSTALL_MBEDTLS_HEADERS)
distortosAppendToSavedConfiguration(LINK_WITH_PTHREAD)
distortosAppendToSavedConfiguration(LINK_WITH_TRUSTED_STORAGE)
distortosAppendToSavedConfiguration(UNSAFE_BUILD)
distortosAppendToSavedConfiguration(USE_PKCS11_HELPER_LIBRARY)
distortosAppendToSavedConfiguration(USE_SHARED_MBEDTLS_LIBRARY)
distortosAppendToSavedConfiguration(USE_STATIC_MBEDTLS_LIBRARY)