mpreal icon indicating copy to clipboard operation
mpreal copied to clipboard

Add cmake.

Open emsr opened this issue 4 years ago • 9 comments

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

emsr avatar Sep 18 '20 17:09 emsr

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

advanpix avatar Jan 22 '22 01:01 advanpix

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.

advanpix avatar Feb 15 '22 03:02 advanpix

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

emsr avatar Mar 02 '22 15:03 emsr

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

emsr avatar Mar 02 '22 15:03 emsr

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 avatar Mar 02 '22 15:03 emsr

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

emsr avatar Mar 08 '22 18:03 emsr

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.

advanpix avatar Mar 10 '22 03:03 advanpix

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 avatar Mar 11 '22 17:03 emsr

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

emsr avatar Mar 11 '22 17:03 emsr