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

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

Open
jvannugteren opened this issue Apr 16, 2024 · 3 comments
Open

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

jvannugteren opened this issue Apr 16, 2024 · 3 comments
Assignees
Labels
enhancement New feature or request

Comments

@jvannugteren
Copy link

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
Copy link
Owner

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.

@DrTimothyAldenDavis DrTimothyAldenDavis added the enhancement New feature or request label Apr 16, 2024
@DrTimothyAldenDavis DrTimothyAldenDavis self-assigned this Apr 16, 2024
@jvannugteren
Copy link
Author

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 added a commit to mmuetzel/SuiteSparse that referenced this issue Apr 17, 2024
Some preprocessor flags that are conditionally set by the build rules of
CHOLMOD affect which symbols are exported from the built libraries.
Add the preprocessor flags that are used to guard function declarations
in `cholmod.h` to the CMake targets and the pkg-config file. That way
consumers of the library get only those declarations that are actually
exported from the library when including `cholmod.h` in their code.

Fixes DrTimothyAldenDavis#794.
@mmuetzel
Copy link
Contributor

I opened #795 that might help with this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants