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

Add cmake. #4

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open

Add cmake. #4

wants to merge 11 commits into from

Conversation

emsr
Copy link
Contributor

@emsr emsr commented Sep 18, 2020

This adds cmake support. This is useful to use mpreal as a submodule in another git project that uses cmake. The only targets are the interface (header-only) library mpreal and mpreal_example - the test/example utility. I left the makefile in the example directory as it doesn't impact cmake.

We could set the C++ version back to 11 if you want to.
Ed Smith-Rowland

@advanpix
Copy link
Owner

Yes, it is better to remove requirement for C++ standard as mpreal can work with anything down to C++ 2003 and even older.

@advanpix
Copy link
Owner

Please consider removing the restriction on C++ standard. It is really has no sense for MPFR C++.
I would prefer keeping GMP/MPFR CMake files out of the MPFR C++ repository. It is responsibility of the main program/target user to find & link to proper GMP/MPFR.

Besides, GMP cannot be used in MSVC (MPIR is used instead). So that including GMP scripts has no sense for a lot of target users.

@emsr
Copy link
Contributor Author

emsr commented Mar 2, 2022

I'm removing the standard requirement. That's a good idea.
I just pushed to my repo.

@emsr
Copy link
Contributor Author

emsr commented Mar 2, 2022

I took out the GMP and MPFR scripts also.
So now it's just a header-only library with no enforced dependencies.
W00t!

@emsr
Copy link
Contributor Author

emsr commented Mar 2, 2022

The CMakeLists does still have mpfr as a target link library for the example but it doesn't seem to need a script if mpfr is on your system.

@emsr
Copy link
Contributor Author

emsr commented Mar 8, 2022

Ok, now I've pushed the changes to my branch. No sure what happened. I also merged the latest.

@advanpix
Copy link
Owner

Could you please elaborate a bit why do you think CMake is needed for mpreal at all?
The mpreal is one-header library, without restrictions on C++ compiler features, on GMP/MPIR/MPFR versions, etc. etc. Basically it is supposed to be used as a simple header file.

I use CMake in most of my projects, but I have difficulties in understanding how it can be useful for mpreal. Would appreciate to see some real example why this can be useful.

@emsr
Copy link
Contributor Author

emsr commented Mar 11, 2022

This came up when I added mpreal as a submodule in a larger cmake project. This allows another part of the library to have

add_executable(thing ...)
target_link_libraries(thing mpreal ...)

So everywhere I use mpreal it's just adding one word in target_link_libraries.

I agree that there's no reason intrinsic to mpreal to have CMakeLists (it does build the example) - it's just easier to integrate into a larger cmake project. Not that it's that hard anyway.

@emsr
Copy link
Contributor Author

emsr commented Mar 11, 2022

I don't think having CMake would break other ways of using mpreal.

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

Successfully merging this pull request may close these issues.

2 participants