Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CMake: improve search for Zycore #461

Merged
merged 1 commit into from
Oct 15, 2023
Merged

CMake: improve search for Zycore #461

merged 1 commit into from
Oct 15, 2023

Conversation

athre0z
Copy link
Member

@athre0z athre0z commented Oct 15, 2023

The changes in this PR should allow Zydis to find Zycore in more situations automatically. Most importantly, find_package(Zycore) is now something that we try automatically. This should allow distributions that ship Zycore as a separate package to do so more easily without having to delve into out CMake logic to discover the ZYAN_SYSTEM_ZYCORE option.

I tested:

  • building a full clone with submodule
  • building an incomplete clone (with and without git installed)
  • fallback to system zycore (by hacking the NixOS package, with and without -DZYAN_SYSTEM_ZYCORE)

This should allow Zydis to find Zycore in more situations automatically.
Most importantly, `find_package(Zycore)` is now something that we try
automatically. This should allow distributions that ship Zycore as a
separate package to do so more easily without having to delve into out
CMake logic to discover the `ZYAN_SYSTEM_ZYCORE` option.
@athre0z athre0z added C-enhancement Category: Enhancement of existing features P-low Priority: Low A-build Area: Build system labels Oct 15, 2023
@athre0z athre0z requested a review from flobernd October 15, 2023 19:57
Copy link
Member

@flobernd flobernd left a comment

Choose a reason for hiding this comment

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

LGTM! Good improvement.

message(FATAL_ERROR "ZYAN_SYSTEM_ZYCORE set but no system-installed Zycore found")
endif ()

find_package(Git QUIET)
Copy link
Member

@flobernd flobernd Oct 15, 2023

Choose a reason for hiding this comment

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

We could possibly change this block to the newer CMake 'FetchContent' APIs. However, not sure if we would have to bump our CMake version requirement to do so.

Edit: It might introduce some overhead, as we would have to determine the correct commit hash, that's used for the Git submodule.

Copy link
Member Author

Choose a reason for hiding this comment

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

I suspect we'd have to maintain a separate pinned revision in the CMakeLists then, no? With the existing approach we're using the revision stored in git's meta-info. Or does FetchContent explicitly support this somehow?

Copy link
Member

Choose a reason for hiding this comment

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

I think we would have to either maintain it in two places or extract the hash from the repository config by parsing the Git files.

Not sure if it's worth it. Probably not. Git should be installed on most dev machines anyways.

@athre0z athre0z merged commit 49fa4db into master Oct 15, 2023
13 checks passed
@athre0z athre0z deleted the better-zycore-search branch October 15, 2023 20:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-build Area: Build system C-enhancement Category: Enhancement of existing features P-low Priority: Low
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants