Skip to content

Modernize CMake package config and install layout#204

Merged
caitlinross merged 8 commits into
ROSS-org:masterfrom
caitlinross:cmake-improvements
Jun 2, 2026
Merged

Modernize CMake package config and install layout#204
caitlinross merged 8 commits into
ROSS-org:masterfrom
caitlinross:cmake-improvements

Conversation

@caitlinross
Copy link
Copy Markdown
Member

@caitlinross caitlinross commented Jun 2, 2026

Makes find_package(ROSS) a self-contained modern CMake package. Out-of-tree consumers can write:

find_package(ROSS REQUIRED)
target_link_libraries(myapp PRIVATE ROSS::ROSS)

and get include dirs, the MPI dependency (re-resolved on the consumer's machine, not baked in), and link libraries propagated transparently. Master's hand-written 3-line ROSSConfig.cmake had no version file, no find_dependency(MPI), no namespaced target, and lived at a non-canonical location requiring -DROSS_DIR hints to find.

What changed:

  • New canonical config at <prefix>/lib/cmake/ROSS/ with proper version file, MPI dependency re-resolution, and ROSS::ROSS namespaced target. CMake discovers it from CMAKE_PREFIX_PATH automatically — no hints needed.
  • Installed headers moved from flat <prefix>/include/ to <prefix>/include/ross/ to stop polluting the consumer include namespace with common names (config.h, buddy.h, lz4.h, io.h).
  • Core target hygiene: dropped the nested PROJECT(ROSS C) in core/, attached public include dirs via target_include_directories(... BUILD_INTERFACE / INSTALL_INTERFACE), moved CMake helper modules to top-level cmake/.
  • All install destinations honor GNUInstallDirs: the library, CMake
    config files, pkg-config file, headers, phold binaries, and the
    install-RPATH all derive from ${CMAKE_INSTALL_LIBDIR} /
    ${CMAKE_INSTALL_INCLUDEDIR} / ${CMAKE_INSTALL_BINDIR}. No effect on
    macOS or standard Linux layouts, but installs cleanly on Debian
    multiarch (lib/x86_64-linux-gnu) and RHEL/Fedora multilib (lib64).
  • models/phold updated to install all 6 phold variants (master only installed phold) and dropped a dead BGPM branch.

Back-compat:

  • ross.pc keeps working for pkg-config consumers. CODES rebuilds cleanly against the new install with no source changes .
  • Library filename libROSS.{a,so} unchanged, cached pkgcfg_lib_ROSS_ROSS entries in consumer build dirs stay valid.
  • Legacy find_package(ROSS) + -DROSS_DIR=<prefix>/lib callers keep working via a tiny shim at the old location; emits a deprecation warning and delegates to the canonical config (preserves the ROSS_INCLUDE_DIRS variable master set).
  • Legacy target_link_libraries(... ROSS) callers keep working via a back-compat ALIAS in the new ROSSConfig.cmake.

Checklist

  • Builds cleanly with -Wall and -Wextra
  • CI is green
  • Added a changelog fragment under Documentation/dev/, unless the change is invisible to anyone outside the PR (test refactors, internal renames, comment-only tweaks)
  • Confirmed nothing in CODES breaks. CI has a minimal CODES build that should be green before merging.
  • For new features: blog post on the ROSS website, with link in this PR

@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 2, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 47.86%. Comparing base (427ed81) to head (961dd65).

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #204   +/-   ##
=======================================
  Coverage   47.86%   47.86%           
=======================================
  Files          37       37           
  Lines        4745     4745           
  Branches      857      857           
=======================================
  Hits         2271     2271           
  Misses       2469     2469           
  Partials        5        5           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

- No nested project() call
- use BUILD_INTERFACE and INSTALL_INTERFACE in
  target_include_directories call
- Improve/simplify phold's cmake as well as drop BPGM since BG/Q doesn't exist
  anymore :)
The previous hand-written ROSSConfig.cmake had no version file, no
find_dependency(MPI), no namespaced target, and lived at <prefix>/lib/
where consumers needed a -DROSS_DIR hint to discover it. Out-of-tree
projects had to re-run find_package(MPI) themselves and link the bare
ROSS target.

After this change consumers can write:

    find_package(ROSS REQUIRED)
    target_link_libraries(myapp PRIVATE ROSS::ROSS)

and get include dirs, the MPI dependency, and link libs propagated
transparently. The config installs at the canonical
<prefix>/lib/cmake/ROSS/ which CMake discovers from CMAKE_PREFIX_PATH
without any explicit hint, and a generated ROSSConfigVersion.cmake
makes version-constrained discovery (find_package(ROSS 8.0)) work.

A back-compat ALIAS keeps legacy target_link_libraries(... ROSS) call
sites working without modification, and a tiny shim at the old
<prefix>/lib/ROSSConfig.cmake location preserves -DROSS_DIR=<prefix>/lib
callers, emitting a deprecation warning and delegating to the
canonical config, while also setting the ROSS_INCLUDE_DIRS variable
master used to export.
Top-level is the place for project-level build infrastructure, not among
core C files.
Previously every *.h  was installed flat into <prefix>/include/, polluting the
consumer's include namespace with common names (config.h, buddy.h,
lz4.h, io.h). Moving them under <prefix>/include/ross/ contains the
namespace; the exported target's INSTALL_INTERFACE still resolves #include <ross.h>
transparently for consumers.
Installed headers were moved under <prefix>/include/ross/, but
ross.pc.in still pointed Cflags at the flat <prefix>/include/ so any
pkg-config consumer (CODES today) would emit the wrong -I and miss
the headers. Rewriting includedir to point at the new location keeps
the pkg-config flow transparent for downstream consumers; no source
changes needed on their side.

Install destination uses ${CMAKE_INSTALL_LIBDIR}/pkgconfig so
multilib (lib64) and Spack-style overrides work.
Hoist include(GNUInstallDirs) to the top-level CMakeLists.txt so the
install-RPATH stanza can resolve ${CMAKE_INSTALL_LIBDIR} instead of
forcing <prefix>/lib. The phold install rule likewise switches from
literal "bin" to ${CMAKE_INSTALL_BINDIR}, completing the sweep that
earlier commits had started in core/.

On macOS and standard Linux layouts the resulting paths are unchanged;
the difference shows up on Debian multiarch (lib/x86_64-linux-gnu) and
RHEL/Fedora multilib (lib64), where installed binaries now find
libROSS through the correct directory.
@caitlinross caitlinross force-pushed the cmake-improvements branch from 8f6f9bb to 961dd65 Compare June 2, 2026 22:47
@caitlinross caitlinross changed the title Draft: Modernize CMake package config and install layout Modernize CMake package config and install layout Jun 2, 2026
@caitlinross caitlinross merged commit c332578 into ROSS-org:master Jun 2, 2026
5 checks passed
@caitlinross caitlinross deleted the cmake-improvements branch June 2, 2026 22:53
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.

1 participant