-
Notifications
You must be signed in to change notification settings - Fork 17
Open
Description
I want to use Clarabel as a library via the C-interface.
Is there a way to read the configuration used for building? In particular, I would need to know all features like
CLARABEL_USE_FLOAT
CLARABEL_FEATURE_SDP
CLARABEL_FEATURE_SERDE
CLARABEL_FEATURE_FAER_SPARSE
These features are used in the C-structs and if I set them to a value different from the one a compile time, the code will segfault.
I think one way would be through writing a configuration file, via something like
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/clarabel_config.h.in ${clarabel_c_output_directory}/clarabel_config.h @ONLY)
This will take a configuration file clarabel_config.h.in and parse it. This could look like
#ifndef __CLARABEL_CONFIG_H__
#define __CLARABEL_CONFIG_H__
#cmakedefine CLARABEL_USE_FLOAT
#cmakedefine CLARABEL_FEATURE_SDP
#cmakedefine CLARABEL_FEATURE_SERDE
#cmakedefine CLARABEL_FEATURE_FAER_SPARSE
#endif
The output would be the following file clarabel_config.h:
#ifndef __CLARABEL_CONFIG_H__
#define __CLARABEL_CONFIG_H__
/* #undef CLARABEL_USE_FLOAT */
#define CLARABEL_FEATURE_SDP
#define CLARABEL_FEATURE_SERDE
#define CLARABEL_FEATURE_FAER_SPARSE
#endif
This will only work for features that are directly specified, not the ones passed as CARGO_FEATURES.
Metadata
Metadata
Assignees
Labels
No labels