Skip to content

Export an installed CMake package with consistent ABI metadata - #84

Open
dimpase wants to merge 7 commits into
Macaulay2:masterfrom
dimpase:install-cmake-package
Open

dimpase wants to merge 7 commits into
Macaulay2:masterfrom
dimpase:install-cmake-package

Conversation

@dimpase

@dimpase dimpase commented Sep 18, 2026 •

Copy link
Copy Markdown

The current CMake build has SONAMEs, GNUInstallDirs, TBB selection, and pkg-config installation, but lacks a consumable CMake package. It also reconstructs mathic and memtailor as static imported libraries without their usage requirements. The CMake-generated pkg-config file omits MATHICGB_DEBUG, and a direct configuration-dependent export would select the consumer's Debug ABI instead of the installed library's ABI.

Install mathicgbConfig.cmake, version metadata, and mathicgb::mathicgb, with C++17 and transitive dependencies. Prefer dependency CMake configs, then pkg-config metadata, and retain header/library discovery as a fallback for older installations such as the current Homebrew bottles. Preserve the current TBB ON/OFF/auto behavior and SONAME setup.

Export the installed library's Debug setting through both metadata formats, retain the TBB/no-TBB usage requirements, and explicitly install static archives and the public header. Install documentation using CMAKE_INSTALL_DOCDIR instead of the nonstandard licenses/mathicgb directory, allowing Gentoo to select /usr/share/doc/${PF}. Enable root-level CTest. Extend the existing Linux/macOS, Debug/Release, TBB-on/off CI matrix with shared/static installation checks, pkg-config flag checks, and separate Release consumers of relocated installations. Add the templates and fixtures to Autotools distributions and document usage. CMake 3.18 is required for aliases of non-global imported dependency targets.

macOS CMake CI uses the existing Homebrew memtailor and mathic packages directly. The fallback allows this even when their bottles lack CMake config and pkg-config metadata. Installed pkg-config flag checks run when the dependencies provide .pc files; the installed CMake consumer is tested on both platforms.

Local Gentoo validation, at low priority with two compilation jobs:

  • All 248 tests passed for Release/shared with TBB and Debug/static without TBB.
  • Relocated installed CMake consumers and pkg-config consumers passed, including Release consumers of Debug libraries.
  • Dependency CMake configs were exercised in Release; pkg-config discovery of both dependencies was forced in Debug.
  • make dist succeeded with a nonstandard mathic prefix and includes the new CMake config and consumer fixtures.
  • Workflow lint and diff checks passed. Before the documentation-path follow-up, the full hosted Linux/macOS CI matrix passed.

The documentation-path follow-up was checked by applying the updated Gentoo patch to the release and staging an installation: documentation is under /usr/share/doc/mathicgb-1.4-r2, with no /usr/licenses. Overlay QA passed.

The discovery fallback was tested with both dependency CMake configs and pkg-config disabled. Mathicgb and mgb built against installed headers and libraries; a staged installed CMake consumer compiled, linked, and passed its runtime test.

Related work: Macaulay2/memtailor#23 and Macaulay2/mathic#29. This adapts the Gentoo packaging work to current mathicgb master without reverting its newer CMake improvements. External mathicgb selection in M2 remains separate.

dimpase and others added 3 commits September 17, 2026 23:59
Propagate dependency usage requirements through CMake configs or pkg-config, export the installed Debug and TBB settings, and test relocated shared/static consumers in CI. Retain the existing TBB auto detection and SONAME setup.

Co-authored-by: Codex <noreply@openai.com>
Build tagged Autotools dependencies in a temporary prefix because current Homebrew CMake bottles omit package metadata.

Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Codex <noreply@openai.com>

@dimpase dimpase left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

OK, looks good. Can be simplified once memtailor and mathic cmake changes are propagated into new releases (and into upstreams)

@d-torrance - over to you

Comment thread cmake/FindMemtailor.cmake
)
find_library(MEMTAILOR_LIBRARIES NAMES memtailor
PATHS ${LIB_INSTALL_DIR} ${CMAKE_INSTALL_PREFIX}/lib
)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think we should keep these as a fallback. In particular, this would mean we could keep using the homebrew packages in CI instead of having to build them from source.

Same comment for mathic.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

as we maintain the Homebrew taps in question, we can just update them, then everything will be OK. Anyhow, you merged my mathic PR already...

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

anyhow, fixed by afacdb8

please see Macaulay2/mathic#30 for the corresponding fix for mathic.

Signed-off-by: Dima Pasechnik <dima@pasechnik.info>
Signed-off-by: Dima Pasechnik <dima@pasechnik.info>
Signed-off-by: Dima Pasechnik <dima@pasechnik.info>
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