diff --git a/.gitignore b/.gitignore index 42c2f96e..58dd126c 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ TODO.org bin build compile_commands.json +.vscode/settings.json \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 5773c560..4779f8c2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,11 +6,32 @@ endif() project(SignalEstimator) +set(PROJECT_VERSION 0.1.0) + +# Compilation information option(BUILD_GUI "build Qt GUI" ON) option(ENABLE_SANITIZERS "enable sanitizers" OFF) option(ENABLE_WERROR "enable -Werror" OFF) +execute_process( + COMMAND ${CMAKE_C_COMPILER} -dumpmachine + OUTPUT_VARIABLE GCC_TRIPLET + OUTPUT_STRIP_TRAILING_WHITESPACE +) + set(TOOLCHAIN_PREFIX "" CACHE STRING "target host triplet, e.g. aarch64-linux-gnu") + +string(TIMESTAMP CURRENT_DATE "%b %d %Y") +string(TIMESTAMP CURRENT_TIME "%H:%M:%S") + +add_compile_definitions( + PROJECT_VERSION="${PROJECT_VERSION}" + TARGET_TRIPLET="${GCC_TRIPLET}" + BUILD_DATE="${CURRENT_DATE}" + BUILD_TIME="${CURRENT_TIME}" +) + + include("cmake/SetupToolchain.cmake") include("cmake/ThirdParty.cmake") diff --git a/src/cli/Main.cpp b/src/cli/Main.cpp index c2e1dd08..15624eba 100644 --- a/src/cli/Main.cpp +++ b/src/cli/Main.cpp @@ -15,6 +15,7 @@ using namespace signal_estimator; + int main(int argc, char** argv) { Config config; std::string mode = "latency_corr"; @@ -23,11 +24,15 @@ int main(int argc, char** argv) { output_format = PcmFormat().to_string(); int verbosity = 0; bool list_supported = false; + bool show_version = false; CLI::App app { "Measure characteristics of a looped back signal", "signal-estimator" }; - app.formatter(std::make_shared()); + app.formatter(std::make_shared()); + + app.add_flag( + "-V,--version",show_version, "Show software version"); app.add_flag( "-L,--list-supported", list_supported, "Print supported features and exit"); @@ -189,6 +194,11 @@ int main(int argc, char** argv) { return EXIT_SUCCESS; } + if(show_version){ + print_compilation_information(std::cerr); + return EXIT_SUCCESS; + } + // parse mode const std::map mode_map { { "latency_corr", Mode::LatencyCorr }, diff --git a/src/cli/Print.cpp b/src/cli/Print.cpp index ba627f0b..52a4b52c 100644 --- a/src/cli/Print.cpp +++ b/src/cli/Print.cpp @@ -35,5 +35,8 @@ void print_supported_formats(std::ostream& out) { } } } - -} // namespace signal_estimator +void print_compilation_information(std::ostream& out) { + out<<"Signal Estimator "<< PROJECT_VERSION << "\n"; + out << "Built for " << TARGET_TRIPLET <<" at "<