-
Notifications
You must be signed in to change notification settings - Fork 129
/
CMakeLists.txt
70 lines (65 loc) · 2.24 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
cmake_minimum_required(VERSION 3.13)
project(st_device_sdk_c C)
set(CMAKE_CXX_FLAGS_UNITTEST "-g --coverage -DSUPPORT_TC_ON_STATIC_FUNC" CACHE STRING
"Flags used by the C++ compiler during unit test builds."
FORCE)
set(CMAKE_C_FLAGS_UNITTEST "-g --coverage -DSUPPORT_TC_ON_STATIC_FUNC" CACHE STRING
"Flags used by the C compiler during unit test builds."
FORCE)
set(CMAKE_EXE_LINKER_FLAGS_UNITTEST "--coverage" CACHE STRING
"Flags used for linking binaries during unit test builds."
FORCE)
set(CMAKE_SHARED_LINKER_FLAGS_UNITTEST "--coverage" CACHE STRING
"Flags used by the shared libraries linker during unit test builds."
FORCE
)
mark_as_advanced(
CMAKE_CXX_FLAGS_UNITTEST
CMAKE_C_FLAGS_UNITTEST
CMAKE_EXE_LINKER_FLAGS_UNITTEST
CMAKE_SHARED_LINKER_FLAGS_UNITTEST)
set(CMAKE_BUILD_TYPE "${CMAKE_BUILD_TYPE}" CACHE STRING
"Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel UnitTest."
FORCE
)
if(NOT STDK_IOT_CORE_USE_DEFINED_CONFIG)
if(EXISTS ${stdk_config})
message("include stdk_config : ${stdk_config}")
include("${stdk_config}")
else()
message("include default stdk_config")
include("stdkconfig.cmake")
endif()
endif()
if(CMAKE_C_COMPILER_ID STREQUAL "GNU" AND CMAKE_BUILD_TYPE MATCHES UnitTest)
foreach(stdk_extra_cflags ${STDK_UNITTEST_EXTRA_CFLAGS})
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D${stdk_extra_cflags}")
set(${stdk_extra_cflags} "y")
endforeach()
set(MOCKED_FUNCTIONS
iot_os_malloc
iot_os_realloc
iot_os_free
iot_os_strdup
iot_os_delay
iot_bsp_wifi_get_scan_result
iot_bsp_wifi_get_mac
iot_bsp_wifi_set_mode
iot_bsp_system_set_time_in_sec
port_net_read
port_net_write
port_net_connect
port_net_read_poll
port_net_close
port_net_free
)
else()
foreach(stdk_extra_cflags ${STDK_EXTRA_CFLAGS})
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D${stdk_extra_cflags}")
set(${stdk_extra_cflags} "y")
endforeach()
endif()
add_subdirectory(src)
if(CMAKE_C_COMPILER_ID STREQUAL "GNU" AND CMAKE_BUILD_TYPE MATCHES UnitTest)
add_subdirectory(test)
endif()