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

Allow cmake users to use FetchContent_Declare #2967

Open
SteveBronder opened this issue Oct 25, 2023 · 3 comments
Open

Allow cmake users to use FetchContent_Declare #2967

SteveBronder opened this issue Oct 25, 2023 · 3 comments

Comments

@SteveBronder
Copy link
Collaborator

Description

It would be nice for cmake users to be able to use something like the following to include Stan math in their projects

include(FetchContent)

FetchContent_Declare(
  stanmath
  GIT_REPOSITORY https://github.com/stan-dev/math
  GIT_TAG        v4.7.0
)

FetchContent_MakeAvailable(stanmath)

I have part of this written here where I have stan math compiling with cmake. I'd be happy to expand this into a CMakeLists.txt file in the stan math repo, which would then allow cmake users to do something like the above to include stan math in their projects.

Do any folks have objections to this? I'd say the cmake file I have there is like 60% complete. It does all the correct includes, but does not handle some of the specific flags we use. It also does not support MPI, but that should be easy to setup.

If I set this up we could also setup our test suite to integrate with ctest

Expected Output

Please provide the expected output.

If this is a bug report, show what you expected to happen. Please also show what currently happens.

If this is a feature request, show what you expect to happen if the feature exists.

Current Version:

v4.7.0

@SteveBronder SteveBronder changed the title Allow cmake users to use Allow cmake users to use FetchContent_Declare Oct 25, 2023
@syclik
Copy link
Member

syclik commented Oct 31, 2023

No objections!

@WardBrian
Copy link
Member

I have my own version of this (modified from Steve’s) here: https://github.com/WardBrian/math/tree/experiment/cmake

It has a bit more flag configuration and some logic to support a “install” target for Math, which would let other tools use a find_library call

@riddell-stan
Copy link

Having a canonical version that's tested would be wonderful.

I'm interested in moving to cmake because there's a new Python build system scikit-build that would allow pystan/httpstan to create a source distribution. It would work even if the user doesn't have cmake installed. It works on many more platforms than we currently support.

I'm afraid I haven't found time to really learn cmake, otherwise I'd be more than happy to help out with this.

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

4 participants