From c7a3f7f46e4b47efd627c16da357d126e5ff7e02 Mon Sep 17 00:00:00 2001 From: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> Date: Sun, 23 Jan 2022 13:05:35 -0500 Subject: [PATCH] Add version argument --- CMakeLists.txt | 10 ++++++++-- sunshine/main.cpp | 12 +++++++++++- version.h.in | 10 ++++++++++ 3 files changed, 29 insertions(+), 3 deletions(-) create mode 100644 version.h.in diff --git a/CMakeLists.txt b/CMakeLists.txt index 0115a264..20751568 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.0) -project(Sunshine) +project(Sunshine VERSION 0.11.1) set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake) @@ -258,6 +258,9 @@ else() configure_file(sunshine.service.in sunshine.service @ONLY) endif() +configure_file(version.h.in version.h @ONLY) +include_directories(${CMAKE_CURRENT_BINARY_DIR}) + set(SUNSHINE_TARGET_FILES third-party/moonlight-common-c/reedsolomon/rs.c third-party/moonlight-common-c/reedsolomon/rs.h @@ -367,7 +370,10 @@ list(APPEND SUNSHINE_DEFINITIONS SUNSHINE_DEFAULT_DIR="${SUNSHINE_DEFAULT_DIR}") add_executable(sunshine ${SUNSHINE_TARGET_FILES}) target_link_libraries(sunshine ${SUNSHINE_EXTERNAL_LIBRARIES}) target_compile_definitions(sunshine PUBLIC ${SUNSHINE_DEFINITIONS}) -set_target_properties(sunshine PROPERTIES CXX_STANDARD 17) +set_target_properties(sunshine PROPERTIES CXX_STANDARD 17 + VERSION ${PROJECT_VERSION} + SOVERSION ${PROJECT_VERSION_MAJOR} + ) if(NOT DEFINED CMAKE_CUDA_STANDARD) set(CMAKE_CUDA_STANDARD 17) diff --git a/sunshine/main.cpp b/sunshine/main.cpp index b2bed72f..237b80ff 100644 --- a/sunshine/main.cpp +++ b/sunshine/main.cpp @@ -25,6 +25,7 @@ #include "thread_pool.h" #include "upnp.h" #include "video.h" +#include "version.h" #include "platform/common.h" extern "C" { @@ -63,6 +64,7 @@ void print_help(const char *name) { << std::endl << " --help | print help"sv << std::endl << " --creds username password | set user credentials for the Web manager" << std::endl + << " --version | print the version of sunshine" << std::endl << std::endl << " flags"sv << std::endl << " -0 | Read PIN from stdin"sv << std::endl @@ -80,6 +82,13 @@ int entry(const char *name, int argc, char *argv[]) { } } // namespace help +namespace version { +int entry(const char *name, int argc, char *argv[]) { + std::cout << PROJECT_NAME << " version: " << PROJECT_VER << std::endl; + return 0; +} +} // namespace version + void log_flush() { sink->flush(); } @@ -111,7 +120,8 @@ int entry(const char *name, int argc, char *argv[]) { std::map> cmd_to_func { { "creds"sv, gen_creds::entry }, - { "help"sv, help::entry } + { "help"sv, help::entry }, + { "version"sv, version::entry } }; int main(int argc, char *argv[]) { diff --git a/version.h.in b/version.h.in new file mode 100644 index 00000000..5deb996b --- /dev/null +++ b/version.h.in @@ -0,0 +1,10 @@ +#ifndef INCLUDE_GUARD +#define INCLUDE_GUARD + +#define PROJECT_NAME "@PROJECT_NAME@" +#define PROJECT_VER "@PROJECT_VERSION@" +#define PROJECT_VER_MAJOR "@PROJECT_VERSION_MAJOR@" +#define PROJECT_VER_MINOR "@PROJECT_VERSION_MINOR@" +#define PTOJECT_VER_PATCH "@PROJECT_VERSION_PATCH@" + +#endif // INCLUDE_GUARD