Skip to content

FMU_TESTING is gated on an undefined variable (ENABLE_FMU_EXPORT), so it can never be enabled #780

Description

@DanNegrut

src/chrono_fmi/CMakeLists.txt:51 guards FMU testing on a variable that does not exist:

cmake_dependent_option(FMU_TESTING "Enable FMU testing" ON "ENABLE_FMU_EXPORT" OFF)

ENABLE_FMU_EXPORT occurs exactly once in the whole repository, on that line, and is never defined
anywhere. The option the file actually uses for this everywhere else is FMU_EXPORT_SUPPORT, declared
20-odd lines earlier:

cmake_dependent_option(FMU_EXPORT_SUPPORT "Enable FMU export capabilities" ON "CH_ENABLE_MODULE_FMI" OFF)

Since cmake_dependent_option forces the option to its <force> value whenever the dependency
expression is false, and an undefined variable is false, FMU_TESTING is forced OFF and hidden
regardless of configuration. It does not appear in the CMake cache of a configured build. So FMU testing
cannot currently be switched on.

Introduced in 47ade30 ("Refactor Chrono::FMI to separate build requirements for FMU export and
import.", 2024-05-22), which renamed the export option; this one reference did not follow the rename.

The fix is presumably one word:

cmake_dependent_option(FMU_TESTING "Enable FMU testing" ON "FMU_EXPORT_SUPPORT" OFF)

I have not sent a patch because I have not confirmed what FMU_TESTING is supposed to gate, and whether
those tests currently pass, is worth knowing before it is turned on for everyone. Scope note on the
evidence: the single reference, the absent definition, and the absence of FMU_TESTING from a configured
cache are all verified. The claim that it would become settable after the rename follows from
cmake_dependent_option semantics and was not measured, since doing so needs a static build with
FMU_EXPORT_SUPPORT=ON.

Found while working on #762 / #772.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugconcerns bugs or unusual behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions