forked from TiejunMS/nf-interpreter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
binutils.common.cmake
143 lines (100 loc) · 3.75 KB
/
binutils.common.cmake
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#
# Copyright (c) .NET Foundation and Contributors
# See LICENSE file in the project root for full license information.
#
# set compiler definitions that are common to all builds/targets
macro(NF_COMMON_COMPILER_DEFINITIONS TARGET)
# set define according to target
string(FIND ${TARGET} ${NANOBOOTER_PROJECT_NAME} BOOTER_INDEX)
string(FIND ${TARGET} ${NANOCLR_PROJECT_NAME} CLR_INDEX)
if(${BOOTER_INDEX} EQUAL 0)
target_compile_definitions(${TARGET} PUBLIC -DI_AM_NANOBOOTER)
elseif(${CLR_INDEX} EQUAL 0)
target_compile_definitions(${TARGET} PUBLIC -DI_AM_NANOCLR)
else()
message(FATAL_ERROR "\n\n Target name is not any of the expected ones: '${NANOBOOTER_PROJECT_NAME}' or '${NANOCLR_PROJECT_NAME}'")
endif()
endmacro()
# Add packages that are common to ALL builds
# To be called from target CMakeList.txt
macro(NF_ADD_COMMON_PACKAGES)
find_package(BuildUtils REQUIRED)
find_package(WireProtocol REQUIRED)
find_package(NF_NativeAssemblies)
find_package(NF_CoreCLR REQUIRED)
find_package(nanoHALCore REQUIRED)
if(NF_FEATURE_DEBUGGER)
find_package(NF_Debugger REQUIRED)
find_package(NF_Diagnostics REQUIRED)
endif()
# nF feature: networking
if(USE_NETWORKING_OPTION)
find_package(NF_Networking REQUIRED)
endif()
# security provider is mbedTLS
if(USE_SECURITY_MBEDTLS_OPTION)
find_package(mbedTLS REQUIRED)
endif()
endmacro()
# Add common include directories to a specific CMake target
# To be called from target CMakeList.txt
macro(NF_ADD_COMMON_INCLUDE_DIRECTORIES TARGET)
target_include_directories(${TARGET}.elf PUBLIC
# target path (both source and binary)
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}
# target common path
${CMAKE_CURRENT_SOURCE_DIR}/common
# path for CMake target (both source and binary)
${CMAKE_CURRENT_BINARY_DIR}/${TARGET}
${CMAKE_CURRENT_SOURCE_DIR}/${TARGET}
${NF_CoreCLR_INCLUDE_DIRS}
${NF_NativeAssemblies_INCLUDE_DIRS}
${WireProtocol_INCLUDE_DIRS}
${nanoHALCore_INCLUDE_DIRS}
)
# includes specific to nanoCRL
if(${TARGET} STREQUAL ${NANOCLR_PROJECT_NAME})
target_include_directories(${TARGET}.elf PUBLIC
# directories for nanoFramework libraries
${NF_CoreCLR_INCLUDE_DIRS}
${NF_Debugger_INCLUDE_DIRS}
${NF_Diagnostics_INCLUDE_DIRS}
${NF_Networking_INCLUDE_DIRS}
${mbedTLS_INCLUDE_DIRS}
${Graphics_Includes}
)
endif()
endmacro()
# Add common target sources to a specific CMake target
# To be called from target CMakeList.txt
macro(NF_ADD_COMMON_SOURCES TARGET)
target_sources(${TARGET}.elf PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/target_common.c
${COMMON_PROJECT_SOURCES}
${WireProtocol_SOURCES}
${nanoHALCore_SOURCES}
)
# sources specific to nanoBooter
if(${TARGET} STREQUAL ${NANOBOOTER_PROJECT_NAME})
target_sources(${TARGET}.elf PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/target_BlockStorage.c
${NANOBOOTER_PROJECT_SOURCES}
)
endif()
# sources specific to nanoCRL
if(${TARGET} STREQUAL ${NANOCLR_PROJECT_NAME})
target_sources(${TARGET}.elf PUBLIC
${NANOCLR_PROJECT_SOURCES}
# sources for nanoFramework libraries
${NF_CoreCLR_SOURCES}
${NF_Debugger_SOURCES}
${NF_Diagnostics_SOURCES}
${NF_Networking_SOURCES}
${mbedTLS_SOURCES}
# sources for nanoFramework APIs
${NF_NativeAssemblies_SOURCES}
${Graphics_Sources}
)
endif()
endmacro()