Skip to content
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# Opt out of target/test_autocoder. target/test_chained_autocoder runs test_target_autocoder
# itself (as the first stage of the chain), so applying both targets to this module would
# duplicate the same `cmake -E copy` rule into two sub-makefiles and race under `make -jN`.
# Custom targets are attached inside register_fprime_module, so the flag must be set first.
set(SKIP_TEST_AUTOCODER_TARGET TRUE)
register_fprime_module(
TestChainedAutocoderModule
AUTOCODER_INPUTS
Expand All @@ -6,3 +11,4 @@ register_fprime_module(
EXCLUDE_FROM_ALL
INTERFACE
)
unset(SKIP_TEST_AUTOCODER_TARGET)
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# Opt out of target/test_chained_autocoder. This module exercises the standalone
# target/test_autocoder; without this, the chained target would also run test_target_autocoder
# on it and CMake would emit the same `cmake -E copy` rule into two sub-makefiles, racing
# under `make -jN`. Custom targets are attached inside register_fprime_module, so the flag
# must be set first.
set(SKIP_TEST_CHAINED_AUTOCODER_TARGET TRUE)
register_fprime_module(
TestTargetAutocoderModule
AUTOCODER_INPUTS
Expand All @@ -6,4 +12,5 @@ register_fprime_module(
EXCLUDE_FROM_ALL
INTERFACE
)
unset(SKIP_TEST_CHAINED_AUTOCODER_TARGET)
target_include_directories(TestBuildAutocoderModule PRIVATE "${CMAKE_CURRENT_BINARY_DIR}")
5 changes: 5 additions & 0 deletions cmake/test/data/cmake/target/test_autocoder.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ function(test_autocoder_add_deployment_target MODULE TARGET SOURCES DIRECT_DEPEN
endfunction(test_autocoder_add_deployment_target)

function(test_autocoder_add_module_target MODULE TARGET SOURCES DEPENDENCIES)
# Allow modules to opt out (e.g. TestChainedAutocoderModule, which owns its own
# run of test_target_autocoder via target/test_chained_autocoder).
if (SKIP_TEST_AUTOCODER_TARGET)
return()
endif()
run_ac_set("${MODULE}" "autocoder/test_target_autocoder")
# Use the variable from this run as set by the autocoder
add_custom_target("${MODULE}_test_autocode" DEPENDS "${AUTOCODER_GENERATED_OTHER}")
Expand Down
7 changes: 6 additions & 1 deletion cmake/test/data/cmake/target/test_chained_autocoder.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,14 @@ function(test_chained_autocoder_add_deployment_target MODULE TARGET SOURCES DIRE
endfunction(test_chained_autocoder_add_deployment_target)

function(test_chained_autocoder_add_module_target MODULE TARGET SOURCES DEPENDENCIES)
# Allow modules to opt out (e.g. TestTargetAutocoderModule, which exercises the standalone
# target/test_autocoder). See note in test_autocoder.cmake.
if (SKIP_TEST_CHAINED_AUTOCODER_TARGET)
return()
endif()
# Run both autocoders in sequence: target autocoder first, then chained autocoder
run_ac_set("${MODULE}" "autocoder/test_target_autocoder" "autocoder/test_chained_autocoder")

# Use the variable from this run as set by the autocoders
add_custom_target("${MODULE}_test_chained_autocode" DEPENDS "${AUTOCODER_GENERATED_OTHER}")
add_dependencies("${MODULE}" "${MODULE}_test_chained_autocode")
Expand Down
Loading