48
48
cmake_minimum_required (VERSION 2.8.12)
49
49
project (OSAL C)
50
50
51
- # OSAL_SYSTEM_OSTYPE and OSAL_SYSTEM_BSPTYPE indicate which of the OS packages
52
- # to build. These are required and must be defined. Confirm that this exists
53
- # and error out now if it does not.
54
- if (NOT DEFINED OSAL_SYSTEM_OSTYPE OR
55
- NOT IS_DIRECTORY "${OSAL_SOURCE_DIR} /src/os/${OSAL_SYSTEM_OSTYPE} " )
56
- # It is an error if the indicated OSTYPE does not correspond to a subdirectory
57
- # If this is not caught here then a more obfuscated error will occur later.
58
- message ("Error: \" ${OSAL_SYSTEM_OSTYPE} \" is not a valid OS type" )
59
- message (FATAL_ERROR "OSAL_SYSTEM_OSTYPE must be set to the appropriate OS" )
60
- endif ()
61
- if (NOT DEFINED OSAL_SYSTEM_BSPTYPE OR
62
- NOT IS_DIRECTORY "${OSAL_SOURCE_DIR} /src/bsp/${OSAL_SYSTEM_BSPTYPE} " )
63
- # It is an error if the indicated BSPTYPE does not correspond to a subdirectory
64
- # If this is not caught here then a more obfuscated error will occur later.
65
- message ("Error: \" ${OSAL_SYSTEM_BSPTYPE} \" is not a valid BSP type" )
66
- message (FATAL_ERROR "OSAL_SYSTEM_BSPTYPE must be set to the appropriate BSP" )
67
- endif ()
68
-
69
51
# Read the default compile-time configuration, and update with
70
52
# any mission/project specific options in the OSAL_CONFIGURATION_FILE
71
53
include ("${OSAL_SOURCE_DIR} /default_config.cmake" )
@@ -94,9 +76,6 @@ execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different
94
76
"${CMAKE_BINARY_DIR} /inc/osconfig.h"
95
77
)
96
78
97
- message (STATUS "OSAL Selection: ${OSAL_SYSTEM_OSTYPE} " )
98
- message (STATUS "BSP Selection: ${OSAL_SYSTEM_BSPTYPE} " )
99
-
100
79
# The initial set of directories that define the OSAL API
101
80
# This is used to initialize the interface include directory property of external targets
102
81
set (OSAL_API_INCLUDE_DIRECTORIES
@@ -116,11 +95,26 @@ add_definitions(${OSAL_USER_C_FLAGS})
116
95
# This is done early, so that other targets may reference UT_ASSERT_SOURCE_DIR if needed
117
96
add_subdirectory (ut_assert)
118
97
119
-
120
98
#
121
99
# Step 1:
122
100
# Build the BSP layer
123
101
#
102
+
103
+
104
+ # OSAL_SYSTEM_BSPTYPE indicate which of the BSP packages
105
+ # to build. These is required and must be defined. Confirm that this exists
106
+ # and error out now if it does not.
107
+ if (NOT DEFINED OSAL_SYSTEM_BSPTYPE OR
108
+ NOT IS_DIRECTORY "${OSAL_SOURCE_DIR} /src/bsp/${OSAL_SYSTEM_BSPTYPE} " )
109
+ # It is an error if the indicated BSPTYPE does not correspond to a subdirectory
110
+ # If this is not caught here then a more obfuscated error will occur later.
111
+ message ("Error: \" ${OSAL_SYSTEM_BSPTYPE} \" is not a valid BSP type" )
112
+ message (FATAL_ERROR "OSAL_SYSTEM_BSPTYPE must be set to the appropriate BSP" )
113
+ endif ()
114
+
115
+ message (STATUS "BSP Selection: ${OSAL_SYSTEM_BSPTYPE} " )
116
+
117
+
124
118
# The BSP library is a separate target from OSAL and can be used
125
119
# independently of the OSAL library and/or in combination with
126
120
# UT assert and the OSAL stub library for unit testing.
@@ -132,6 +126,19 @@ target_include_directories(osal_${OSAL_SYSTEM_BSPTYPE}_impl PRIVATE
132
126
${OSAL_SOURCE_DIR} /src/bsp/shared/inc
133
127
)
134
128
129
+ # Confirm that the selected OS is compatible with the selected BSP.
130
+ if (DEFINED OSAL_EXPECTED_OSTYPE)
131
+ if (NOT DEFINED OSAL_SYSTEM_OSTYPE)
132
+ # In the event that OSAL_SYSTEM_OSTYPE was not specified at all,
133
+ # implicitly assume the expected OSTYPE.
134
+ set (OSAL_SYSTEM_OSTYPE ${OSAL_EXPECTED_OSTYPE} )
135
+ elseif (NOT OSAL_SYSTEM_OSTYPE STREQUAL OSAL_EXPECTED_OSTYPE)
136
+ # Generate a warning about the OSTYPE not being expected.
137
+ # Not calling this a fatal error because it could possibly be intended during development
138
+ message (WARNING "Mismatched BSP/OS: ${OSAL_SYSTEM_BSPTYPE} implies ${OSAL_EXPECTED_OSTYPE} , but ${OSAL_SYSTEM_OSTYPE} is configured" )
139
+ endif (NOT DEFINED OSAL_SYSTEM_OSTYPE)
140
+ endif (DEFINED OSAL_EXPECTED_OSTYPE)
141
+
135
142
# Propagate the BSP-specific compile definitions and include directories
136
143
# Apply these to the directory-scope COMPILE_DEFINITIONS and INCLUDE_DIRECTORIES
137
144
# Note this needs to append to the directory property, not overwrite it.
@@ -172,10 +179,25 @@ target_include_directories(osal_bsp PRIVATE
172
179
${OSAL_SOURCE_DIR} /src/bsp/shared/inc
173
180
)
174
181
182
+
175
183
#
176
184
# Step 2:
177
185
# Build the OSAL layer
178
186
#
187
+
188
+ # OSAL_SYSTEM_OSTYPE and OSAL_SYSTEM_BSPTYPE indicate which of the OS packages
189
+ # to build. These are required and must be defined. Confirm that this exists
190
+ # and error out now if it does not.
191
+ if (NOT DEFINED OSAL_SYSTEM_OSTYPE OR
192
+ NOT IS_DIRECTORY "${OSAL_SOURCE_DIR} /src/os/${OSAL_SYSTEM_OSTYPE} " )
193
+ # It is an error if the indicated OSTYPE does not correspond to a subdirectory
194
+ # If this is not caught here then a more obfuscated error will occur later.
195
+ message ("Error: \" ${OSAL_SYSTEM_OSTYPE} \" is not a valid OS type" )
196
+ message (FATAL_ERROR "OSAL_SYSTEM_OSTYPE must be set to the appropriate OS" )
197
+ endif ()
198
+
199
+ message (STATUS "OSAL Selection: ${OSAL_SYSTEM_OSTYPE} " )
200
+
179
201
# The implementation-specific OSAL subdirectory should define
180
202
# an OBJECT target named "osal_${OSAL_SYSTEM_OSTYPE}_impl"
181
203
add_subdirectory (src/os/${OSAL_SYSTEM_OSTYPE} ${OSAL_SYSTEM_OSTYPE} _impl)
0 commit comments