Skip to content

Use CMake to build library#5

Draft
pzehner wants to merge 9 commits intoDaanVanVugt:masterfrom
pzehner:master
Draft

Use CMake to build library#5
pzehner wants to merge 9 commits intoDaanVanVugt:masterfrom
pzehner:master

Conversation

@pzehner
Copy link
Contributor

@pzehner pzehner commented Feb 11, 2021

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

@DaanVanVugt
Copy link
Owner

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).

@pzehner
Copy link
Contributor Author

pzehner commented Feb 11, 2021

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

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

@DaanVanVugt
Copy link
Owner

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 ;)

@pzehner
Copy link
Contributor Author

pzehner commented Mar 21, 2021

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.

@DaanVanVugt
Copy link
Owner

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.

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