Skip to content

build: migrate from git submodule to CPM for dependency management#116

Open
izzalDev wants to merge 4 commits into
artyom-beilis:masterfrom
izzalDev:pyproject
Open

build: migrate from git submodule to CPM for dependency management#116
izzalDev wants to merge 4 commits into
artyom-beilis:masterfrom
izzalDev:pyproject

Conversation

@izzalDev
Copy link
Copy Markdown

@izzalDev izzalDev commented May 9, 2026

Summary

Replaces the dlprimitives git submodule with CPM.cmake so that all C++ dependencies are fetched automatically at CMake configure time. Callers no longer need --recurse-submodules when cloning.

Also adds pyproject.toml to enable building and installing the package via uv build / pip install . using scikit-build-core.

Motivation

  • Git submodules require manual init and are a common source of "why doesn't this build?" complaints from new contributors.
  • CPM provides a single-file, zero-install dependency manager for CMake projects and supports a local source cache via CPM_SOURCE_CACHE.
  • Packaging via pyproject.toml makes the project installable with standard Python tooling without manual CMake invocations.

Changes

File What changed
.gitmodules Removed — submodule replaced by CPM
dlprimitives Submodule entry deleted
cmake/CPM.cmake Added — bootstraps CPM v0.42.3 at configure time
CMakeLists.txt CPMAddPackage for dlprimitives, OpenCL-Headers, OpenCL-CLHPP; switch to target_include_directories; bump cmake min to 3.15
pyproject.toml Added — scikit-build-core build backend, uv source for CPU torch
README-build.md Simplified; documents uv-based build and CPM cache tip

How to test

  • Clone without --recurse-submodules — build should succeed.
  • Run uv build and verify a .whl is produced in dist/.
  • Install the wheel and run python mnist.py --device ocl:0.
  • Set CPM_SOURCE_CACHE=$HOME/.cache/CPM, delete build/, reconfigure — deps should load from cache without re-downloading.

izzalDev added 3 commits May 9, 2026 08:31
Replace dlprimitives git submodule with CPM (CMake Package Manager) to
automatically fetch dlprimitives, OpenCL-Headers, and OpenCL-CLHPP at
build time. This removes the need for --recurse-submodules on clone.

- Remove .gitmodules and dlprimitives submodule
- Add cmake/CPM.cmake bootstrap script (v0.42.3)
- Update CMakeLists.txt to use CPMAddPackage for all C++ dependencies
- Switch include_directories to target_include_directories on pt_ocl
- Bump cmake minimum version to 3.15
- Add pyproject.toml for scikit-build-core / uv based Python packaging
- Update README-build.md to reflect new uv-based build workflow
@izzalDev
Copy link
Copy Markdown
Author

izzalDev commented May 9, 2026

With scikit-build-core, you no longer need to manually specify the Python and Pytorch paths, having to write those path every build is a real pain. Instead of spending time on configuration, this lets contributors stay focused on the implementation.

@artyom-beilis
Copy link
Copy Markdown
Owner

Can you please elaborate - I'm not aware of CPM and there is another good reason for submodule - development.

I frequently do changed in dlprimitives together with pytorch dlprim - so having it as submodule allows smooth transition. As I modify it in submodule directly and commit changes.

--recurse-submodules - is pretty standard practice.

@izzalDev
Copy link
Copy Markdown
Author

izzalDev commented May 9, 2026

CPM (CMake Package Manager) simplifies dependency management by handling libraries like OpenCL headers automatically within CMake, keeping your system clean without the need for external package managers (such as apt, Homebrew, vcpkg, or Conan). On the other hand, you can still use Git Submodules for the active development of dlprimitives to ensure that the process of modifying and committing code across projects remains smooth, standard, and portable. Do you want to keep using submodules for that part?

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.

2 participants