-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
92 lines (72 loc) · 3.02 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
cmake_minimum_required(VERSION 3.10)
if(${CMAKE_VERSION} VERSION_LESS 3.10)
cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
endif()
if (NOT DEFINED ENV{BOLOS_SDK})
message(FATAL_ERROR "BOLOS_SDK environment variable not found.")
endif()
# project information
project(unit_tests
VERSION 0.1
DESCRIPTION "Unit tests for Ledger Application"
LANGUAGES C)
# guard against bad build-type strings
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Debug")
endif()
configure_file(${CMAKE_SOURCE_DIR}/CTestCustom.cmake ${CMAKE_BINARY_DIR})
# Build secp256k1 optimized library
add_subdirectory(./secp256k1)
include(CTest)
enable_testing()
# specify C standard
set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED True)
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wall -pedantic -g -O0 --coverage")
set(GCC_COVERAGE_LINK_FLAGS "--coverage -lgcov")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${GCC_COVERAGE_LINK_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${GCC_COVERAGE_LINK_FLAGS}")
# guard against in-source builds
if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
message(FATAL_ERROR "In-source builds not allowed. Please make a new directory (called a build directory) and run CMake from there. You may need to remove CMakeCache.txt. ")
endif()
add_compile_definitions(TEST)
include_directories(../src)
include_directories($ENV{BOLOS_SDK}/lib_standard_app)
include_directories(.)
include_directories(./secp256k1/include)
# Add the define for PRINTF as a macro
add_definitions(-DPRINTF=printf)
# EXECUTABLE DECLARATION
add_executable(test_bip32 test_bip32.c)
add_executable(test_block_parser test_block_parser.c)
# STANDARD LIBRARIES
add_library(base58 SHARED $ENV{BOLOS_SDK}/lib_standard_app/base58.c)
add_library(bip32 SHARED $ENV{BOLOS_SDK}/lib_standard_app/bip32.c ../src/common/bip32_derivation.c)
add_library(buffer SHARED $ENV{BOLOS_SDK}/lib_standard_app/buffer.c)
add_library(read SHARED $ENV{BOLOS_SDK}/lib_standard_app/read.c)
add_library(write SHARED $ENV{BOLOS_SDK}/lib_standard_app/write.c)
add_library(format SHARED $ENV{BOLOS_SDK}/lib_standard_app/format.c)
add_library(varint SHARED $ENV{BOLOS_SDK}/lib_standard_app/varint.c)
add_library(apdu_parser SHARED $ENV{BOLOS_SDK}/lib_standard_app/parser.c)
# CUSTOM LIBRARIES
add_library(tlv SHARED ../src/common/tlv.c)
add_library(block_parser ../src/block/block_parser.c)
add_library(crypto SHARED ./lib/crypto.c ./lib/hmac_sha2.c ./lib/sha2.c ./lib/bn.c)
# LINKAGE
target_link_libraries(test_bip32 PUBLIC cmocka gcov bip32 read crypto base58 write secp256k1)
target_link_libraries(test_block_parser PUBLIC
block_parser
tlv
buffer
varint
bip32
cmocka
gcov
write
crypto
secp256k1
read)
# TESTS DECLARATION
add_test(test_bip32 test_bip32)
add_test(test_block_parser test_block_parser)