2
2
# Generic RTEMS configuration
3
3
################################################################################
4
4
5
- # This function performs the generic RTEMS configuration. It expects
6
- # following arguments:
5
+ # This function performs the generic RTEMS configuration. Following function
6
+ # arguments are mandatory:
7
+ #
7
8
# 1. Target/executable name
8
- # 2. RTEMS installation prefix, path where the RTEMS toolchain is installed
9
- # 3. RTEMS BSP, which consists generally has the format <Architecture>/<BSP>
10
- function (rtems_generic_config TARGET_NAME RTEMS_INST RTEMS_BSP )
9
+ # 2. RTEMS prefix. This is generally the path where the RTEMS tools and BSPs
10
+ # are installed. More experienced users can use multiple prefixes.
11
+ # This value will be cached inside the RTEMS_PREFIX variable.
12
+ # 3. RTEMS BSP pair name, which consists generally has the
13
+ # format <Architecture>/<BSP>. This variable will be cached inside
14
+ # the RTEMS_BSP variable.
15
+ #
16
+ # Other variables which can be provided by the developer via command line
17
+ # as well:
18
+ #
19
+ # 1. RTEMS_VERSION:
20
+ # The user can supply RTEMS_VERSION to specify the RTEMS version
21
+ # manually. This is required to determine the toolchains to use. If no
22
+ # RTEMS_VERSION is supplied, this CMake file will try to autodetermine the
23
+ # RTEMS version from the supplied tools path.
24
+ # 2. RTEMS_TOOLS:
25
+ # The user can provide this filepath variable if the RTEMS tools path is
26
+ # not equal to the RTEMS prefix.
27
+ # 3. RTEMS_PATH:
28
+ # The user can provide this filepath variable if the RTEMS path (containig
29
+ # the BSPs) is not equal to the RTEMS prefix.
30
+
31
+ function (rtems_generic_config TARGET_NAME RTEMS_PREFIX RTEMS_BSP_PAIR )
32
+
33
+ set (EXTRA_RTEMS_ARGS ${ARGN} )
34
+ list (LENGTH EXTRA_RTEMS_ARGS NUM_EXTRA_RTEMS_ARGS )
35
+
36
+ if (${NUM_EXTRA_RTEMS_ARGS} EQUAL 1 )
37
+ # This only works for one optional arguments! Need to write list to
38
+ # single variables if this is extended.
39
+ set (RTEMS_PATH ${EXTRA_RTEMS_ARGS} )
40
+ endif ()
11
41
12
- set (RTEMS_VERSION "" CACHE STRING "RTEMS version" )
42
+ set (RTEMS_PREFIX ${RTEMS_PREFIX} CACHE FILEPATH "RTEMS prefix" )
43
+ set (RTEMS_BSP ${RTEMS_BSP} CACHE STRING "RTEMS BSP pair" )
13
44
14
- message (STATUS "Setting up and checking RTEMS cross compile configuration.." )
15
- if (RTEMS_INST STREQUAL "" )
16
- message (FATAL_ERROR "RTEMS toolchain path has to be specified!" )
17
- endif ()
18
-
19
- if (RTEMS_VERSION STREQUAL "" )
20
- message (STATUS "No RTEMS_VERSION supplied." )
21
- message (STATUS "Autodetermining version from prefix ${RTEMS_INST} .." )
22
- string (REGEX MATCH [0-9]+$ RTEMS_VERSION "${RTEMS_INST} " )
45
+ set (RTEMS_INSTALL
46
+ ${CMAKE_INSTALL_PREFIX}
47
+ CACHE FILEPATH "RTEMS install destination"
48
+ )
49
+
50
+ if (NOT RTEMS_PATH )
51
+ message (STATUS
52
+ "RTEMS path was not specified and was set to RTEMS prefix."
53
+ )
54
+ set (RTEMS_PATH ${RTEMS_PREFIX} CACHE FILEPATH "RTEMS folder" )
55
+ else ()
56
+ set (RTEMS_TOOLS ${RTEMS_PATH} CACHE FILEPATH "RTEMS path folder" )
57
+ endif ()
58
+
59
+ if (NOT RTEMS_TOOLS )
60
+ message (STATUS
61
+ "RTEMS toolchain path was not specified and was set to RTEMS prefix."
62
+ )
63
+ set (RTEMS_TOOLS ${RTEMS_PREFIX} CACHE FILEPATH "RTEMS tools folder" )
64
+ else ()
65
+ set (RTEMS_TOOLS ${RTEMS_TOOLS} CACHE FILEPATH "RTEMS tools folder" )
66
+ endif ()
67
+
68
+ if (NOT RTEMS_VERSION )
69
+ message (STATUS "No RTEMS_VERSION supplied." )
70
+ message (STATUS "Autodetermining version from tools path ${RTEMS_TOOLS} .." )
71
+ string (REGEX MATCH [0-9]+$ RTEMS_VERSION "${RTEMS_TOOLS} " )
23
72
message (STATUS "Version ${RTEMS_VERSION} found" )
24
73
endif ()
25
74
26
- string (REPLACE "/" ";" RTEMS_BSP_LIST_SEPARATED ${RTEMS_BSP} )
75
+ set (RTEMS_VERSION "${RTEMS_VERSION} " CACHE STRING "RTEMS version" )
76
+
77
+ message (STATUS "Setting up and checking RTEMS cross compile configuration.." )
78
+
79
+ string (REPLACE "/" ";" RTEMS_BSP_LIST_SEPARATED ${RTEMS_BSP_PAIR} )
27
80
list (LENGTH RTEMS_BSP_LIST_SEPARATED BSP_LIST_SIZE )
28
81
29
82
if (NOT ${BSP_LIST_SIZE} EQUAL 2 )
30
- message (FATAL_ERROR "Supplied RTEMS_BSP variable invalid. Make sure to provide a slash separated string" )
83
+ message (FATAL_ERROR
84
+ "Supplied RTEMS_BSP variable invalid. "
85
+ "Make sure to provide a slash separated string"
86
+ )
31
87
endif ()
32
88
33
89
list (GET RTEMS_BSP_LIST_SEPARATED 0 RTEMS_ARCH_NAME )
34
90
list (GET RTEMS_BSP_LIST_SEPARATED 1 RTEMS_BSP_NAME )
35
91
36
92
set (RTEMS_ARCH_TOOLS "${RTEMS_ARCH_NAME} -rtems${RTEMS_VERSION} " )
37
93
38
- if (IS_DIRECTORY "${RTEMS_INST} /${RTEMS_ARCH_TOOLS} " )
39
- if (IS_DIRECTORY "${RTEMS_INST} /${RTEMS_ARCH_TOOLS} /lib" )
40
- set (RTEMS_ARCH_LIB_PATH "${RTEMS_INST} /${RTEMS_ARCH_TOOLS} /lib" PARENT_SCOPE )
41
- endif ()
42
- set (RTEMS_BSP_LIB_PATH "${RTEMS_INST} /${RTEMS_ARCH_TOOLS} /${RTEMS_BSP_NAME} /lib" )
43
- if (NOT IS_DIRECTORY "${RTEMS_BSP_LIB_PATH} " )
44
- message (FATAL_ERROR "RTEMS BSP lib folder not found at ${RTEMS_BSP_LIB_PATH} " )
45
- endif ()
46
- set (RTEMS_BSP_INC_PATH "${RTEMS_BSP_LIB_PATH} /include" )
47
- if (NOT IS_DIRECTORY "${RTEMS_BSP_INC_PATH} " )
48
- message (FATAL_ERROR "RTEMS BSP include folder not found at ${RTEMS_BSP_INC_PATH} " )
49
- endif ()
50
- else ()
51
- message (FATAL_ERROR "RTEMS Architecure folder not found at ${RTEMS_INST} /${RTEMS_ARCH_TOOLS} " )
94
+ if (NOT IS_DIRECTORY "${RTEMS_PATH} /${RTEMS_ARCH_TOOLS} " )
95
+ message (FATAL_ERROR
96
+ "RTEMS architecure folder not found at "
97
+ "${RTEMS_PATH} /${RTEMS_ARCH_TOOLS} "
98
+ )
99
+ endif ()
100
+
101
+ set (RTEMS_BSP_PATH "${RTEMS_PATH} /${RTEMS_ARCH_TOOLS} /${RTEMS_BSP_NAME} " )
102
+ if (NOT IS_DIRECTORY ${RTEMS_BSP_PATH} )
103
+ message (STATUS
104
+ "Supplied or autodetermined BSP path "
105
+ "${RTEMS_BSP_PATH} is invalid!"
106
+ )
107
+ message (FATAL_ERROR
108
+ "Please check the BSP path or make sure "
109
+ "the BSP is installed."
110
+ )
52
111
endif ()
53
112
113
+ set (RTEMS_BSP_LIB_PATH "${RTEMS_BSP_PATH} /lib" )
114
+ if (NOT IS_DIRECTORY "${RTEMS_BSP_LIB_PATH} " )
115
+ message (FATAL_ERROR
116
+ "RTEMS BSP lib folder not found at "
117
+ "${RTEMS_BSP_LIB_PATH} "
118
+ )
119
+ endif ()
120
+ set (RTEMS_BSP_INC_PATH "${RTEMS_BSP_LIB_PATH} /include" )
121
+ if (NOT IS_DIRECTORY "${RTEMS_BSP_INC_PATH} " )
122
+ message (FATAL_ERROR
123
+ "RTEMS BSP include folder not found at "
124
+ "${RTEMS_BSP_INC_PATH} "
125
+ )
126
+ endif ()
127
+
128
+
54
129
################################################################################
55
130
# Checking the toolchain
56
131
################################################################################
57
132
58
133
message (STATUS "Checking for RTEMS binaries folder.." )
59
- set (RTEMS_BIN_PATH "${RTEMS_INST } /bin" )
134
+ set (RTEMS_BIN_PATH "${RTEMS_TOOLS } /bin" )
60
135
if (NOT IS_DIRECTORY "${RTEMS_BIN_PATH} " )
61
- message (FATAL_ERROR "RTEMS binaries folder not found at ${RTEMS_INST } /bin" )
136
+ message (FATAL_ERROR "RTEMS binaries folder not found at ${RTEMS_TOOLS } /bin" )
62
137
endif ()
63
138
64
139
message (STATUS "Checking for RTEMS gcc.." )
65
140
set (RTEMS_GCC "${RTEMS_BIN_PATH} /${RTEMS_ARCH_TOOLS} -gcc" )
66
141
if (NOT EXISTS "${RTEMS_GCC} " )
67
- message (FATAL_ERROR "RTEMS gcc compiler not found at ${RTEMS_BIN_PATH} /${RTEMS_ARCH_TOOLS} -gcc" )
142
+ message (FATAL_ERROR
143
+ "RTEMS gcc compiler not found at "
144
+ "${RTEMS_BIN_PATH} /${RTEMS_ARCH_TOOLS} -gcc"
145
+ )
68
146
endif ()
69
147
70
148
message (STATUS "Checking for RTEMS g++.." )
71
149
set (RTEMS_GXX "${RTEMS_BIN_PATH} /${RTEMS_ARCH_TOOLS} -g++" )
72
150
if (NOT EXISTS "${RTEMS_GXX} " )
73
- message (FATAL_ERROR "RTEMS g++ compiler not found at ${RTEMS_BIN_PATH} /${RTEMS_ARCH_TOOLS} -g++" )
151
+ message (FATAL_ERROR
152
+ "RTEMS g++ compiler not found at "
153
+ "${RTEMS_BIN_PATH} /${RTEMS_ARCH_TOOLS} -g++"
154
+ )
74
155
endif ()
75
156
76
157
message (STATUS "Checking for RTEMS assembler.." )
77
158
set (RTEMS_ASM "${RTEMS_BIN_PATH} /${RTEMS_ARCH_TOOLS} -as" )
78
159
if (NOT EXISTS "${RTEMS_GXX} " )
79
- message (FATAL_ERROR "RTEMS as compiler not found at ${RTEMS_BIN_PATH} /${RTEMS_ARCH_TOOLS} -as" )
160
+ message (FATAL_ERROR
161
+ "RTEMS as compiler not found at "
162
+ "${RTEMS_BIN_PATH} /${RTEMS_ARCH_TOOLS} -as" )
80
163
endif ()
81
164
82
165
message (STATUS "Checking for RTEMS linker.." )
83
166
set (RTEMS_LINKER "${RTEMS_BIN_PATH} /${RTEMS_ARCH_TOOLS} -ld" )
84
167
if (NOT EXISTS "${RTEMS_LINKER} " )
85
- message (FATAL_ERROR "RTEMS ld linker not found at ${RTEMS_BIN_PATH} /${RTEMS_ARCH_TOOLS} -ld" )
168
+ message (FATAL_ERROR
169
+ "RTEMS ld linker not found at "
170
+ "${RTEMS_BIN_PATH} /${RTEMS_ARCH_TOOLS} -ld" )
86
171
endif ()
87
172
88
173
message (STATUS "Checking done" )
@@ -91,12 +176,15 @@ message(STATUS "Checking done")
91
176
# Info output
92
177
###########################################
93
178
94
- message (STATUS "RTEMS Version: ${RTEMS_VERSION} " )
95
- message (STATUS "RTEMS installation path: ${RTEMS_INST} " )
96
- message (STATUS "RTEMS Architecture tools path: ${RTEMS_ARCH_TOOLS} " )
97
- message (STATUS "RTEMS BSP: ${RTEMS_BSP} " )
98
- message (STATUS "RTEMS BSP LIB path: ${RTEMS_BSP_LIB_PATH} " )
99
- message (STATUS "RTEMS BSP INC path: ${RTEMS_BSP_INC_PATH} " )
179
+ message (STATUS "RTEMS version: ${RTEMS_VERSION} " )
180
+ message (STATUS "RTEMS prefix: ${RTEMS_PREFIX} " )
181
+ message (STATUS "RTEMS tools path: ${RTEMS_TOOLS} " )
182
+ message (STATUS "RTEMS BSP pair: ${RTEMS_BSP} " )
183
+ message (STATUS "RTEMS architecture tools path: "
184
+ "${RTEMS_PATH} /${RTEMS_ARCH_TOOLS} " )
185
+ message (STATUS "RTEMS BSP library path: ${RTEMS_BSP_LIB_PATH} " )
186
+ message (STATUS "RTEMS BSP include path: ${RTEMS_BSP_INC_PATH} " )
187
+ message (STATUS "RTEMS install target: ${RTEMS_INSTALL} " )
100
188
101
189
message (STATUS "RTEMS gcc compiler: ${RTEMS_GCC} " )
102
190
message (STATUS "RTEMS g++ compiler: ${RTEMS_GXX} " )
@@ -116,7 +204,10 @@ set(CMAKE_CXX_COMPILER ${RTEMS_GXX} PARENT_SCOPE)
116
204
set (CMAKE_ASM_COMPILER ${RTEMS_ASM} PARENT_SCOPE )
117
205
set (CMAKE_LINKER ${RTEMS_LINKER} PARENT_SCOPE )
118
206
119
- set (RTEMS_BSP_LIB_PATH ${RTEMS_BSP_LIB_PATH} PARENT_SCOPE )
120
- set (RTEMS_BSP_INC_PATH ${RTEMS_BSP_INC_PATH} PARENT_SCOPE )
207
+ set (RTEMS_BSP_LIB_PATH ${RTEMS_BSP_LIB_PATH} CACHE FILEPATH "BSP library path" )
208
+ set (RTEMS_BSP_INC_PATH ${RTEMS_BSP_INC_PATH} CACHE FILEPATH "BSP include path" )
209
+ set (RTEMS_ARCH_LIB_PATH ${RTEMS_BSP_INC_PATH}
210
+ CACHE FILEPATH "Architecture library path"
211
+ )
121
212
122
213
endfunction ()
0 commit comments