From 40fbd3b046a8da302a830ff00a0636642ea281d4 Mon Sep 17 00:00:00 2001 From: Yohan Boujon Date: Wed, 12 Mar 2025 10:44:47 +0000 Subject: [PATCH] Added poco (cmake) dependency. --- include/{libxml.h => libxml_meson.h} | 0 include/poco.h | 9 +++++++++ meson.build | 12 ++++++++++-- src/{libxml.cpp => libxml_meson.cpp} | 2 +- src/main.cpp | 19 ++++++++++++++++++- src/poco.cpp | 21 +++++++++++++++++++++ subprojects/poco.wrap | 7 +++++++ 7 files changed, 66 insertions(+), 4 deletions(-) rename include/{libxml.h => libxml_meson.h} (100%) create mode 100644 include/poco.h rename src/{libxml.cpp => libxml_meson.cpp} (97%) create mode 100644 src/poco.cpp create mode 100644 subprojects/poco.wrap diff --git a/include/libxml.h b/include/libxml_meson.h similarity index 100% rename from include/libxml.h rename to include/libxml_meson.h diff --git a/include/poco.h b/include/poco.h new file mode 100644 index 0000000..8c0c233 --- /dev/null +++ b/include/poco.h @@ -0,0 +1,9 @@ +#ifndef _HEADER_MESONTEST_POCO +#define _HEADER_MESONTEST_POCO + +#include + +std::string get_date_time(); +std::string format_poco_version(); + +#endif // _HEADER_MESONTEST__POCO diff --git a/meson.build b/meson.build index f858504..4b589ad 100644 --- a/meson.build +++ b/meson.build @@ -4,16 +4,24 @@ project('meson-test', 'cpp', ) # Libraries +# libxml2 libxml2_proj = subproject('libxml2', default_options: ['python=false', 'default_library=static']) libxml2_dep = libxml2_proj.get_variable('xml_dep') +# poco +cmake = import('cmake') +poco_proj = cmake.subproject('poco') +poco_dep_foundation = poco_proj.dependency(['Foundation']) +poco_dep_util = poco_proj.dependency(['Util']) + # Include directories incdir = include_directories('include') # Executable executable('mesontest', - 'src/libxml.cpp', + 'src/libxml_meson.cpp', + 'src/poco.cpp', 'src/main.cpp', - dependencies: libxml2_dep, + dependencies: [libxml2_dep, poco_dep_foundation, poco_dep_util], include_directories : incdir ) \ No newline at end of file diff --git a/src/libxml.cpp b/src/libxml_meson.cpp similarity index 97% rename from src/libxml.cpp rename to src/libxml_meson.cpp index 3ad31e8..d5695fd 100644 --- a/src/libxml.cpp +++ b/src/libxml_meson.cpp @@ -1,4 +1,4 @@ -#include "libxml.h" +#include "libxml_meson.h" #include #include diff --git a/src/main.cpp b/src/main.cpp index 88d1292..21e1610 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,11 +1,17 @@ +#include #include -#include "libxml.h" +#include "poco.h" +#include "libxml_meson.h" + +void info_poco(void); int main(void) { try { + std::cout << "Poco Test..." << std::endl; + info_poco(); std::cout << "Libxml2 Test..." << std::endl; info_libxml(); create_xml(); @@ -18,3 +24,14 @@ int main(void) } return 0; } + +void info_poco(void) +{ + std::cout << "\n"; + std::cout << "[TIME]:\t" << get_date_time() << "\n"; + std::cout << "[ OS]:\t" << Poco::Environment::osDisplayName() << " v" << Poco::Environment::osVersion() << "\n"; + std::cout << "[ARCH]:\t" << Poco::Environment::osArchitecture() << "\n"; + std::cout << "[POCO]:\tPoco C++ Library v" << format_poco_version() << "\n"; + std::cout << "\n" + << std::flush; +} diff --git a/src/poco.cpp b/src/poco.cpp new file mode 100644 index 0000000..8172252 --- /dev/null +++ b/src/poco.cpp @@ -0,0 +1,21 @@ +#include "poco.h" + +#include +#include +#include +#include +#include + +std::string get_date_time() +{ + Poco::LocalDateTime dateTime; + return Poco::DateTimeFormatter::format( + dateTime, + "%W %d %B %Y at %H:%M:%S"); +} + +std::string format_poco_version() +{ + uint32_t full_version = Poco::Environment::libraryVersion(); + return Poco::format("%u.%u.%u", (full_version >> 24), ((full_version >> 16) & 0xff), ((full_version >> 8) & 0xff)); +} \ No newline at end of file diff --git a/subprojects/poco.wrap b/subprojects/poco.wrap new file mode 100644 index 0000000..255b3dd --- /dev/null +++ b/subprojects/poco.wrap @@ -0,0 +1,7 @@ +[wrap-file] +directory = poco-poco-1.9.4-release +source_url = https://github.com/pocoproject/poco/archive/refs/tags/poco-1.9.4-release.tar.gz +source_filename = poco-1.9.4-release.tar.gz +source_hash = 367014cdbcfe9df8f1d746239902149d2398af9b49ba2c1aaaa88616fd538f61 +method = cmake +wrapdb_version = 1.9.4