-
Notifications
You must be signed in to change notification settings - Fork 6
/
CMakeLists.txt
42 lines (35 loc) · 1.36 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
cmake_minimum_required(VERSION 3.5)
project(emusca C)
option(TARGET_ARM_BAREMETAL "Target ARM baremetal using arm-none-eabi-gcc toolchain" ON)
if(TARGET_ARM_BAREMETAL)
set(CMAKE_EXECUTABLE_SUFFIX ".elf")
set(CMAKE_TOOLCHAIN_FILE $ENV{KSDK_ROOT}/tools/cmake_toolchain_files/armgcc.cmake)
set(CFLAGS -g -Os -mthumb -ffunction-sections -fdata-sections -DMBEDTLS_NO_PLATFORM_ENTROPY -UMBEDTLS_TIMING_C)
set(LDFLAGS "-Wl,--gc-sections,-e,aes_do_dec_wrapped,-E")
set(CMAKE_C_STANDARD_LIBRARIES "-Wl,--start-group -lgcc -lc_nano -lm -Wl,--end-group")
set(ARCH_OPTS
-mcpu=cortex-m4
-mfpu=fpv4-sp-d16
-mfloat-abi=hard
-mthumb
)
else()
set(CFLAGS -g -Os)
set(LDFLAGS -Wl,-dead_strip)
endif()
add_subdirectory(mbedtls EXCLUDE_FROM_ALL)
add_executable(aes-dec-test aes-dec-test.c)
target_link_libraries(aes-dec-test mbedcrypto)
target_include_directories(aes-dec-test PRIVATE ${CMAKE_SOURCE_DIR}/mbedtls/include)
target_compile_options(mbedcrypto PRIVATE ${CFLAGS})
target_compile_options(aes-dec-test PRIVATE ${CFLAGS})
add_executable(aes-sbox-dec-test aes-sbox-dec-test.c tiny-AES-c/aes.c)
target_include_directories(aes-sbox-dec-test PRIVATE ${CMAKE_SOURCE_DIR}/tiny-AES-c)
target_compile_options(aes-sbox-dec-test PRIVATE ${CFLAGS})
set_target_properties(
aes-dec-test aes-sbox-dec-test
PROPERTIES
C_STANDARD 11
C_EXTENSIONS ON
LINK_FLAGS "${LDFLAGS}"
)