Skip to content

dune_add_test does not work with aliased targets

It turns out that non-mutable targets are not usable with dune_add_test because the dune testing facilities want to mutate the target.

  • With the introduction of !1247 (merged), we want to make more regular usage of aliased targets as they represent the non-mutable version of a target.
  • Another instance of this case is when using an imported library or executable. Since they are imported, they are non-mutable.

The offending line is here, where the test wants to modify the properties of the target to (not) be excluded from make all.

  # Make sure to exclude the target from all, even when it is user-provided
  if(DUNE_BUILD_TESTS_ON_MAKE_ALL AND (NOT ADDTEST_EXPECT_COMPILE_FAIL))
    set_property(TARGET ${ADDTEST_TARGET} PROPERTY EXCLUDE_FROM_ALL 0)
  else()
    set_property(TARGET ${ADDTEST_TARGET} PROPERTY EXCLUDE_FROM_ALL 1)
  endif()