-
Notifications
You must be signed in to change notification settings - Fork 0
/
ChibiOS16.cmake
85 lines (73 loc) · 3.51 KB
/
ChibiOS16.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
IF(NOT ChibiOS_FIND_COMPONENTS)
SET(ChibiOS_FIND_COMPONENTS nil hal st)
MESSAGE(STATUS "No ChibiOS components specified, using default: ${ChibiOS_FIND_COMPONENTS}")
ENDIF()
MESSAGE(STATUS "ChibiOS components: ${ChibiOS_FIND_COMPONENTS}")
LIST(FIND ChibiOS_FIND_COMPONENTS nil ChibiOS_FIND_COMPONENTS_nil)
LIST(FIND ChibiOS_FIND_COMPONENTS rt ChibiOS_FIND_COMPONENTS_rt)
LIST(FIND ChibiOS_FIND_COMPONENTS hal ChibiOS_FIND_COMPONENTS_hal)
LIST(FIND ChibiOS_FIND_COMPONENTS st ChibiOS_FIND_COMPONENTS_st)
IF((${ChibiOS_FIND_COMPONENTS_nil} LESS 0) AND (${ChibiOS_FIND_COMPONENTS_rt} LESS 0))
MESSAGE(STATUS "No kernel component selected, using Nil kernel")
LIST(APPEND ChibiOS_FIND_COMPONENTS nil)
SET(CHIBIOS_KERNEL nil)
ELSE()
IF((NOT (${ChibiOS_FIND_COMPONENTS_nil} LESS 0)) AND (NOT (${ChibiOS_FIND_COMPONENTS_rt} LESS 0)))
MESSAGE(WARNING "Cannot use RT and nil kernel at the same time - nil will win")
SET(CHIBIOS_KERNEL nil)
ENDIF()
IF(NOT (${ChibiOS_FIND_COMPONENTS_nil} LESS 0))
SET(CHIBIOS_KERNEL nil)
ELSE()
SET(CHIBIOS_KERNEL rt)
ENDIF()
ENDIF()
IF(${ChibiOS_FIND_COMPONENTS_hal} LESS 0)
LIST(APPEND ChibiOS_FIND_COMPONENTS hal)
ENDIF()
IF(${ChibiOS_FIND_COMPONENTS_st} LESS 0)
LIST(APPEND ChibiOS_FIND_COMPONENTS st)
ENDIF()
INCLUDE(ChibiOS16_LD)
INCLUDE(ChibiOS16_HAL)
INCLUDE(ChibiOS16_Contrib)
IF(${CHIBIOS_KERNEL} STREQUAL rt)
INCLUDE(ChibiOS16_RT)
ELSE()
INCLUDE(ChibiOS16_NIL)
ENDIF()
INCLUDE(ChibiOS16_Various)
SET(CHIBIOS_COMPONENTS nil rt hal ${CHIBIOS_HAL_MODULES} ${CHIBIOS_HAL_LIB_MODULES} ${CHIBIOS_VARIOUS_MODULES} ${CHIBIOS_CONTRIB_MODULES})
IF(NOT ChibiOS_LINKER_SCRIPT)
MESSAGE(STATUS "ChibiOS doesn't have linker script for your chip, please specify it directly using ChibiOS_LINKER_SCRIPT variable.")
ENDIF()
FOREACH(comp ${ChibiOS_FIND_COMPONENTS})
LIST(FIND CHIBIOS_COMPONENTS ${comp} INDEX)
IF(INDEX EQUAL -1)
MESSAGE(FATAL_ERROR "Unknown ChibiOS component: ${comp}\nSupported ChibiOS components: ${CHIBIOS_COMPONENTS}")
ENDIF()
FOREACH(source ${CHIBIOS_${comp}_SOURCES})
FIND_FILE(CHIBIOS_${comp}_${source} NAMES ${source} PATHS ${CHIBIOS_${comp}_SEARCH_PATH} NO_DEFAULT_PATH CMAKE_FIND_ROOT_PATH_BOTH)
LIST(APPEND ChibiOS_SOURCES ${CHIBIOS_${comp}_${source}})
ENDFOREACH()
IF(CHIBIOS_${comp}_SEARCH_HEADERS)
FOREACH(header ${CHIBIOS_${comp}_SEARCH_HEADERS})
FIND_PATH(CHIBIOS_${comp}_${header}_INCLUDE_DIR NAMES ${header} PATHS ${CHIBIOS_${comp}_SEARCH_PATH} NO_DEFAULT_PATH CMAKE_FIND_ROOT_PATH_BOTH)
LIST(APPEND ChibiOS_INCLUDE_DIRS ${CHIBIOS_${comp}_${header}_INCLUDE_DIR})
ENDFOREACH()
ENDIF()
IF(CHIBIOS_${comp}_PLATFORM_SEARCH_HEADERS)
FOREACH(header ${CHIBIOS_${comp}_PLATFORM_SEARCH_HEADERS})
FIND_PATH(CHIBIOS_${comp}_PLATFORM_${header}_INCLUDE_DIR NAMES ${header} PATHS ${CHIBIOS_${comp}_PLATFORM_SEARCH_PATH} NO_DEFAULT_PATH CMAKE_FIND_ROOT_PATH_BOTH)
LIST(APPEND ChibiOS_INCLUDE_DIRS ${CHIBIOS_${comp}_PLATFORM_${header}_INCLUDE_DIR})
ENDFOREACH()
ENDIF()
IF(CHIBIOS_${comp}_PLATFORM_SOURCES)
FOREACH(source ${CHIBIOS_${comp}_PLATFORM_SOURCES})
FIND_FILE(CHIBIOS_${comp}_PLATFORM_${source} NAMES ${source} PATHS ${CHIBIOS_${comp}_PLATFORM_SEARCH_PATH} NO_DEFAULT_PATH CMAKE_FIND_ROOT_PATH_BOTH)
LIST(APPEND ChibiOS_SOURCES ${CHIBIOS_${comp}_PLATFORM_${source}})
ENDFOREACH()
ENDIF()
STRING(TOUPPER "CHIBIOS_HAS_${comp}" TMP)
LIST(APPEND CHIBIOS_COMPONENTS_DEFINITIONS ${TMP})
ENDFOREACH()