Skip to content

Conversation

@Ubospica
Copy link
Contributor

@Ubospica Ubospica commented Oct 15, 2025

Relocate CMake config files from cmake/ to share/cmake/tvm_ffi/ to match
CMake's standard search pattern <prefix>/<name>*/share/cmake/<name>*/.

This enables find_package(tvm_ffi CONFIG REQUIRED) to work automatically
without manually setting tvm_ffi_ROOT.

When find_package(Python) is called, CMake adds sys.prefix to search paths,
allowing it to discover tvm-ffi's config files in the standard location.

This also aligns with pybind's behavior. See also https://github.com/pybind/pybind11/blob/a2c59711b20707d64b7ad61d488e002611369780/.github/CONTRIBUTING.md#L325 and https://github.com/pybind/pybind11/blob/a2c59711b20707d64b7ad61d488e002611369780/pybind11/commands.py#L22.

Changes:

  • CMakeLists.txt: Install config to share/cmake/tvm_ffi/
  • libinfo.py: Update find_cmake_path() to check standard path first
  • examples: Simplify CMakeLists.txt to use direct find_package()

This PR also avoids rebuilding in editable installation mode, and adds a cd command in the readme of examples to ensure user is in the correct directory.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @Ubospica, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the usability and integration of tvm_ffi with CMake-based projects. By relocating CMake configuration files to a standard share/cmake directory, tvm_ffi can now be automatically discovered by find_package, eliminating the need for manual path configuration. This change simplifies project setups, particularly for examples, and optimizes the editable installation process by preventing redundant builds.

Highlights

  • CMake Config Relocation: CMake configuration files for tvm_ffi are now installed to share/cmake/tvm_ffi/ to align with standard CMake search patterns, improving discoverability.
  • Automatic Discovery: find_package(tvm_ffi CONFIG REQUIRED) now automatically discovers the tvm_ffi CMake configuration without needing to manually set tvm_ffi_ROOT.
  • Simplified Examples: Example CMakeLists.txt files have been simplified by removing manual calls to tvm_ffi.config for CMake path discovery, making them cleaner and easier to use.
  • Editable Install Optimization: The build system is configured to avoid unnecessary rebuilding when performing an editable installation, streamlining the development workflow.
  • Improved Example Readme: README.md files in examples now include cd commands to ensure users are in the correct directory before running installation or build commands, preventing common user errors.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request makes a valuable improvement by relocating the CMake configuration files to a standard directory, which enables automatic discovery by CMake's find_package. This simplifies the integration for downstream projects, as demonstrated by the cleanup in the example files. The addition of editable.rebuild = false is also a nice touch for improving the developer workflow during editable installs.

My review found one issue in python/tvm_ffi/libinfo.py where the path to the new CMake directory is constructed incorrectly for standard installations. I've left a specific comment with a suggested fix. Otherwise, the changes are well-implemented and align with the stated goals.

@tqchen tqchen merged commit df04392 into apache:main Oct 15, 2025
7 checks passed
@junrushao
Copy link
Member

Nice work!! I was about to ask :)

@tqchen
Copy link
Member

tqchen commented Oct 18, 2025

note that this unfortunately does not work for cmake that is outside of scikit build part, so we still need to keep the cmake path for max compact

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants