Refactor CMake build system with modular options #32
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary of Changes
This PR refactors the root
CMakeLists.txtto introduce a set of modular build options, inspired by best practices seen in projects likeosqp. 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 onSTATIC_LIB)CUPDLPX_BUILD_TESTS(Default:OFF, depends onSTATIC_LIB)CUPDLPX_BUILD_PYTHON(Default:OFF, depends onSTATIC_LIB)The
installrules 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).
libcupdlpx.soshared library.cupdlpx_corestatic library for thepybind11module 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:
[Julia]
build_tarballs.jlis updated:Now explicitly passes
-DCUPDLPX_BUILD_SHARED_LIB=ONand disables all other targets (STATIC_LIB=OFF,CLI=OFF,TESTS=OFF,PYTHON=OFF) to ensure only the shared library is built.[Python]
pyproject.tomlis updated:Now explicitly passes
-DCUPDLPX_BUILD_STATIC_LIB=ONand-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.