From 73b5d44b46be1efc46780642e0804ad077a9662e Mon Sep 17 00:00:00 2001 From: a dinosaur Date: Mon, 25 Mar 2024 15:36:07 +1100 Subject: [PATCH] get version info from project file --- CMakeLists.txt | 5 ++++- src/CMakeLists.txt | 4 ++++ src/config.h.in | 6 ++++++ src/tmx2gba.cpp | 5 ++--- 4 files changed, 16 insertions(+), 4 deletions(-) create mode 100644 src/config.h.in diff --git a/CMakeLists.txt b/CMakeLists.txt index 0200f0f..45b4849 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,8 @@ cmake_minimum_required(VERSION "3.15" FATAL_ERROR) -project(tmx2gba VERSION "0.3") +project(tmx2gba + VERSION "0.7" + DESCRIPTION "Simple CLI utility for converting Tiled (.tmx) maps to GBA-friendly charmaps." + HOMEPAGE_URL "https://github.com/ScrelliCopter/tmx2gba") # Options option(TMX2GBA_DKP_INSTALL "Install into DEVKITPRO prefix" OFF) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 83160bf..53aa6e5 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -6,6 +6,10 @@ add_executable(tmx2gba swriter.hpp swriter.cpp tmx2gba.cpp) +configure_file(config.h.in config.h @ONLY) +target_sources(tmx2gba PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/config.h) +target_include_directories(tmx2gba PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) + set_target_properties(tmx2gba PROPERTIES CXX_STANDARD 20) # Enable strong warnings diff --git a/src/config.h.in b/src/config.h.in new file mode 100644 index 0000000..d544867 --- /dev/null +++ b/src/config.h.in @@ -0,0 +1,6 @@ +#ifndef CONFIG_H +#define CONFIG_H + +#define TMX2GBA_VERSION "@PROJECT_VERSION@" + +#endif//CONFIG_H diff --git a/src/tmx2gba.cpp b/src/tmx2gba.cpp index 04381d9..a3952c4 100644 --- a/src/tmx2gba.cpp +++ b/src/tmx2gba.cpp @@ -5,13 +5,12 @@ #include "convert.hpp" #include "headerwriter.hpp" #include "swriter.hpp" +#include "config.h" #include #include #include -static const char* versionStr = "tmx2gba version 0.3, (c) 2015-2022 a dinosaur"; - struct Arguments { std::string inPath, outPath; @@ -148,7 +147,7 @@ int main(int argc, char** argv) } if (p.showVersion) { - std::cout << versionStr << std::endl; + std::cout << "tmx2gba version " << TMX2GBA_VERSION << ", (c) 2015-2024 a dinosaur" << std::endl; return 0; }