Skip to content

Define MAMICO_COMMIT_HASH at build time, not at configure time#128

Merged
rubenhorn merged 2 commits intomasterfrom
fix/MAMICO_COMMIT_HASH-WIP
Feb 16, 2026
Merged

Define MAMICO_COMMIT_HASH at build time, not at configure time#128
rubenhorn merged 2 commits intomasterfrom
fix/MAMICO_COMMIT_HASH-WIP

Conversation

@rubenhorn
Copy link
Copy Markdown
Contributor

@rubenhorn rubenhorn commented Feb 12, 2026

Avoids mismatch between version info and actual repo state. (Part of #125)

@rubenhorn rubenhorn requested a review from Thinkpiet February 12, 2026 14:46
@rubenhorn rubenhorn linked an issue Feb 12, 2026 that may be closed by this pull request
12 tasks
@rubenhorn rubenhorn removed a link to an issue Feb 12, 2026
12 tasks
@github-actions
Copy link
Copy Markdown

Sufficient test coverage for changed files.

@rubenhorn rubenhorn changed the title Define MAMICO_COMMIT_HASH as build time, not at configure time Define MAMICO_COMMIT_HASH at build time, not at configure time Feb 12, 2026
@Thinkpiet
Copy link
Copy Markdown
Member

Very good idea! 👍

However, this is a lot of code for something very simple. It looks fragile (might not work on system X for surprising reason Y) due to its complexity. Is there really no simpler way?

@rubenhorn
Copy link
Copy Markdown
Contributor Author

However, this is a lot of code for something very simple. It looks fragile (might not work on system X for surprising reason Y) due to its complexity. Is there really no simpler way?

This is actually the simplest way to do it.
The whole code generation is written in CMake, so it does not depend on any 3rd party interpreter (Bash, Python, PowerShell).
The logic for generating the version hash has been extracted from the main CMakeLists.txt, which makes this file easier to read in my opinion.
The target mamico just depends on an additional target and include path.

This should really work on any system:

  • Cannot execute cmake script? (Impossible, CMake is required.)
  • Git is not installed? Skip hash computation and just default to “unknown”.
  • Other OS/shell used? Pure CMake commands used. (Delegate responsibility.)

@Thinkpiet
Copy link
Copy Markdown
Member

OK! Please test it on at least 3-4 different machines - if it works then it is approved :-) (For me it works fine)

@rubenhorn
Copy link
Copy Markdown
Contributor Author

Tested on:

Device Architecture OS CMake CXX
My laptop Intel i7 x86 Ubuntu 24.04.4 LTS 3.28.3 Clang 18.1.8
Minicluster AMD AMD EPYC x86 Rocky Linux 8.5 3.20.2 GNU 8.5.0
Minicluster ARM FUJITSU A64FX Rocky Linux 8.5 3.20.2 GNU 8.5.0
HSUper Intel Xeon x86 Rocky Linux 8.10 3.27.9 GNU 13.2.0
Google Colab Intel Xeon x86 Ubuntu 22.04.5 LTS 3.31.10 GNU 11.4.0
My phone1 ARM Cortex aarch64 Android 16 4.2.3 Clang 21.1.8

This should be enough. 😉

Footnotes

  1. Using Termux. (Requires -DKokkos_ENABLE_LIBDL=OFF.)

@rubenhorn rubenhorn merged commit a8b42f2 into master Feb 16, 2026
1 check passed
@rubenhorn rubenhorn deleted the fix/MAMICO_COMMIT_HASH-WIP branch February 16, 2026 14:35
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