Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
codeinred opened this issue Jun 6, 2024 · 1 comment
Closed

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

codeinred opened this issue Jun 6, 2024 · 1 comment

Comments

@codeinred
Copy link
Contributor

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.

codeinred added a commit to codeinred/Clarabel.cpp that referenced this issue Jun 6, 2024
This commit allows Clarabel.cpp to be consumed by other CMake projects
via a call to `add_subdirectory`:

```cmake

add_subdirectory(path/to/clarabel.cpp)
```

Other projects might have Clarabel.cpp as a git submodule, and this
makes it easier to do so.
goulart-paul added a commit that referenced this issue Jan 13, 2025
goulart-paul added a commit that referenced this issue Feb 2, 2025
* fix issue #44 - eigen requires at least c++14 support

* fix issue #45 - specify byproducts

Build fails if ninja isn't aware of the byproducts for libclarabel_c

* fix issue #46 - support use via `add_subdirectory`

This commit allows Clarabel.cpp to be consumed by other CMake projects
via a call to `add_subdirectory`:

```cmake

add_subdirectory(path/to/clarabel.cpp)
```

Other projects might have Clarabel.cpp as a git submodule, and this
makes it easier to do so.

* Remove unncessary <iostream> include

Including iostream means introducing the static (global) constructors
and destructors for std::cin, std::cerr, and std::cout. That extra
init and fini code is undesirable when those streams are not actually
used.

* bump version

* fixes #48

* fixes #49

* fix v1.84 clippys

* fixes #43

* update submodule

* add max_threads

* v0.10 build fixes

---------

Co-authored-by: Alecto Irene Perez <[email protected]>
Co-authored-by: Jeremy Nimmer <[email protected]>
@goulart-paul
Copy link
Member

With apologies for the long delay : thank you for these, which are now in v0.10.0.

goulart-paul pushed a commit that referenced this issue Feb 2, 2025
* fix issue #44 - eigen requires at least c++14 support

* fix issue #45 - specify byproducts

Build fails if ninja isn't aware of the byproducts for libclarabel_c

* fix issue #46 - support use via `add_subdirectory`

This commit allows Clarabel.cpp to be consumed by other CMake projects
via a call to `add_subdirectory`:

```cmake

add_subdirectory(path/to/clarabel.cpp)
```

Other projects might have Clarabel.cpp as a git submodule, and this
makes it easier to do so.
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

No branches or pull requests

2 participants