oscarhiggott / PyMatching

PyMatching: A Python/C++ library for decoding quantum error correcting codes with minimum-weight perfect matching.
Apache License 2.0
187 stars 32 forks source link

Make it easier to use pymatching as a C++ dependency #77

Closed Strilanc closed 1 year ago

Strilanc commented 1 year ago

Linking from CMake

Note the commit ID I'm using is the latest commit of this PR, not one on main.

Here is now a way to use pymatching as a cmake dependency. In the CMakeLists.txt file fetch it using FetchContent:

FetchContent_Declare(pymatching
        GIT_REPOSITORY https://github.com/oscarhiggott/pymatching.git
        GIT_TAG 48098cf8d6d77fb4c2caf0ab319b31bde4d37d22 )
FetchContent_GetProperties(pymatching)
if(NOT pymatching_POPULATED)
  FetchContent_Populate(pymatching)
  add_subdirectory(${pymatching_SOURCE_DIR})
endif()

You can then link to it:

[...]
target_link_libraries(YOURLIBRARY libpymatching)
[...]

Linking from Bazel

Note the commit ID I'm using is the latest commit of this PR, not one on main.

In WORKSPACE:

load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
git_repository(
    name = "pymatching",
    commit = "48098cf8d6d77fb4c2caf0ab319b31bde4d37d22",
    remote = "https://github.com/oscarhiggott/pymatching.git",
)

In BUILD:

cc_binary(
    name = "your_project",
    ...
    deps = [
        "@pymatching//:libpymatching",
    ],
)

Fixes https://github.com/oscarhiggott/PyMatching/issues/76

codecov-commenter commented 1 year ago

:warning: Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 100.00%. Comparing base (1211298) to head (48098cf). Report is 24 commits behind head on master.

:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #77 +/- ## ========================================= Coverage 100.00% 100.00% ========================================= Files 3 3 Lines 331 331 ========================================= Hits 331 331 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

Strilanc commented 1 year ago

Don't merge this yet, I'm still cleaning it up.

Strilanc commented 1 year ago

Okay this should be safe to merge now, assuming tests pass.