Skip to content

ONNX_MLIR_BUILD_TESTS doesn't appear to be honored #3285

@mschofie

Description

@mschofie

The "ONNX_MLIR_BUILD_TESTS" setting is documented as controlling whether the test executables are built. But it doesn't appear to be honored. A couple of problems:

  1. It's only tested in docs/doc_example/CMakeLists.txt and test/multiple-models/CMakeLists.txt
  2. When it's ON, the logic sets set(EXCLUDE_FROM_ALL ON). The CMake documentation for EXCLUDE_FROM_ALL says that it's either a property on a target (documentation), or a property on a directory (documentation) - and set(EXCLUDE_FROM_ALL ON) sets neither.

It looks like a fix would be to:

  1. Test it in docs/doc_example/CMakeLists.txt and test/CMakeLists.txt
  2. Set the property on the directory with (for example):
# If 'ONNX_MLIR_BUILD_TESTS' is ON, set 'EXCLUDE_FROM_ALL' for this directory. This will allow test targets to be
# defined, but 'all' will not depend on them by default.
if (NOT ONNX_MLIR_BUILD_TESTS)
  set_directory_properties(PROPERTIES EXCLUDE_FROM_ALL ON)
endif()

This problem manifests for me with a Visual Studio Generator, and the fix fixes it. I'll double check with a Ninja Generator. I'm happy to send the fix; wondering if others see this problem...?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions