flogging icon indicating copy to clipboard operation
flogging copied to clipboard

Use CMake to build library

Open pzehner opened this issue 4 years ago • 5 comments

This PR aims to change the build script from GNU Make to CMake.

Using CMake makes the project compiler-independent, platform-independent, and it automatizes the installation process. It also allows to seamlessly use the library in another project using CMake.

Almost all features present in the old Makefile have been translated to CMake instructions (using the modern, post 3.11.0, syntax). The file has been deleted, but it can be restored. The only target I am not sure about is make doc_deploy.

A full workflow looks like:

# create build directory
mkdir build
cd build
# prepare a release build with tests
cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=ON ..
# build (using GNU Make)
make
# test
ctest
# install
sudo make install
# build doc
make doc

pzehner avatar Feb 11 '21 12:02 pzehner

I appreciate the use of CMake, and it seems like a nice workflow. However, I would like it to also be available to people compiling it 'manually' with Make. Perhaps we can keep a (simplified) Makefile with a message about using CMake?

In some projects it sees use as a subtree in the source code instead of a system-wide install, since fortran .mod files are not compatible across compilers (and between versions).

DaanVanVugt avatar Feb 11 '21 12:02 DaanVanVugt

I've added the Makefile back with a warning when used.

I'm still thinking about a clean way for the subtree scenario.

pzehner avatar Feb 11 '21 16:02 pzehner

Thanks! Perhaps we don't need to do much in that case, if people would use their existing build system and just adjust the include path, it could suffice just to make some docs. Could be out of scope for this PR ;)

DaanVanVugt avatar Feb 11 '21 16:02 DaanVanVugt

Just a random question, is it necessary to produce a shared library? I'm also testing the lib with the PGI compiler and it behaves better with a static library instead.

pzehner avatar Mar 21 '21 09:03 pzehner

I have no preference there, since its really small it might be better as a static library. Originally I thought making a shared library would help with portability across compilers, but since we also need to use flogging iirc it does not matter.

DaanVanVugt avatar Mar 21 '21 10:03 DaanVanVugt