Skip to content

Commit

Permalink
Add ALPAQA_COMMIT_HASH variable
Browse files Browse the repository at this point in the history
  • Loading branch information
tttapa committed Nov 14, 2023
1 parent 7fb13d4 commit 00959c0
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
11 changes: 7 additions & 4 deletions cmake/alpaqa-version.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,14 @@
#define ALPAQA_VERSION "@PROJECT_VERSION@"
#define ALPAQA_VERSION_FULL "@PROJECT_VERSION@@PY_VERSION_SUFFIX@"
#define ALPAQA_BUILD_TIME alpaqa_build_time
#define ALPAQA_COMMIT_HASH alpaqa_commit_hash

#include <alpaqa/export.h>
#ifdef __cplusplus
extern "C"
#else
extern
extern "C" {
#endif
extern ALPAQA_EXPORT const char *const alpaqa_build_time;
extern ALPAQA_EXPORT const char *const alpaqa_commit_hash;
#ifdef __cplusplus
}
#endif
ALPAQA_EXPORT const char *const alpaqa_build_time;
6 changes: 6 additions & 0 deletions src/cmake/BuildTime.cmake
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
string(TIMESTAMP ALPAQA_BUILD_TIME UTC)
execute_process(
COMMAND git log -1 --format=%H
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
OUTPUT_VARIABLE ALPAQA_COMMIT_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_QUIET)
configure_file(${CMAKE_CURRENT_LIST_DIR}/alpaqa-build-time.cpp.in
alpaqa-build-time.cpp @ONLY)
3 changes: 2 additions & 1 deletion src/cmake/alpaqa-build-time.cpp.in
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
#include <alpaqa-version.h>
const char *const alpaqa_build_time = "@ALPAQA_BUILD_TIME@";
const char *const alpaqa_build_time = "@ALPAQA_BUILD_TIME@";
const char *const alpaqa_commit_hash = "@ALPAQA_COMMIT_HASH@";

0 comments on commit 00959c0

Please sign in to comment.