Skip to content

Commit

Permalink
Fix nasa#135, Add separate CMakeLists.txt for each implementation
Browse files Browse the repository at this point in the history
Do not use aux_source_directory to assemble a list of source files.
Instead, put a proper CMakeLists.txt file in each implementation
and build the implementation separately from the shared/common parts.

In addition to avoiding the aux_source_directory this allows PSP-specific
compile definitions to be set on a per-implementation basis because
it is defined separately.
  • Loading branch information
jphickey committed Mar 30, 2020
1 parent 7a5400b commit 5495e89
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 13 deletions.
34 changes: 21 additions & 13 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,29 @@ if (NOT CFE_SYSTEM_PSPNAME)
message(FATAL_ERROR "CFE_SYSTEM_PSPNAME is not defined - do not know which to build")
endif()

if (NOT IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/fsw/${CFE_SYSTEM_PSPNAME})
message(FATAL_ERROR "PSP ${CFE_SYSTEM_PSPNAME} is not implemented")
endif()

add_definitions(-D_CFE_PSP_)
include_directories(fsw/${CFE_SYSTEM_PSPNAME}/inc)

include_directories(fsw/shared)

# Use all source files under the shared code directory (always)
# as well as all the files for the selected PSP
set(PSPFILES)
aux_source_directory(fsw/shared PSPFILES)
aux_source_directory(fsw/${CFE_SYSTEM_PSPNAME}/src PSPFILES)

add_library(psp-${CFE_SYSTEM_PSPNAME} STATIC ${PSPFILES})

# Build the PSP implementation which lies in a system-specific subdirectory
include_directories(fsw/${CFE_SYSTEM_PSPNAME}/inc)
add_subdirectory(fsw/${CFE_SYSTEM_PSPNAME} ${CFE_SYSTEM_PSPNAME})

# Build the "common" parts as a library
add_library(psp-${CFE_SYSTEM_PSPNAME} STATIC
fsw/shared/cfe_psp_configdata.c
fsw/shared/cfe_psp_eeprom.c
fsw/shared/cfe_psp_memrange.c
fsw/shared/cfe_psp_memutils.c
fsw/shared/cfe_psp_module.c
fsw/shared/cfe_psp_port.c
fsw/shared/cfe_psp_ram.c
$<TARGET_OBJECTS:psp-${CFE_SYSTEM_PSPNAME}-impl>)

# propagate the PSP implementation-specific flags to the base PSP library
target_compile_definitions(psp-${CFE_SYSTEM_PSPNAME} PUBLIC
$<TARGET_PROPERTY:psp-${CFE_SYSTEM_PSPNAME}-impl,INTERFACE_COMPILE_DEFINITIONS>
)

if (ENABLE_UNIT_TESTS)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/fsw/ut-stubs)
Expand Down
13 changes: 13 additions & 0 deletions fsw/mcp750-vxworks/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

# Build the mcp750-vxworks implementation as a library
add_library(psp-${CFE_SYSTEM_PSPNAME}-impl OBJECT
src/cfe_psp_exception.c
src/cfe_psp_memory.c
src/cfe_psp_memtab.c
src/cfe_psp_ssr.c
src/cfe_psp_start.c
src/cfe_psp_support.c
src/cfe_psp_timer.c
src/cfe_psp_voltab.c
src/cfe_psp_watchdog.c)

17 changes: 17 additions & 0 deletions fsw/pc-linux/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

# Build the pc-linux implementation as a library
add_library(psp-${CFE_SYSTEM_PSPNAME}-impl OBJECT
src/cfe_psp_exception.c
src/cfe_psp_memory.c
src/cfe_psp_memtab.c
src/cfe_psp_ssr.c
src/cfe_psp_start.c
src/cfe_psp_support.c
src/cfe_psp_timer.c
src/cfe_psp_voltab.c
src/cfe_psp_watchdog.c)

# Use _XOPEN_SOURCE=600 to enable X/Open group version 6 conformance
target_compile_definitions(psp-${CFE_SYSTEM_PSPNAME}-impl PUBLIC
_XOPEN_SOURCE=600
)
13 changes: 13 additions & 0 deletions fsw/pc-rtems/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

# Build the pc-rtems implementation as a library
add_library(psp-${CFE_SYSTEM_PSPNAME}-impl OBJECT
src/cfe_psp_exception.c
src/cfe_psp_memory.c
src/cfe_psp_memtab.c
src/cfe_psp_ssr.c
src/cfe_psp_start.c
src/cfe_psp_support.c
src/cfe_psp_timer.c
src/cfe_psp_voltab.c
src/cfe_psp_watchdog.c)

0 comments on commit 5495e89

Please sign in to comment.