Skip to content

Commit

Permalink
Cmake changes to enable custom autocoder registration
Browse files Browse the repository at this point in the history
  • Loading branch information
Anthony Limiero committed Jul 9, 2022
1 parent 776af78 commit 88783b7
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 2 deletions.
40 changes: 40 additions & 0 deletions cmake/API.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
####
set(FPRIME_TARGET_LIST "" CACHE INTERNAL "FPRIME_TARGET_LIST: custom fprime targets" FORCE)
set(FPRIME_UT_TARGET_LIST "" CACHE INTERNAL "FPRIME_UT_TARGET_LIST: custom fprime targets" FORCE)
set(FPRIME_AUTOCODER_TARGET_LIST "" CACHE INTERNAL "FPRIME_AUTOCODER_TARGET_LIST: custom fprime targets" FORCE)
####
# Function `add_fprime_subdirectory`:
#
Expand Down Expand Up @@ -467,6 +468,45 @@ macro(register_fprime_target_helper TARGET_FILE_PATH TARGET_LIST)
endmacro(register_fprime_target_helper)


####
# Macro `register_fprime_autocoder`:
#
# Identical to the above `register_fprime_target` function
#
###
macro(register_fprime_autocoder TARGET_FILE_PATH)
# Normal registered targets don't run in prescan
message(STATUS "Registering custom autocoder: ${TARGET_FILE_PATH}")
if (NOT DEFINED FPRIME_PRESCAN)
register_fprime_autocoder_helper("${TARGET_FILE_PATH}" FPRIME_AUTOCODER_TARGET_LIST)
endif()
endmacro(register_fprime_autocoder)


####
# Macro `register_fprime_autocoder_helper`:
#
# Helper function to do the actual registration.
#
####
macro(register_fprime_autocoder_helper TARGET_FILE_PATH TARGET_LIST)
include("${TARGET_FILE_PATH}")
# Prevent out-of-order setups
get_property(MODULE_DETECTION_STARTED GLOBAL PROPERTY MODULE_DETECTION SET)
if (MODULE_DETECTION_STARTED)
message(FATAL_ERROR "Cannot register fprime autocoder after including subdirectories or FPrime-Code.cmake'")
endif()
# Get the target list to add this target to or use default
set(LIST_NAME FPRIME_AUTOCODER_TARGET_LIST)
if (${ARGC} GREATER 1)
set(LIST_NAME "${ARGV1}")
endif()
get_property(TARGETS GLOBAL PROPERTY "${TARGET_LIST}")
if (NOT TARGET_FILE_PATH IN_LIST TARGETS)
set_property(GLOBAL APPEND PROPERTY "${LIST_NAME}" "${TARGET_FILE_PATH}")
endif()
endmacro(register_fprime_autocoder_helper)

#### Documentation links
# Next Topics:
# - Setting Options: [Options](Options.md) are used to vary a CMake build.
Expand Down
3 changes: 2 additions & 1 deletion cmake/target/build.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ endfunction()
function(build_add_module_target MODULE TARGET SOURCES DEPENDENCIES)
get_target_property(MODULE_TYPE "${MODULE}" FP_TYPE)
message(STATUS "Adding ${MODULE_TYPE}: ${MODULE}")
run_ac_set("${SOURCES}" autocoder/fpp autocoder/ai_xml)
get_property(CUSTOM_AUTOCODERS GLOBAL PROPERTY FPRIME_AUTOCODER_TARGET_LIST)
run_ac_set("${SOURCES}" autocoder/fpp autocoder/ai_xml ${CUSTOM_AUTOCODERS})
resolve_dependencies(RESOLVED ${DEPENDENCIES} ${AC_DEPENDENCIES} )
build_setup_build_module("${MODULE}" "${SOURCES}" "${AC_GENERATED}" "${AC_SOURCES}" "${RESOLVED}")
# Special flags applied to modules when compiling with testing enabled
Expand Down
2 changes: 1 addition & 1 deletion docs/UsersGuide/dev/target-integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ globally. Module targets run on every module defining the `<target>_register_fpr
targets run on deployments defined with the `<target>_register_fprime_deployment` calls, and global targets run once.

Targets are CMake files that define three functions, one for each level, and are described below. The filename of this
CMake without the `.cmake` extension is determines the`<target>` name. e.g. `utility.cmake` will define the `utility`
CMake without the `.cmake` extension determines the`<target>` name. e.g. `utility.cmake` will define the `utility`
target.

Targets stages are defined in the following order:
Expand Down

0 comments on commit 88783b7

Please sign in to comment.