@@ -21,23 +21,44 @@ target_compile_definitions(psp_module_api INTERFACE
2121target_include_directories (psp_module_api INTERFACE
2222 fsw/inc # public API
2323 fsw/shared/inc # all PSP shared headers
24+ ${CMAKE_CURRENT_LIST_DIR} /fsw/${CFE_PSP_TARGETNAME} /inc # platform-specific headers
2425 ${CFE_SOURCE_DIR} /cmake/target /inc # for sysconfig
2526 $<TARGET_PROPERTY:osal,INTERFACE_INCLUDE_DIRECTORIES > # use headers from OSAL
2627)
2728
29+ # Translate the CFE_PSP_TARGETNAME to a set of additional modules to build
30+ file (STRINGS "${CMAKE_CURRENT_LIST_DIR} /fsw/${CFE_PSP_TARGETNAME} /psp_module_list.cmake" PSP_TARGET_MODULE_LIST REGEX "^[a-zA-Z]" )
2831
29- # The PSP is currently built in two parts, consisting of a fully platform-specific
30- # module combined with a shared component which is built for multiple targets.
32+ # The PSP is currently built in modular parts, consisting of a platform-specific
33+ # module(s) combined with a shared component which is built for multiple targets.
3134# The "shared" component is compiled using headers from the platform-specific module
3235# so it is still ultimately a platform-specific binary, and it all gets wrapped into
3336# a single PSP static library target.
3437add_subdirectory (fsw/${CFE_PSP_TARGETNAME} ${CFE_PSP_TARGETNAME} -impl)
3538add_subdirectory (fsw/shared ${CFE_PSP_TARGETNAME} -shared)
3639
40+ # Generate a list of PSP modules along with a pointer to its API structure/entry point
41+ set (GENERATED_EXTERNS)
42+ set (GENERATED_KEYVALS)
43+ foreach (PSPMOD ${PSP_TARGET_MODULE_LIST} )
44+ add_subdirectory (fsw/modules/${PSPMOD} ${PSPMOD} -${CFE_PSP_TARGETNAME} -impl)
45+ list (APPEND GENERATED_EXTERNS "extern CFE_PSP_ModuleApi_t CFE_PSP_${PSPMOD} _API;\n " )
46+ list (APPEND GENERATED_KEYVALS "{ .Name = \" ${PSPMOD} \" , .Api = &CFE_PSP_${PSPMOD} _API },\n " )
47+ endforeach ()
48+
49+ configure_file (${CMAKE_CURRENT_SOURCE_DIR} /cmake/module_list.c.in ${CMAKE_CURRENT_BINARY_DIR} /${CFE_PSP_TARGETNAME} _module_list.c @ONLY)
50+
3751add_library (psp-${CFE_PSP_TARGETNAME} STATIC
52+ ${CMAKE_CURRENT_BINARY_DIR} /${CFE_PSP_TARGETNAME} _module_list.c
3853 $<TARGET_OBJECTS:psp-${CFE_PSP_TARGETNAME} -shared>
3954 $<TARGET_OBJECTS:psp-${CFE_PSP_TARGETNAME} -impl>
4055)
56+ target_link_libraries (psp-${CFE_PSP_TARGETNAME} PUBLIC
57+ ${PSP_TARGET_MODULE_LIST}
58+ )
59+ target_link_libraries (psp-${CFE_PSP_TARGETNAME} PRIVATE
60+ psp_module_api
61+ )
4162
4263target_include_directories (psp-${CFE_PSP_TARGETNAME} INTERFACE
4364 fsw/inc
0 commit comments