diff options
author | Thomas White <taw@physics.org> | 2020-07-29 15:44:02 +0200 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2020-07-29 18:53:45 +0200 |
commit | 42898f7d59e215434fa2aead84223f64b30fcee8 (patch) | |
tree | 5cdfb4c0c279c766efcbbc6c455ee58a5c8741f1 /libcrystfel | |
parent | 6105a7797b96418d940ced7d88c6cf2b308b9711 (diff) |
New way of injecting version information
Also, this fixes some incorrect headers and adds --version flags to
programs which didn't yet have them.
Diffstat (limited to 'libcrystfel')
-rw-r--r-- | libcrystfel/CMakeLists.txt | 3 | ||||
-rw-r--r-- | libcrystfel/src/libcrystfel-version.c.cmake.in | 4 | ||||
-rw-r--r-- | libcrystfel/src/libcrystfel-version.h | 2 | ||||
-rw-r--r-- | libcrystfel/src/reflist-utils.c | 6 | ||||
-rw-r--r-- | libcrystfel/src/stream.c | 5 |
5 files changed, 16 insertions, 4 deletions
diff --git a/libcrystfel/CMakeLists.txt b/libcrystfel/CMakeLists.txt index 5374ae00..79534f6b 100644 --- a/libcrystfel/CMakeLists.txt +++ b/libcrystfel/CMakeLists.txt @@ -10,6 +10,8 @@ find_package(BISON REQUIRED) find_package(Doxygen) pkg_search_module(FFTW fftw3) +configure_file(src/libcrystfel-version.c.cmake.in libcrystfel-version.c) + set(HAVE_CURSES ${CURSES_FOUND}) set(HAVE_FFTW ${FFTW_FOUND}) set(HAVE_XGANDALF ${XGANDALF_FOUND}) @@ -120,6 +122,7 @@ endif (DOXYGEN_FOUND) add_library(${PROJECT_NAME} SHARED ${LIBCRYSTFEL_SOURCES} + ${CMAKE_CURRENT_BINARY_DIR}/libcrystfel-version.c ${LIBCRYSTFEL_FFTW_SOURCES} ${LIBCRYSTFEL_HEADERS}) diff --git a/libcrystfel/src/libcrystfel-version.c.cmake.in b/libcrystfel/src/libcrystfel-version.c.cmake.in new file mode 100644 index 00000000..513d7871 --- /dev/null +++ b/libcrystfel/src/libcrystfel-version.c.cmake.in @@ -0,0 +1,4 @@ +const char *libcrystfel_version_string() +{ + return "${CRYSTFEL_VERSION}"; +} diff --git a/libcrystfel/src/libcrystfel-version.h b/libcrystfel/src/libcrystfel-version.h new file mode 100644 index 00000000..7e3ac4f7 --- /dev/null +++ b/libcrystfel/src/libcrystfel-version.h @@ -0,0 +1,2 @@ +extern const char *libcrystfel_version_string(void); +extern const char *libcrystfel_licence_string(void); diff --git a/libcrystfel/src/reflist-utils.c b/libcrystfel/src/reflist-utils.c index 7a41f335..467a3007 100644 --- a/libcrystfel/src/reflist-utils.c +++ b/libcrystfel/src/reflist-utils.c @@ -41,6 +41,7 @@ #include "utils.h" #include "reflist-utils.h" #include "symmetry.h" +#include "libcrystfel-version.h" /** \file reflist-utils.h @@ -698,9 +699,8 @@ void reflist_add_command_and_version(RefList *list, int argc, char *argv[]) char *tmp; char vers[128]; - vers[0] = '\0'; - strcat(vers, "Generated by CrystFEL "); - strncat(vers, CRYSTFEL_VERSIONSTRING, 100); + snprintf(vers, 128, "Generated by CrystFEL %s", + libcrystfel_version_string()); reflist_add_notes(list, vers); tmp = full_command_line(argc, argv); diff --git a/libcrystfel/src/stream.c b/libcrystfel/src/stream.c index 02abd549..6242071b 100644 --- a/libcrystfel/src/stream.c +++ b/libcrystfel/src/stream.c @@ -53,6 +53,8 @@ #include "reflist-utils.h" #include "datatemplate.h" #include "detgeom.h" +#include "libcrystfel-version.h" + /** \file stream.h */ @@ -1319,7 +1321,8 @@ Stream *stream_open_for_write(const char *filename) fprintf(st->fh, "CrystFEL stream format %i.%i\n", st->major_version, st->minor_version); - fprintf(st->fh, "Generated by CrystFEL "CRYSTFEL_VERSIONSTRING"\n"); + fprintf(st->fh, "Generated by CrystFEL %s\n", + libcrystfel_version_string()); fflush(st->fh); return st; |