From ae91f57f932697756350906cc6e2ef4c5bc8ab27 Mon Sep 17 00:00:00 2001 From: bog Date: Fri, 10 Nov 2023 23:50:20 +0100 Subject: [PATCH] :tada: C++ meson project. --- .gitignore | 4 ++++ Makefile | 14 ++++++++++++++ meson.build | 31 +++++++++++++++++++++++++++++++ src/commons.hpp | 7 +++++++ src/conf.in.hpp | 7 +++++++ src/main.cpp | 8 ++++++++ 6 files changed, 71 insertions(+) create mode 100644 .gitignore create mode 100644 Makefile create mode 100644 meson.build create mode 100644 src/commons.hpp create mode 100644 src/conf.in.hpp create mode 100644 src/main.cpp diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..21b98b5 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +*\#* +*~* +.cache +build \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..2d4ab09 --- /dev/null +++ b/Makefile @@ -0,0 +1,14 @@ +.PHONY: build + +build: + meson setup build + meson compile -C build + +install: build + meson install -C build + +check: + @cppcheck --language=c++ --enable=all -q \ + --suppress=missingInclude \ + --suppress=missingIncludeSystem \ + src diff --git a/meson.build b/meson.build new file mode 100644 index 0000000..8457095 --- /dev/null +++ b/meson.build @@ -0,0 +1,31 @@ +project('bloody-gun', + 'cpp', + version: '0.0.0', + default_options: [ + 'warning_level=3', + 'cpp_std=c++17' + ]) + +datadir = get_option('prefix') / get_option('datadir') / 'bloody_gun' + +conf = configuration_data() +conf.set('version', meson.project_version()) +conf.set('datadir', datadir) + +configure_file( + input: 'src/conf.in.hpp', + output: 'conf.hpp', + configuration: conf +) + +executable( + 'bloody-gun', + sources: [ + 'src/main.cpp', + ], + dependencies: [ + ], + install: true +) + +install_subdir('assets', install_dir: datadir) diff --git a/src/commons.hpp b/src/commons.hpp new file mode 100644 index 0000000..882e21f --- /dev/null +++ b/src/commons.hpp @@ -0,0 +1,7 @@ +#ifndef bg_COMMONS_HPP +#define bg_COMMONS_HPP + +#include +#include "conf.hpp" + +#endif diff --git a/src/conf.in.hpp b/src/conf.in.hpp new file mode 100644 index 0000000..4843e10 --- /dev/null +++ b/src/conf.in.hpp @@ -0,0 +1,7 @@ +#ifndef bg_CONF_HPP +#define bg_CONF_HPP + +#define BG_VERSION std::string("@version@") +#define BG_DATADIR std::filesystem::path("@datadir@") + +#endif diff --git a/src/main.cpp b/src/main.cpp new file mode 100644 index 0000000..1ab284f --- /dev/null +++ b/src/main.cpp @@ -0,0 +1,8 @@ +#include +#include "commons.hpp" + +int main(int, char**) +{ + std::cout << "Bloody Gun v" << BG_VERSION << std::endl; + return 0; +}