Add version argument

This commit is contained in:
ReenigneArcher 2022-01-23 13:05:35 -05:00
parent e5239583b5
commit c7a3f7f46e
3 changed files with 29 additions and 3 deletions

View File

@ -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)

View File

@ -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<std::string_view, std::function<int(const char *name, int argc, char **argv)>> 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[]) {

10
version.h.in Normal file
View File

@ -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