-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
109 lines (92 loc) · 4.75 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
cmake_minimum_required(VERSION 3.21.0)
###########################################################################
# #
# Setup #
# #
###########################################################################
option(USE_TREZOR_CRYPTO "Use trezor_crypto as a cryptography provider" OFF)
option(LT_CRYPTO_MBEDTLS "Use mbedtls as a cryptography provider" OFF)
option(BUILD_DOCS "Build documentation" OFF)
option(EXPERIMENTAL_SPI_UART "Experimental feature for spi slave to serial hw convertor" OFF)
option(EXPERIMENTAL_SPI_RASPBERRYPI "Experimental feature for spi slave on rpi 4" OFF)
###########################################################################
# #
# Building documentation #
# #
###########################################################################
if(BUILD_DOCS)
find_package(Doxygen)
if(Doxygen_FOUND)
add_subdirectory(docs)
message(STATUS "Doxygen found, building docs")
else()
message(STATUS "Doxygen not found, not building docs")
endif()
endif()
# Check if cryptography provider is defined
if((NOT USE_TREZOR_CRYPTO) AND (NOT LT_CRYPTO_MBEDTLS) AND (NOT BUILD_DOCS))
message(FATAL_ERROR "Mbed TLS or trezor_crypto must be enabled!")
endif()
###########################################################################
# #
# Collect files #
# #
###########################################################################
project(libtropic_SDK
VERSION 0.0.1
DESCRIPTION "TROPIC01 software development kit"
HOMEPAGE_URL "www.tropicsquare.com"
LANGUAGES C)
set(SDK_SRCS ${SDK_SRCS}
${CMAKE_CURRENT_SOURCE_DIR}/src/libtropic.c
${CMAKE_CURRENT_SOURCE_DIR}/src/lt_crc16.c
${CMAKE_CURRENT_SOURCE_DIR}/src/lt_l1_port_wrap.c
${CMAKE_CURRENT_SOURCE_DIR}/src/lt_l1.c
${CMAKE_CURRENT_SOURCE_DIR}/src/lt_l2.c
${CMAKE_CURRENT_SOURCE_DIR}/src/lt_l2_frame_check.c
${CMAKE_CURRENT_SOURCE_DIR}/src/lt_l3.c
${CMAKE_CURRENT_SOURCE_DIR}/src/lt_hkdf.c
${CMAKE_CURRENT_SOURCE_DIR}/src/lt_random.c
)
set(SDK_INCS ${SDK_INCS}
${CMAKE_CURRENT_SOURCE_DIR}/include/libtropic_common.h
${CMAKE_CURRENT_SOURCE_DIR}/include/libtropic.h
${CMAKE_CURRENT_SOURCE_DIR}/include/libtropic_port.h
${CMAKE_CURRENT_SOURCE_DIR}/src/lt_crc16.h
${CMAKE_CURRENT_SOURCE_DIR}/src/lt_l1_port_wrap.h
${CMAKE_CURRENT_SOURCE_DIR}/src/lt_l1.h
${CMAKE_CURRENT_SOURCE_DIR}/src/lt_l2.h
${CMAKE_CURRENT_SOURCE_DIR}/src/lt_l2_frame_check.h
${CMAKE_CURRENT_SOURCE_DIR}/src/lt_l3.h
${CMAKE_CURRENT_SOURCE_DIR}/src/lt_hkdf.h
${CMAKE_CURRENT_SOURCE_DIR}/src/lt_random.h
)
set(SDK_SRCS ${SDK_SRCS}
${CMAKE_CURRENT_SOURCE_DIR}/hal/crypto/trezor_crypto/lt_crypto_trezor_aesgcm.c
${CMAKE_CURRENT_SOURCE_DIR}/hal/crypto/trezor_crypto/lt_crypto_trezor_ed25519.c
${CMAKE_CURRENT_SOURCE_DIR}/hal/crypto/trezor_crypto/lt_crypto_trezor_sha256.c
${CMAKE_CURRENT_SOURCE_DIR}/hal/crypto/trezor_crypto/lt_crypto_trezor_x25519.c
)
add_library(tropic ${SDK_SRCS} ${SDK_INCS})
target_include_directories(tropic PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src/)
target_include_directories(tropic PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include/)
target_compile_definitions(tropic PRIVATE "$<$<CONFIG:DEBUG>:LIBT_DEBUG>")
###########################################################################
# #
# Compile and link #
# #
###########################################################################
# This options just add 10ms synchronisation delay before read and write functions.
# Needed for hardware spi slave to uart converter.
if(EXPERIMENTAL_SPI_UART)
target_compile_definitions(tropic PRIVATE EXPERIMENTAL_SPI_UART=1)
endif()
if(EXPERIMENTAL_SPI_RASPBERRYPI)
target_compile_definitions(tropic PRIVATE EXPERIMENTAL_SPI_RASPBERRYPI=1)
endif()
if(USE_TREZOR_CRYPTO)
add_subdirectory(vendor/trezor_crypto/ "trezor_crypto")
target_compile_definitions(trezor_crypto PRIVATE AES_VAR)
target_link_libraries(tropic PRIVATE trezor_crypto)
target_compile_definitions(tropic PRIVATE USE_TREZOR_CRYPTO)
endif()