oxfordcontrol / Clarabel.cpp

Clarabel.cpp: C/C++ interface to the Clarabel Interior-point solver for convex conic optimisation problems.
Apache License 2.0
33 stars 11 forks source link

Add support for usage of Clarabel.cpp via `add_subdirectory` #46

Open codeinred opened 4 months ago

codeinred commented 4 months ago

A common pattern is to have C++ dependencies provisioned via git submodule. These dependencies can then be included via add_subdirectory, however this fails with Clarabel.cpp because Clarabel.cpp expects to be the top-level project:

if(CMAKE_BUILD_TYPE MATCHES Release)
   set(clarabel_c_build_flags "--release")
   set(clarabel_c_output_directory "${CMAKE_SOURCE_DIR}/rust_wrapper/target/release")
else()
    set(clarabel_c_build_flags "")
    set(clarabel_c_output_directory "${CMAKE_SOURCE_DIR}/rust_wrapper/target/debug")
endif()

If Clarabel.cpp is not the top-level project, it will fail to build, because directories like rust_wrapper won't be found.