diff --git a/CMakeLists.txt b/CMakeLists.txt index f43819bad7d5b79976810fe0c33ebd6c72258ba5..fa71b8f60d4c301938ecd5d71252d8191c1d9740 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,6 +6,13 @@ set (CMAKE_CXX_STANDARD 20) option(PROFILE_ENABLED "instrument for gprof" OFF) +set(CMAKE_PROJECT_VERSION_MAJOR 2) +set(CMAKE_PROJECT_VERSION_MINOR 0) +set(CMAKE_PROJECT_VERSION_PATCH 0) +add_compile_definitions(VERSION_MAJOR=${CMAKE_PROJECT_VERSION_MAJOR}) +add_compile_definitions(VERSION_MINOR=${CMAKE_PROJECT_VERSION_MINOR}) +add_compile_definitions(VERSION_PATCH=${CMAKE_PROJECT_VERSION_PATCH}) + find_package(Doxygen) set(SRC_FILES @@ -69,6 +76,16 @@ if(WIN32) ) set(COMMON_LINK_FLAGS "-flto -dl") + + if(NOT CMAKE_HOST_SYSTEM_NAME MATCHES "Windows") + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/package-win.sh ${CMAKE_CURRENT_BINARY_DIR}/package.sh @ONLY) + add_custom_target(package + COMMAND ${CMAKE_CURRENT_BINARY_DIR}/package.sh + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMENT "Createing release archive" + VERBATIM) + endif() + else() message("Building on UNIX") diff --git a/eisgenerator/eistype.h b/eisgenerator/eistype.h index 970b4e157bf39acb37e5d86b168c3790e395cdad..c71f87dba29be48395ea669f41abf1695ff66170 100644 --- a/eisgenerator/eistype.h +++ b/eisgenerator/eistype.h @@ -452,6 +452,16 @@ std::pair<std::valarray<fvalue>, std::valarray<fvalue>> eisToValarrays(const std /** @} */ + +struct VersionFixed +{ + int major; + int minor; + int patch; +}; + +const VersionFixed& getVersion(); + } std::ostream &operator<<(std::ostream &s, eis::DataPoint const& dp); @@ -460,3 +470,4 @@ std::ostream &operator<<(std::ostream &s, eis::Range const& range); std::ostream &operator<<(std::ostream &s, eis::EisSpectra const& spectra); + diff --git a/eistype.cpp b/eistype.cpp index 349688b63014da58b4644e841fdd6e5e87c578d0..6061d7943a8c1bd8cfef8339de01b76d2bcffc70 100644 --- a/eistype.cpp +++ b/eistype.cpp @@ -394,6 +394,13 @@ EisSpectra EisSpectra::loadFromDisk(const std::filesystem::path& path) } } +static VersionFixed version = {VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH}; + +const VersionFixed& getVersion() +{ + return version; +} + std::ostream &operator<<(std::ostream &s, EisSpectra const& spectra) { spectra.saveToStream(s); diff --git a/options.h b/options.h index ea8b208044ea9a7fb4e422f88ab76b08233a48f4..b477d435c2f4c3476b0d36bf7af43a6be4d6bcdb 100644 --- a/options.h +++ b/options.h @@ -20,13 +20,13 @@ #pragma once #include <string> -#include <vector> #include <argp.h> -#include "model.h" #include "log.h" -#include "strops.h" -const char *argp_program_version = "eisgenerator-1.0"; +#define xstr(s) str(s) +#define str(s) #s + +const char *argp_program_version = "eisgenerator-" xstr(VERSION_MAJOR) "." xstr(VERSION_MINOR) "." xstr(VERSION_PATCH); const char *argp_program_bug_address = "<carl@uvos.xyz>"; static char doc[] = "Application that generates EIS spectra from model strings"; static char args_doc[] = ""; diff --git a/package-win.sh b/package-win.sh new file mode 100755 index 0000000000000000000000000000000000000000..47bcc77ee4d5547ae931bb5e7e26eb0e3fe01d4b --- /dev/null +++ b/package-win.sh @@ -0,0 +1,19 @@ +#!/bin/bash -e + +PORJECT_NAME=@PROJECT_NAME@ +ONNXNAME="@ONNX_NAME@" +VERSION="@CMAKE_PROJECT_VERSION_MAJOR@.@CMAKE_PROJECT_VERSION_MINOR@.@CMAKE_PROJECT_VERSION_PATCH@" +BINARYDIR="@CMAKE_CURRENT_BINARY_DIR@" +SRCDIR="@CMAKE_CURRENT_SOURCE_DIR@" +RELDIRECTORY="$BINARYDIR/packaged/$VERSION/release" + +rm $BINARYDIR/packaged/$PORJECT_NAME-$VERSION.zip || true +cd $BINARYDIR +install -d $RELDIRECTORY +cp libeisgenerator.dll $RELDIRECTORY +cp libeisgenerator.dll.a $RELDIRECTORY +cp libeisgenerator_static.a $RELDIRECTORY +cp eisgenerator_export.exe $RELDIRECTORY +cp eisgenerator_test.exe $RELDIRECTORY +cd $RELDIRECTORY/.. +zip -r $BINARYDIR/packaged/$PORJECT_NAME-$VERSION.zip release