LLNL / sundials

Official development repository for SUNDIALS - a SUite of Nonlinear and DIfferential/ALgebraic equation Solvers. Pull requests are welcome for bug fixes and minor changes.
https://computing.llnl.gov/projects/sundials
BSD 3-Clause "New" or "Revised" License
515 stars 125 forks source link

Check system installation of sundials #533

Closed sn248 closed 3 months ago

sn248 commented 3 months ago

Hi

I am trying to update the R interface to Sundials (sn248/sundialr). R package rules dictate that I first check for system installation of sundials before using the bundled-up version.

I was not able to find any information regarding pkg-config for sundials.

Could you suggest how to check if sundials is installed on user's machine?

Thanks

balos1 commented 3 months ago

I was not able to find any information regarding pkg-config for sundials.

We do not provide a pkg-config file at this time (see #242).

Could you suggest how to check if sundials is installed on user's machine?

CMake's find_package command is the supported way. Not sure if this possible for you to use in the context of R.

sn248 commented 3 months ago

Thank you for the quick response. I used the following to know that SUNDIALS exists.

sudo cmake --find-package -DNAME=SUNDIALS -DCOMPILER_ID=GNU -DLANGUAGE=C -DMODE=EXIST

which gives

SUNDIALS found

But I am not able to get the location of header files and static libraries (in /usr/local/include and /usr/local/lib respectively), when I use the following commands.

sudo cmake --find-package -DNAME=SUNDIALS -DCOMPILER_ID=GNU -DLANGUAGE=C -DMODE=COMPILE

sudo cmake --find-package -DNAME=SUNDIALS -DCOMPILER_ID=GNU -DLANGUAGE=C -DMODE=LINK

In addition, I would also like to check that the installed version is 7.0.0 or higher.

Any suggestion would be very helpful. Thanks!

balos1 commented 3 months ago

Sorry, I meant that the supported way is to use the find_package command from a CMakeLists.txt. According to the output of cmake --help though, the --find-package command line option is deprecated (I have never used it either, so I am unsure if it can do what youre asking).

From a CMakeLists.txt you would do

find_package(SUNDIALS)

Then the SUNDIALS::<component> targets would give you the link libraries and include paths. See this part of the docs.

Otherwise, you may need to write some custom script to look for sundials and then parse the SUNDIALSConfig.cmake / SUNDIALSTargets.cmake files to get the includes and link libraries. We have noted that a pkg-config file is a requested feature and hope to add it at some point in the future (we would also happily take a community contribution that does it).

sn248 commented 3 months ago

Thanks again! This is helpful although I am not sure how to use a CMakelist.txt within R package to compile using system installation.

Perhaps, I will wait till we get a pkg-config, until then use the current approach of bundling the Sundials source with the package.

balos1 commented 3 months ago

OK. I will close this now as a duplicate request for a pkg-config file.