Skip to content

Add support for building libcaffeine with CMake instead of FPM - #373

Merged
bonachea merged 11 commits into
BerkeleyLab:mainfrom
bonachea:cmake
Sep 22, 2026
Merged

bonachea merged 11 commits into
BerkeleyLab:mainfrom
bonachea:cmake

Conversation

@bonachea

Copy link
Copy Markdown
Member

This PR supercedes #271 in providing a CMake-driven build of the Caffeine library, without requiring FPM.
By sharing 90.6% of the existing FPM-driven build system (in particular the fetch/build/install of GASNet-EX, generation of pkg-config files and installation to prefix), the result is more maintainable and provides a uniform install experience for end users (who don't directly invoke cmake at all). It also supports the full generality of library conduit, codemode and threadmode, while minimizing the required CMake version.

This new feature is provided entirely by the first commit that only modifies install.sh. The remaining commits on this PR make other tangential improvements, add CI coverage and fix existing problems that arose during extensive manual testing.

Details:

  • New install.sh option --enable-cmake (aka --disable-fpm) activates the internal use of CMake instead of FPM to drive the build.
  • Homebrew support is extended to optionally install CMake instead FPM, as appropriate.
  • Still generates run-fpm.sh, which can optionally be used to invoke an FPM-driven build of the library or tests after running install.sh (e.g. if FPM is later installed)
  • Additional commits improve Caffiene's pkg-config output files (caffeine.pc), and using them expand app/Makefile to support PRIF-aware compilers; this enables make-driven build+execute of app/native-multi-image.F90 over Caffeine, without FPM. This is not necessary for end-use of the Caffeine library, but provides a convenient smoke test for the Caffeine library built by CMake (or FPM).

Limitations:

  • Does not support CMake-driven build of Caffeine's unit tests or examples. Caffeine developers should install FPM and use run-fpm.sh test (or leverage the FPM in GitHub Actions CI).
  • Currently only builds static libcaffeine*.a. This might be expanded in a future PR to include a shared library build.

Details:

* New `install.sh` option `--enable-cmake` (aka `--disable-fpm`) activates the
  internal use of CMake instead of FPM to drive the build.

* Homebrew support is extended to optionally install CMake instead FPM, as appropriate.

* Still generates `run-fpm.sh`, which can optionally be used to invoke an
  FPM-driven build of the library or tests after running `install.sh` (e.g. if
  FPM is later installed)

Limitations:

* Does not support CMake-driven build of Caffeine unit tests or examples.
  Caffeine developers should install FPM and use `run-fpm.sh test` (or leverage
  the FPM in GitHub Actions CI).
Some FFLAGS and CFLAGS should not be exported via our pkg-config file,
so separate those out into new *_lib variants and deploy appropriately.
When only FC is set, try to auto-detect appropriate CC.

Also make the auto-suffixing logic a bit more robust.
Ensure that Caffeine's C compilation (caffeine.c in particular)
use LFortran's copy of ISO_Fortran_binding.h
We were relying on GASNet's detection of CFLAGS and CPPFLAGS which
get injected into GASNET_CC and used to build GASNet, however they
don't appear in the GASNET_CFLAGS and GASNET_CPPFLAGS that we pass
to FPM or CMake.

install.sh now directly detects these upon invocations and appends
them to the CFLAGS used by FPM or CMake.
@bonachea
bonachea requested a review from rouson September 22, 2026 05:21
@bonachea
bonachea marked this pull request as ready for review September 22, 2026 05:21
@bonachea
bonachea requested a review from JDPailleux September 22, 2026 05:22

@rouson rouson left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks, @bonachea!

@JDPailleux JDPailleux left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Tested locally and it works well. Thanks !

@bonachea bonachea added this to the Caffeine 0.8.2 milestone Sep 22, 2026
@bonachea
bonachea merged commit 65ee8e4 into BerkeleyLab:main Sep 22, 2026
63 checks passed
@bonachea
bonachea deleted the cmake branch September 22, 2026 21:48
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.

3 participants