Skip to content

Conversation

@ZedongPeng
Copy link
Collaborator

Summary of Changes

This PR refactors the root CMakeLists.txt to introduce a set of modular build options, inspired by best practices seen in projects like osqp. This provides fine-grained control over which build artifacts are created.

The new key options are:

  • CUPDLPX_BUILD_STATIC_LIB (Default: ON)
  • CUPDLPX_BUILD_SHARED_LIB (Default: ON)
  • CUPDLPX_BUILD_CLI (Default: ON, depends on STATIC_LIB)
  • CUPDLPX_BUILD_TESTS (Default: OFF, depends on STATIC_LIB)
  • CUPDLPX_BUILD_PYTHON (Default: OFF, depends on STATIC_LIB)

The install rules have also been updated to respect these new options.

Motivation for this Change

The previous build system built all targets (static lib, shared lib, CLI) at once, which is not ideal for different packaging ecosystems (Python vs. Julia).

  • Julia (Yggdrasil) only needs the libcupdlpx.so shared library.
  • Python (Wheels) only needs the cupdlpx_core static library for the pybind11 module to link against.

These options allow us to create minimal, clean builds tailored for each packaging workflow.

Impact on Packaging

This PR updates the build configurations for both Julia and Python:

  1. [Julia] build_tarballs.jl is updated:
    Now explicitly passes -DCUPDLPX_BUILD_SHARED_LIB=ON and disables all other targets (STATIC_LIB=OFF, CLI=OFF, TESTS=OFF, PYTHON=OFF) to ensure only the shared library is built.

  2. [Python] pyproject.toml is updated:
    Now explicitly passes -DCUPDLPX_BUILD_STATIC_LIB=ON and -DCUPDLPX_BUILD_PYTHON=ON, while disabling all other targets (SHARED_LIB=OFF, CLI=OFF, TESTS=OFF). This ensures the Python wheel is built by statically linking the core library.

This makes the packaging workflows for different platforms cleaner, more robust, and more efficient.

@ZedongPeng ZedongPeng merged commit c2e7bb4 into MIT-Lu-Lab:main Nov 15, 2025
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.

1 participant