Add versioning system

This commit is contained in:
Grayson Riffe 2025-01-23 16:57:55 -06:00
parent 73445af2e7
commit 581db91157
5 changed files with 14 additions and 4 deletions

View File

@ -7,3 +7,9 @@ set_property(TARGET NothinFancy PROPERTY CXX_STANDARD 20)
# Use precompiled header
target_precompile_headers(NothinFancy PUBLIC "src/pch.h")
target_include_directories(NothinFancy PUBLIC "src/")
# Generate version.h
find_package(Git)
execute_process(COMMAND ${GIT_EXECUTABLE} describe OUTPUT_VARIABLE NFVERSION OUTPUT_STRIP_TRAILING_WHITESPACE)
configure_file(src/version.h.in version.h)
target_include_directories(NothinFancy PUBLIC "${PROJECT_BINARY_DIR}/NothinFancy")

View File

@ -1,9 +1,11 @@
// NF startup
#include "pch.h"
#include "version.h"
namespace nf {
void test() {
std::cout << "NothinFancy\n";
void startEngine() {
std::cout << std::format("Nothin' Fancy {}\n", NFVERSION);
std::cin.get();
}
}

View File

@ -2,5 +2,5 @@
#pragma once
namespace nf {
void test();
void startEngine();
}

View File

@ -0,0 +1,2 @@
// Version configured header
#define NFVERSION "@NFVERSION@"

View File

@ -2,6 +2,6 @@
#include "nf.h"
int main(int argc, char* argv[]) {
nf::test();
nf::startEngine();
return 0;
}