From b2f2a5f685c7bd8e1674f44857d7273d93aec6d7 Mon Sep 17 00:00:00 2001 From: Joseph Hickey Date: Tue, 2 Jun 2020 12:54:23 -0400 Subject: [PATCH] Fix #724, implement config-based target builds The existing build system built target executables grouped by toolchain as a proxy for CPU architecture + machine options/flags. The app binaries would be built once and copied to any/all targets sharing that toolchain. The side effect of doing this is that the application needs to be written in an CPU-agnostic manner, performing its subscriptions and configurations from runtime table data rather than hardcoded/fixed values. Unfortunately most apps are not coded that way, so workarounds were needed. This changes the top level process to include the "platform" within this target build logic, effectively treating different platform configs as entirely different builds, even if they share the same toolchain file. As a result, binaries will only be shared between targets that explicitly set the "TGTx_PLATFORM" setting in targets.cmake to the same value. --- cmake/Makefile.sample | 2 +- cmake/arch_build.cmake | 33 +----- cmake/cfe_generated_file.h.in | 5 + cmake/global_functions.cmake | 156 +++++++++++++++++--------- cmake/mission_build.cmake | 115 +++++++++++++++---- cmake/target/CMakeLists.txt | 10 +- fsw/cfe-core/CMakeLists.txt | 14 +-- fsw/cfe-core/unit-test/CMakeLists.txt | 6 +- 8 files changed, 210 insertions(+), 131 deletions(-) create mode 100644 cmake/cfe_generated_file.h.in diff --git a/cmake/Makefile.sample b/cmake/Makefile.sample index bea332e6f..c1466e7d3 100644 --- a/cmake/Makefile.sample +++ b/cmake/Makefile.sample @@ -62,7 +62,7 @@ # Establish default values for critical variables. Any of these may be overridden # on the command line or via the make environment configuration in an IDE O ?= build -ARCH ?= native +ARCH ?= native/default_cpu1 BUILDTYPE ?= debug INSTALLPREFIX ?= /exe DESTDIR ?= $(O) diff --git a/cmake/arch_build.cmake b/cmake/arch_build.cmake index dfe5309f1..04984f8b3 100644 --- a/cmake/arch_build.cmake +++ b/cmake/arch_build.cmake @@ -411,16 +411,6 @@ function(process_arch SYSVAR) set(TGTLIST_DRV_${DRV}) endforeach() - # INCLUDE_REFACTOR: apps and the PSP like to #include cfe_platform_cfg.h -- they shouldn't - # This will become unnecessary when dependency refactoring is merged in, but for now - # they need to be able to find it. Remove the next line once refactoring is merged. - # Also do not do this if more than one CPU shares this architecture - this hack can only - # be done if a 1:1 mapping between cpus and architectures (so all apps are rebuilt per-cpu) - list(LENGTH TGTSYS_${SYSVAR} ARCHLEN) - if (ARCHLEN EQUAL 1) - include_directories(${CMAKE_BINARY_DIR}/cfe_core_default_${TGT${TGTSYS_${SYSVAR}}_NAME}/inc) - endif (ARCHLEN EQUAL 1) - # Process each PSP module that is referenced on this system architecture (any cpu) foreach(PSPMOD ${TGTSYS_${SYSVAR}_PSPMODULES}) message(STATUS "Building PSP Module: ${PSPMOD}") @@ -464,6 +454,9 @@ function(process_arch SYSVAR) add_subdirectory(${${APP}_MISSION_DIR} apps/${APP}) endforeach() + # Actual core library is a subdirectory + add_subdirectory(${MISSION_SOURCE_DIR}/cfe/fsw/cfe-core cfe-core) + # If unit test is enabled, build a generic ut stub library for CFE if (ENABLE_UNIT_TESTS) add_subdirectory(${cfe-core_MISSION_DIR}/ut-stubs ut_cfe_core_stubs) @@ -473,24 +466,8 @@ function(process_arch SYSVAR) # Second Pass: Build cfe-core and link final target executable foreach(TGTID ${TGTSYS_${SYSVAR}}) - set(TGTNAME ${TGT${TGTID}_NAME}) - set(TGTPLATFORM ${TGT${TGTID}_PLATFORM}) - if(NOT TGTPLATFORM) - set(TGTPLATFORM "default" ${TGTNAME}) - endif(NOT TGTPLATFORM) - - string(REPLACE ";" "_" CFE_CORE_TARGET "cfe_core_${TGTPLATFORM}") - if (NOT TARGET ${CFE_CORE_TARGET}) - - # Generate wrapper file for the requisite cfe_platform_cfg.h file - generate_config_includefile("${CFE_CORE_TARGET}/inc/cfe_msgids.h" msgids.h ${TGTPLATFORM}) - generate_config_includefile("${CFE_CORE_TARGET}/inc/cfe_platform_cfg.h" platform_cfg.h ${TGTPLATFORM}) - - # Actual core library is a subdirectory - add_subdirectory(${MISSION_SOURCE_DIR}/cfe/fsw/cfe-core ${CFE_CORE_TARGET}) - - endif (NOT TARGET ${CFE_CORE_TARGET}) - + set(TGTNAME ${TGT${TGTID}_NAME}) + # Target to generate the actual executable file add_subdirectory(cmake/target ${TGTNAME}) diff --git a/cmake/cfe_generated_file.h.in b/cmake/cfe_generated_file.h.in new file mode 100644 index 000000000..5bc4d4108 --- /dev/null +++ b/cmake/cfe_generated_file.h.in @@ -0,0 +1,5 @@ +@GENERATED_FILE_HEADER@ + +@GENERATED_FILE_CONTENT@ + +@GENERATED_FILE_TRAILER@ diff --git a/cmake/global_functions.cmake b/cmake/global_functions.cmake index c2edb78b0..8bcc91595 100644 --- a/cmake/global_functions.cmake +++ b/cmake/global_functions.cmake @@ -8,6 +8,49 @@ # ################################################################## +include(CMakeParseArguments) + +################################################################## +# +# FUNCTION: generate_c_headerfile +# +# Generates a C header file in the build directory. +# First argument is the file name to write. All remaining arguments will be +# concatenated and written to the file. +# +function(generate_c_headerfile FILE_NAME) + + # Determine the absolute location for this wrapper file + # If it is relative path then assume it is relative to ${CMAKE_BINARY_DIR} + # This should not write generated files to ${CMAKE_SOURCE_DIR} + if (NOT IS_ABSOLUTE "${FILE_NAME}") + set(FILE_NAME "${CMAKE_BINARY_DIR}/${FILE_NAME}") + endif (NOT IS_ABSOLUTE "${FILE_NAME}") + + # Generate an include guard + get_filename_component(FILE_GUARD "${FILE_NAME}" NAME) + string(REGEX REPLACE "[^A-Za-z0-9]" "_" FILE_GUARD "${FILE_GUARD}") + string(TOUPPER "GENERATED_INCLUDE_${FILE_GUARD}" FILE_GUARD) + set(GENERATED_FILE_HEADER + "/* Generated header file. Do not edit */\n\n" + "#ifndef ${FILE_GUARD}\n" + "#define ${FILE_GUARD}\n\n" + ) + set(GENERATED_FILE_TRAILER + "#endif /* ${FILE_GUARD} */\n" + ) + + # Use configure_file() to write the file, as this automatically + # has the logic to not update the timestamp on the file unless it changes. + string(REPLACE ";" "" GENERATED_FILE_CONTENT "${ARGN}") + string(REPLACE ";" "" GENERATED_FILE_HEADER "${GENERATED_FILE_HEADER}") + string(REPLACE ";" "" GENERATED_FILE_TRAILER "${GENERATED_FILE_TRAILER}") + configure_file( + "${CFE_SOURCE_DIR}/cmake/cfe_generated_file.h.in" + "${FILE_NAME}" + @ONLY) + +endfunction(generate_c_headerfile) ################################################################## # @@ -21,58 +64,56 @@ # This also supports "stacking" multiple component files together by specifying more than one # source file for the wrapper. # -# In all cases, care must be used when updating such files -- if the timestamp is updated then -# everything that uses it will be rebuilt even if the content did not change. So the file content -# is checked against any pre-existing files, and if the content is the same then the update is -# skipped, preserving the original timestamp. +# This function now accepts named parameters: +# OUTPUT_DIRECTORY - where the generated file will be written +# FILE_NAME - the name of the file to write +# FALLBACK_FILE - if no files are found in "defs" using the name match, this file will be used instead. +# MATCH_SUFFIX - the suffix to match in the "defs" directory (optional) +# PREFIXES - a list of prefixes to match in the "defs" directory (optional) # -function(generate_config_includefile DESTFILE SUFFIX) +function(generate_config_includefile) - # Determine the absolute location for this wrapper file - if (NOT IS_ABSOLUTE ${DESTFILE}) - set(DESTFILE ${CMAKE_BINARY_DIR}/${DESTFILE}) - endif (NOT IS_ABSOLUTE ${DESTFILE}) - - set(INCL_LIST) - set(DEST_CONTENTSTR "/* This is a wrapper file generated by the build system - DO NOT EDIT */\n") - foreach(SRC ${ARGN}) - set(SRC_LOCAL_PATH "${MISSION_DEFS}/${SRC}_${SUFFIX}") - # only add this if not already included (prevent double inclusion) */ - list(FIND INCL_LIST "${SRC_LOCAL_PATH}" INCL_INDX) - if (INCL_INDX LESS 0) - list(APPEND INCL_LIST "${SRC_LOCAL_PATH}") - if (EXISTS "${SRC_LOCAL_PATH}") - file(TO_NATIVE_PATH "${SRC_LOCAL_PATH}" SRC_NATIVE) - set(DEST_CONTENTSTR "${DEST_CONTENTSTR}#include \"${SRC_NATIVE}\"\n") - else() - set(DEST_CONTENTSTR "${DEST_CONTENTSTR}/* ${SRC_LOCAL_PATH} does not exist */\n") - endif (EXISTS "${SRC_LOCAL_PATH}") - endif (INCL_INDX LESS 0) - endforeach(SRC ${SRCFILES}) - if (EXISTS "${DESTFILE}") - file(READ "${DESTFILE}" DEST_EXISTING) - else (EXISTS "${DESTFILE}") - set(DEST_EXISTING) - endif (EXISTS "${DESTFILE}") - if (NOT DEST_CONTENTSTR STREQUAL DEST_EXISTING) - file(WRITE "${DESTFILE}" "${DEST_CONTENTSTR}") - endif (NOT DEST_CONTENTSTR STREQUAL DEST_EXISTING) - - # Create a copy of the generated file in a location where it can - # be found by an editor such as Eclipse. The user will still have to - # add the path to the IDEs include search path, but this makes it easier - # by at least putting them all in one spot. This is not used for the build. - get_filename_component(DESTBASENAME "${DESTFILE}" NAME) - if (MISSION_BINARY_DIR) - set(EDITOR_COPY_DIR ${MISSION_BINARY_DIR}/editor_inc) - else() - set(EDITOR_COPY_DIR ${CMAKE_BINARY_DIR}/editor_inc) - endif() - - file(MAKE_DIRECTORY ${EDITOR_COPY_DIR}) - execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different ${DESTFILE} ${EDITOR_COPY_DIR}/${DESTBASENAME}) + cmake_parse_arguments(GENCONFIG_ARG "" "OUTPUT_DIRECTORY;FILE_NAME;FALLBACK_FILE;MATCH_SUFFIX" "PREFIXES" ${ARGN} ) + + set(WRAPPER_FILE_CONTENT) + set(ITEM_FOUND FALSE) + + # Assemble a list of file names to test for + # Check for existence of a file in defs directory with an exact matching name + # Then Check for existence of file(s) with a matching prefix+suffix + set(CHECK_PATH_LIST "${MISSION_DEFS}/${GENCONFIG_ARG_FILE_NAME}") + if (GENCONFIG_ARG_MATCH_SUFFIX) + foreach(PREFIX ${GENCONFIG_ARG_PREFIXES} ${GENCONFIG_ARG_UNPARSED_ARGUMENTS}) + list(APPEND CHECK_PATH_LIST "${MISSION_DEFS}/${PREFIX}_${GENCONFIG_ARG_MATCH_SUFFIX}") + endforeach() + endif(GENCONFIG_ARG_MATCH_SUFFIX) + + # Check for existence of files, and add to content if present + # Note that all files are appended/concatenated together. + foreach(SRC_LOCAL_PATH ${CHECK_PATH_LIST}) + if (EXISTS "${SRC_LOCAL_PATH}") + file(TO_NATIVE_PATH "${SRC_LOCAL_PATH}" SRC_NATIVE_PATH) + list(APPEND WRAPPER_FILE_CONTENT "#include \"${SRC_NATIVE_PATH}\"\n") + set(ITEM_FOUND TRUE) + else() + list(APPEND WRAPPER_FILE_CONTENT "/* ${SRC_LOCAL_PATH} does not exist */\n") + endif (EXISTS "${SRC_LOCAL_PATH}") + endforeach() + + # If _no_ files were found in the above loop, + # then check for and use the fallback file. + # (if specified by the caller it should always exist) + if (NOT ITEM_FOUND AND GENCONFIG_ARG_FALLBACK_FILE) + file(TO_NATIVE_PATH "${GENCONFIG_ARG_FALLBACK_FILE}" SRC_NATIVE_PATH) + list(APPEND WRAPPER_FILE_CONTENT + "\n\n/* No configuration for ${GENCONFIG_ARG_FILE_NAME}, using fallback */\n" + "#include \"${GENCONFIG_ARG_FALLBACK_FILE}\"\n") + endif() + + # Generate a header file + generate_c_headerfile("${GENCONFIG_ARG_OUTPUT_DIRECTORY}/${GENCONFIG_ARG_FILE_NAME}" ${WRAPPER_FILE_CONTENT}) -endfunction(generate_config_includefile DESTFILE SUFFIX) +endfunction(generate_config_includefile) ################################################################## @@ -106,21 +147,28 @@ function(read_targetconfig) endif() if (NOT DEFINED TGT${TGTID}_SYSTEM) set(TGT${TGTID}_SYSTEM "cpu${TGTID}") + set(TGT${TGTID}_SYSTEM "${TGT${TGTID}_SYSTEM}" PARENT_SCOPE) + endif() + if (NOT DEFINED TGT${TGTID}_PLATFORM) + set(TGT${TGTID}_PLATFORM "default" "${TGT${TGTID}_NAME}") + set(TGT${TGTID}_PLATFORM "${TGT${TGTID}_PLATFORM}" PARENT_SCOPE) endif() if (SIMULATION) # if simulation use simulation system architecture for all targets - set(CURRSYS "${SIMULATION}") + set(TOOLCHAIN_NAME "${SIMULATION}") else (SIMULATION) # get the target system arch identifier string - set(CURRSYS "${TGT${TGTID}_SYSTEM}") + set(TOOLCHAIN_NAME "${TGT${TGTID}_SYSTEM}") endif (SIMULATION) - # make sure the string is safe for a variable name - string(REGEX REPLACE "[^A-Za-z0-9]" "_" SYSVAR "${CURRSYS}") + set(BUILD_CONFIG ${TOOLCHAIN_NAME} ${TGT${TGTID}_PLATFORM}) + + # convert to a the string which is safe for a variable name + string(REGEX REPLACE "[^A-Za-z0-9]" "_" SYSVAR "${BUILD_CONFIG}") # save the unmodified name for future reference - set(SYSID_${SYSVAR} "${CURRSYS}" PARENT_SCOPE) + set(BUILD_CONFIG_${SYSVAR} "${BUILD_CONFIG}" PARENT_SCOPE) # if the "global" applist is not empty, append to every CPU applist if (MISSION_GLOBAL_APPLIST) diff --git a/cmake/mission_build.cmake b/cmake/mission_build.cmake index 77b81efe6..6cdbaa067 100644 --- a/cmake/mission_build.cmake +++ b/cmake/mission_build.cmake @@ -111,10 +111,6 @@ function(prepare) add_definitions(-DSIMULATION=${SIMULATION}) endif (SIMULATION) - # Generate the cfe_mission_cfg.h wrapper file - generate_config_includefile("inc/cfe_mission_cfg.h" mission_cfg.h ${MISSIONCONFIG}) - generate_config_includefile("inc/cfe_perfids.h" perfids.h ${MISSIONCONFIG} ) - # Create custom targets for building and cleaning all architectures # This is required particularly for doing extra stuff in the clean step add_custom_target(mission-all COMMAND $(MAKE) all) @@ -166,7 +162,7 @@ function(prepare) # Export the full set of dependencies to the parent build # including the individual dependency paths to each component set(MISSION_DEPS ${MISSION_DEPS} PARENT_SCOPE) - foreach(DEP ${MISSION_DEPS} ${MISSION_PSPMODULES}) + foreach(DEP ${MISSION_APPS} ${MISSION_DEPS} ${MISSION_PSPMODULES}) set(${DEP}_MISSION_DIR ${${DEP}_MISSION_DIR} PARENT_SCOPE) endforeach(DEP ${MISSION_DEPS}) @@ -251,6 +247,39 @@ function(prepare) doxygen osalguide.doxyfile WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/doc") + # Generate the cfe_mission_cfg.h wrapper file + generate_config_includefile( + OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/inc" + FILE_NAME "cfe_mission_cfg.h" + MATCH_SUFFIX "mission_cfg.h" + PREFIXES ${MISSIONCONFIG} # May be a list of items + ) + + generate_config_includefile( + OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/inc" + FILE_NAME "cfe_perfids.h" + MATCH_SUFFIX "perfids.h" + PREFIXES ${MISSIONCONFIG} # May be a list of items + ) + + # Create wrappers for any files provided in an "fsw/mission_inc" subdirectory of each app + # These may be optionally overridden by providing a file of the same name in the defs directory + foreach(APP_NAME ${MISSION_APPS}) + set(APP_MISSION_CONFIG_DIR "${${APP_NAME}_MISSION_DIR}/fsw/mission_inc") + if (IS_DIRECTORY "${APP_MISSION_CONFIG_DIR}") + file(GLOB APP_MISSION_CONFIG_FILES RELATIVE "${APP_MISSION_CONFIG_DIR}" "${APP_MISSION_CONFIG_DIR}/*.h") + foreach(CONFIG_FILE ${APP_MISSION_CONFIG_FILES}) + generate_config_includefile( + OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/inc" + FILE_NAME "${CONFIG_FILE}" + FALLBACK_FILE "${APP_MISSION_CONFIG_DIR}/${CONFIG_FILE}" + MATCH_SUFFIX "${CONFIG_FILE}" + PREFIXES ${MISSIONCONFIG} + ) + endforeach() + endif() + endforeach() + # Certain runtime variables need to be "exported" to the subordinate build, such as # the specific arch settings and the location of all the apps. This is done by creating # a temporary file within the dir and then the subprocess will read that file and re-create @@ -319,22 +348,28 @@ endfunction(prepare) # function(process_arch TARGETSYSTEM) - set(CURRSYS "${SYSID_${TARGETSYSTEM}}") - set(ARCH_BINARY_DIR "${CMAKE_BINARY_DIR}/${CURRSYS}") - file(MAKE_DIRECTORY "${ARCH_BINARY_DIR}") + # The "BUILD_CONFIG" is a list of items to uniquely identify this build + # The first element in the list is the toolchain name, followed by config name(s) + set(BUILD_CONFIG ${BUILD_CONFIG_${TARGETSYSTEM}}) + list(GET BUILD_CONFIG 0 ARCH_TOOLCHAIN_NAME) + list(REMOVE_AT BUILD_CONFIG 0) + # convert to a the string which is safe for a directory name + string(REGEX REPLACE "[^A-Za-z0-9]" "_" ARCH_CONFIG_NAME "${BUILD_CONFIG}") + set(ARCH_BINARY_DIR "${CMAKE_BINARY_DIR}/${ARCH_TOOLCHAIN_NAME}/${ARCH_CONFIG_NAME}") + file(MAKE_DIRECTORY "${ARCH_BINARY_DIR}" "${ARCH_BINARY_DIR}/inc") - message(STATUS "Configuring for system arch: ${CURRSYS}") + message(STATUS "Configuring for system arch: ${ARCH_TOOLCHAIN_NAME}/${ARCH_CONFIG_NAME}") # Note - A warning is issued if you pass CMAKE_TOOLCHAIN_FILE to an already-configured build area # so an extra check is added to see if this is an initial run or a re-run by checking for a CMakeCache file. - if (NOT CURRSYS STREQUAL "native" AND NOT EXISTS "${ARCH_BINARY_DIR}/CMakeCache.txt") + if (NOT ARCH_TOOLCHAIN_NAME STREQUAL "native" AND NOT EXISTS "${ARCH_BINARY_DIR}/CMakeCache.txt") # Find the toolchain file - allow a file in the mission defs dir to supercede one in the compile dir - if (EXISTS ${MISSION_DEFS}/toolchain-${CURRSYS}.cmake) - set(TOOLCHAIN_FILE ${MISSION_DEFS}/toolchain-${CURRSYS}.cmake) - elseif(EXISTS ${CFE_SOURCE_DIR}/cmake/toolchain-${CURRSYS}.cmake) - set(TOOLCHAIN_FILE ${CFE_SOURCE_DIR}/cmake/toolchain-${CURRSYS}.cmake) + if (EXISTS "${MISSION_DEFS}/toolchain-${ARCH_TOOLCHAIN_NAME}.cmake") + set(TOOLCHAIN_FILE "${MISSION_DEFS}/toolchain-${ARCH_TOOLCHAIN_NAME}.cmake") + elseif(EXISTS "${CFE_SOURCE_DIR}/cmake/toolchain-${ARCH_TOOLCHAIN_NAME}.cmake") + set(TOOLCHAIN_FILE "${CFE_SOURCE_DIR}/cmake/toolchain-${ARCH_TOOLCHAIN_NAME}.cmake") else() - message(FATAL_ERROR "Unable to find toolchain file for ${CURRSYS}") + message(FATAL_ERROR "Unable to find toolchain file for ${ARCH_TOOLCHAIN_NAME}") endif() set(SELECTED_TOOLCHAIN_FILE "-DCMAKE_TOOLCHAIN_FILE=${TOOLCHAIN_FILE}") else() @@ -342,6 +377,38 @@ function(process_arch TARGETSYSTEM) set(SELECTED_TOOLCHAIN_FILE) endif () + # Generate wrapper file for the requisite cfe_platform_cfg.h file + generate_config_includefile( + OUTPUT_DIRECTORY "${ARCH_BINARY_DIR}/inc" + FILE_NAME "cfe_msgids.h" + MATCH_SUFFIX "msgids.h" + PREFIXES ${BUILD_CONFIG} ${ARCH_TOOLCHAIN_NAME} + ) + generate_config_includefile( + OUTPUT_DIRECTORY "${ARCH_BINARY_DIR}/inc" + FILE_NAME "cfe_platform_cfg.h" + MATCH_SUFFIX "platform_cfg.h" + PREFIXES ${BUILD_CONFIG} ${ARCH_TOOLCHAIN_NAME} + ) + + # Create wrappers for any files provided in an "fsw/platform_inc" subdirectory of each app + # These may be optionally overridden by providing a file of the same name in the defs directory + foreach(APP_NAME ${MISSION_APPS}) + set(APP_PLATFORM_CONFIG_DIR "${${APP_NAME}_MISSION_DIR}/fsw/platform_inc") + if (IS_DIRECTORY "${APP_PLATFORM_CONFIG_DIR}") + file(GLOB APP_PLATFORM_CONFIG_FILES RELATIVE "${APP_PLATFORM_CONFIG_DIR}" "${APP_PLATFORM_CONFIG_DIR}/*.h") + foreach(CONFIG_FILE ${APP_PLATFORM_CONFIG_FILES}) + generate_config_includefile( + OUTPUT_DIRECTORY "${ARCH_BINARY_DIR}/inc" + FILE_NAME "${CONFIG_FILE}" + FALLBACK_FILE "${APP_PLATFORM_CONFIG_DIR}/${CONFIG_FILE}" + MATCH_SUFFIX "${CONFIG_FILE}" + PREFIXES ${BUILD_CONFIG} ${ARCH_TOOLCHAIN_NAME} + ) + endforeach() + endif() + endforeach() + # Execute CMake subprocess to create a binary build tree for the specific CPU architecture execute_process( COMMAND ${CMAKE_COMMAND} @@ -358,24 +425,24 @@ function(process_arch TARGETSYSTEM) RESULT ) if (NOT RESULT EQUAL 0) - message(FATAL_ERROR "Failed to configure ${CURRSYS}") + message(FATAL_ERROR "Failed to configure ${TARGETSYSTEM}") endif (NOT RESULT EQUAL 0) # Hook the "make all", "make clean", and "make install" targets for the subordinate build # to top-level build targets prefixed by the CPU architecture. - add_custom_target(${CURRSYS}-all + add_custom_target(${TARGETSYSTEM}-all COMMAND $(MAKE) all WORKING_DIRECTORY "${ARCH_BINARY_DIR}" ) - add_custom_target(${CURRSYS}-clean + add_custom_target(${TARGETSYSTEM}-clean COMMAND $(MAKE) clean WORKING_DIRECTORY "${ARCH_BINARY_DIR}" ) - add_custom_target(${CURRSYS}-install + add_custom_target(${TARGETSYSTEM}-install COMMAND $(MAKE) install WORKING_DIRECTORY @@ -383,12 +450,12 @@ function(process_arch TARGETSYSTEM) ) # All subordinate builds depend on the generated files being present first - add_dependencies(${CURRSYS}-install mission-prebuild) - add_dependencies(${CURRSYS}-all mission-prebuild) + add_dependencies(${TARGETSYSTEM}-install mission-prebuild) + add_dependencies(${TARGETSYSTEM}-all mission-prebuild) - add_dependencies(mission-all ${CURRSYS}-all) - add_dependencies(mission-clean ${CURRSYS}-clean) - add_dependencies(mission-install ${CURRSYS}-install) + add_dependencies(mission-all ${TARGETSYSTEM}-all) + add_dependencies(mission-clean ${TARGETSYSTEM}-clean) + add_dependencies(mission-install ${TARGETSYSTEM}-install) endfunction(process_arch TARGETSYSTEM) diff --git a/cmake/target/CMakeLists.txt b/cmake/target/CMakeLists.txt index 903b9a45c..b71591c64 100644 --- a/cmake/target/CMakeLists.txt +++ b/cmake/target/CMakeLists.txt @@ -12,11 +12,6 @@ project(CFETARGET C) -# The CFE core target to link to MUST be given -if (NOT CFE_CORE_TARGET) - message(FATAL_ERROR "CFE_CORE_TARGET must be defined to link a final exe") -endif (NOT CFE_CORE_TARGET) - # Create a file for the statically-linked module list for this target # do this for both PSP and CFS static modules file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/psp_module_list.inc.tmp" @@ -43,9 +38,6 @@ file (REMOVE "${CMAKE_CURRENT_BINARY_DIR}/cfs_static_symbol_list.inc.tmp") # Include the current binary dir for the driver list include_directories(${CMAKE_CURRENT_BINARY_DIR}) -# Include the CFE core-specific configuration -include_directories(${CMAKE_BINARY_DIR}/${CFE_CORE_TARGET}/inc) - # The CPU ID and name are defined by the build scripts for this target if (DEFINED TGTID) add_definitions(-DCFE_CPU_ID_VALUE=${TGTID}) @@ -109,8 +101,8 @@ endif (TGT${TGTID}_APPLIST) # Collect any additional libraries that should be included on the link line # This depends on whether any special features are included or not set(CFE_LINK_WHOLE_LIBS - ${CFE_CORE_TARGET} ${MISSION_CORE_MODULES} + cfe-core psp-${CFE_SYSTEM_PSPNAME} osal ) diff --git a/fsw/cfe-core/CMakeLists.txt b/fsw/cfe-core/CMakeLists.txt index d7337425e..f9480a9e2 100644 --- a/fsw/cfe-core/CMakeLists.txt +++ b/fsw/cfe-core/CMakeLists.txt @@ -13,29 +13,19 @@ # ################################################################## -cmake_minimum_required(VERSION 2.6.4) project(CFECORE C) -# The CFE core target to generate MUST be given -# this allows more than one cfe core target per architecture -if (NOT CFE_CORE_TARGET) - message(FATAL_ERROR "CFE_CORE_TARGET must be defined to build cFE core") -endif (NOT CFE_CORE_TARGET) - -# The cmake CURRENT binary include dir will have the generated platform config file (cfe_platform_cfg.h) -include_directories(${CMAKE_CURRENT_BINARY_DIR}/inc) - # Define the "_CFE_CORE_" macro during compilation of all CFE core sources add_definitions(-D_CFE_CORE_) set(CFE_CORE_MODULES es sb evs tbl time fs) set(CFE_ALL_MODULE_SRCS) -foreach(MODULE ${CFE_CORE_MODULES} config shared) +foreach(MODULE ${CFE_CORE_MODULES}) aux_source_directory(src/${MODULE} CFE_ALL_MODULE_SRCS) endforeach(MODULE ${CFE_CORE_MODULES}) -add_library(${CFE_CORE_TARGET} STATIC ${CFE_ALL_MODULE_SRCS}) +add_library(cfe-core STATIC ${CFE_ALL_MODULE_SRCS}) if (ENABLE_UNIT_TESTS) add_subdirectory(unit-test) diff --git a/fsw/cfe-core/unit-test/CMakeLists.txt b/fsw/cfe-core/unit-test/CMakeLists.txt index 3aebb52fe..3c90521c4 100644 --- a/fsw/cfe-core/unit-test/CMakeLists.txt +++ b/fsw/cfe-core/unit-test/CMakeLists.txt @@ -22,7 +22,7 @@ include_directories( ) # CFE needs a supplemental test support hook library -add_library(ut_${CFE_CORE_TARGET}_support STATIC +add_library(ut_cfe-core_support STATIC ut_support.c ut_osprintf_stubs.c ) @@ -35,7 +35,7 @@ foreach(MODULE ${CFE_CORE_MODULES}) # The "UT_TARGET_NAME" is a concatenation of the configuration name with the current module # This avoids target name duplication in case more than one configuration is used # (All targets should be based on this name) - set(UT_TARGET_NAME "${CFE_CORE_TARGET}_${MODULE}") + set(UT_TARGET_NAME "cfe-core_${MODULE}") set(CFE_MODULE_FILES) aux_source_directory(${cfe-core_MISSION_DIR}/src/${MODULE} CFE_MODULE_FILES) @@ -64,7 +64,7 @@ foreach(MODULE ${CFE_CORE_MODULES}) # This should enable coverage analysis on platforms that support this target_link_libraries(${UT_TARGET_NAME}_UT ${UT_COVERAGE_LINK_FLAGS} - ut_${CFE_CORE_TARGET}_support + ut_cfe-core_support ut_cfe-core_stubs ut_assert)