diff --git a/CMakeLists.txt b/CMakeLists.txt index a53b0a8b4ab1236e592206b087716194cf2bfa5e..9d10cd8d922da61f3cce96c852d3e3c5a05a405e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,13 @@ PROJECT(Corpus2Library) + +set(corpus2_ver_major "1") +set(corpus2_ver_minor "0") +set(corpus2_ver_patch "12") + +add_definitions(-DLIBCORPUS2_VERSION_MAJOR=${corpus2_ver_major}) +add_definitions(-DLIBCORPUS2_VERSION_MINOR=${corpus2_ver_minor}) +add_definitions(-DLIBCORPUS2_VERSION_PATCH=${corpus2_ver_patch}) + cmake_minimum_required(VERSION 2.8.0) # use some of our own Find* scripts diff --git a/corpus2tools/tagset-tool.cpp b/corpus2tools/tagset-tool.cpp index f20389e9749ffc5f427ae660721da8e1441bfa7e..7968b788092b09684005fc6ab5346f98e1e2d970 100644 --- a/corpus2tools/tagset-tool.cpp +++ b/corpus2tools/tagset-tool.cpp @@ -223,6 +223,7 @@ int main(int argc, char** argv) ("sort,s", value(&sort)->zero_tokens(), "Sort parsed tags") ("help,h", "Show help") + ("version", "print version string") ; boost::program_options::variables_map vm; boost::program_options::positional_options_description p; @@ -244,6 +245,10 @@ int main(int argc, char** argv) std::cout << Corpus2::available_tagsets() << "\n"; return 1; } + if (vm.count("version")) { + std::cout << "tagset-tool (libcorpus2) " << Corpus2::version_string() << "\n"; + return 0; + } Corpus2::Path::Instance().set_verbose(!quiet); diff --git a/libcorpus2/CMakeLists.txt b/libcorpus2/CMakeLists.txt index b02207e9f34658d1d410e1411ce54179ad70efbd..4c2be81282c0caa11820b360d45ce41ca479e024 100644 --- a/libcorpus2/CMakeLists.txt +++ b/libcorpus2/CMakeLists.txt @@ -1,11 +1,6 @@ ########## libcorpus2 ############### PROJECT(corpus2) -set(corpus2_ver_major "1") -set(corpus2_ver_minor "0") -set(corpus2_ver_patch "12") - - if(NOT LIBCORPUS2_SRC_DATA_DIR) message(FATAL_ERROR "There is no data for libcorpus2") endif(NOT LIBCORPUS2_SRC_DATA_DIR) diff --git a/libcorpus2/util/settings.cpp b/libcorpus2/util/settings.cpp index bfa5c33042c8dba4e51b28f1502fa5c7b70fe706..c6c73093e6ff76631bb6cb985ff3d359723a9861 100644 --- a/libcorpus2/util/settings.cpp +++ b/libcorpus2/util/settings.cpp @@ -24,8 +24,17 @@ or FITNESS FOR A PARTICULAR PURPOSE. #define LIBCORPUS2_PATH_SEPARATOR ":" #endif +#include <sstream> + namespace Corpus2 { +const std::string version_string() +{ + std::stringstream version; + version << version_major << "." << version_minor << "." << version_patch; + return version.str(); +} + Corpus2PathSearcher::Corpus2PathSearcher() : PwrNlp::PathSearcher<FileNotFound>(LIBCORPUS2_PATH_SEPARATOR) { diff --git a/libcorpus2/util/settings.h b/libcorpus2/util/settings.h index 1dd57722b0e53d07c9d81bacd59b3360a2d4780c..e952a70a7f2cb1a9cff2362a6cb154cbbc10427f 100644 --- a/libcorpus2/util/settings.h +++ b/libcorpus2/util/settings.h @@ -23,6 +23,12 @@ or FITNESS FOR A PARTICULAR PURPOSE. namespace Corpus2 { +const int version_major = (LIBCORPUS2_VERSION_MAJOR); +const int version_minor = (LIBCORPUS2_VERSION_MINOR); +const int version_patch = (LIBCORPUS2_VERSION_PATCH); + +const std::string version_string(); + class Corpus2PathSearcher : public PwrNlp::PathSearcher<FileNotFound> { public: