DrTimothyAldenDavis / SuiteSparse

The official SuiteSparse library: a suite of sparse matrix algorithms authored or co-authored by Tim Davis, Texas A&M University.
https://people.engr.tamu.edu/davis/suitesparse.html
Other
1.11k stars 256 forks source link

Way to detect whether CHOLMOD is compiled with LGPL enabled #794

Open jvannugteren opened 3 months ago

jvannugteren commented 3 months ago

Thank you for making this large collection of very useful libraries available.

I'm offering my users the ability to link my MIT licensed code to cholmod using cmake. For this purpose it is sometimes necessary to use CHOLMOD in LGPL mode, i.e. no supernodal, cuda etc. Otherwise the combined code becomes GPL, which is in some cases too restrictive. This means I'd like to build in a safety feature in my compilation process that requires the user to explicitly and knowingly enable the GPL features of CHOLMOD, or otherwise only allow linking to the LGPL version.

To do this in cmake I require a way to detect how CHOLMOD was compiled. However, the compile definitions are not carried over to the installed target as add_compile_definitions(NGPL) etc are used. Would it be possible to use something like target_compile_definitions(CHOLMOD PUBLIC NGPL) instead (also for NSUPERNODAL), similar to how it is currently done for CHOLMOD_HAS_CUDA. I believe this then should carry over to the cmake installed target. This would then automatically enable the #ifdef features in cholmod.h as well.

Or is there perhaps another way to achieve what I need?

DrTimothyAldenDavis commented 3 months ago

That would be a good idea to add. I could use cmake to configure cholmod.h with #define's that can be used to determine which modules are installed, and whether or not an GPL modules are installed. That would be better than adding target_compile_definitions in cmake.

I could also add a user-callable function that returns true/false for any module, to query if it is installed, and true/false if any GPL modules are installed.

jvannugteren commented 3 months ago

That would be great. With this I can probably use some preprocessor directives to throw a compile time error if there is a problem with the licensing situation. Thank you for having a look at this.

mmuetzel commented 3 months ago

I opened #795 that might help with this.