Add conan files#1184
Conversation
…ps://github.com/codingwithmagga/MatX into codingwithmagga/fix-359-package-manager-support
|
Thanks for doing this! One comment I have is that the version number is hard-coded in many places making it a maintenance burden to update all the right places. Would it be possible to grab the source version from CMakeLists.txt, which is our current source of truth? Also, what would be required to make this present in the public conan repo? |
Greptile SummaryThis PR adds Conan 2 packaging support for MatX, introducing a root-level
Confidence Score: 4/5Safe to merge as a first-cut Conan packaging addition; no changes to library code or existing build infrastructure. The core recipe logic is sound and follows Conan 2 conventions. The main gap is that conanfile.py — the recipe's missing Important Files Changed
Sequence DiagramsequenceDiagram
participant Dev as Developer
participant Conan as Conan CLI
participant CMake as CMake
participant CPM as CPM/FetchContent
participant GitHub as GitHub (CCCL)
participant Cache as Local Conan Cache
Dev->>Conan: conan create .
Conan->>CMake: cmake.configure()
CMake->>CPM: rapids_cpm_cccl()
CPM->>GitHub: Download CCCL (requires internet)
GitHub-->>CPM: CCCL source
CMake-->>Conan: Configure done
Conan->>CMake: cmake.install()
CMake-->>Conan: Headers + cmake config files
Conan->>Cache: Store matx/1.0.0 package
Dev->>Conan: conan build . (test_package)
Conan->>CMake: Generate CMakeDeps + CMakeToolchain
CMake->>Cache: find_package(matx CONFIG REQUIRED)
Cache-->>CMake: matx::matx target
CMake-->>Dev: test_package binary built
Reviews (1): Last reviewed commit: "Merge branch 'codingwithmagga/fix-359-pa..." | Re-trigger Greptile |
| package_type = "header-library" | ||
| description = ( |
There was a problem hiding this comment.
For a
header-library package, setting no_copy_source = True is recommended. Without it, Conan copies all exports_sources (including the large cmake/rapids-cmake/ tree) into the build folder before calling cmake.configure(). This is unnecessary for a header-only library and can significantly slow down the packaging step.
| package_type = "header-library" | |
| description = ( | |
| package_type = "header-library" | |
| no_copy_source = True | |
| description = ( |
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
| def package(self): | ||
| cmake = CMake(self) | ||
| cmake.configure() |
There was a problem hiding this comment.
CCCL fetched via CPM during
package() step
The main CMakeLists.txt calls rapids_cpm_cccl() during configure, which triggers CPM/FetchContent to download CCCL from GitHub. Because CCCL is not declared as a Conan dependency in this recipe, conan create . silently requires internet access — it will fail in offline or air-gapped environments. Ideally CCCL would be expressed as a requires() or tool_requires() in the recipe, but at a minimum this dependency on network access during packaging should be documented.
| using namespace matx; | ||
|
|
||
| int main([[maybe_unused]] int argc, [[maybe_unused]] char **argv) | ||
| { | ||
| auto a = matx::make_tensor<float>({10}); | ||
| a.SetVals({1, 2, 3, 4, 5, 6, 7, 8, 9, 10}); | ||
|
|
||
| matx::print(a); | ||
| } No newline at end of file |
There was a problem hiding this comment.
The
using namespace matx; declaration is never actually relied upon — every call below still uses explicit matx:: qualification. Either remove the using declaration or drop the redundant qualifiers.
| using namespace matx; | |
| int main([[maybe_unused]] int argc, [[maybe_unused]] char **argv) | |
| { | |
| auto a = matx::make_tensor<float>({10}); | |
| a.SetVals({1, 2, 3, 4, 5, 6, 7, 8, 9, 10}); | |
| matx::print(a); | |
| } | |
| int main([[maybe_unused]] int argc, [[maybe_unused]] char **argv) | |
| { | |
| auto a = matx::make_tensor<float>({10}); | |
| a.SetVals({1, 2, 3, 4, 5, 6, 7, 8, 9, 10}); | |
| matx::print(a); | |
| return 0; | |
| } |
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
| def test(self): | ||
| if can_run(self): | ||
| bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") | ||
| self.run(bin_path, env="conanrun") No newline at end of file |
Conan
Add conan files to create a matx conan package.
Workflow
In the main folder run
conan create .This creates the matx conan package on your system.
Test
After creating the conan package create a new folder with a
conanfile.py.I added a
CMakeLists.txtand a foldersrcwhere I copied the examples from this repo to.Now you can run
conan build .to create the examples using conan and the matx conan package.