[cpp] add a version header+functions
this way, it is possible to get (either at build time and at runtime)
the version of the current poppler-cpp library
poppler-config.h is generated by the build system (autotools or cmake)
with the correct version information
diff --git a/configure.ac b/configure.ac
index a7d61f7..70bac6c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -547,6 +547,7 @@
AC_SUBST([POPPLER_MAJOR_VERSION],[poppler_version_major])
AC_SUBST([POPPLER_MINOR_VERSION],[poppler_version_minor])
AC_SUBST([POPPLER_MICRO_VERSION],[poppler_version_micro])
+AC_SUBST([POPPLER_VERSION],[poppler_version])
AC_OUTPUT([
Makefile
@@ -566,6 +567,7 @@
qt4/tests/Makefile
qt4/demos/Makefile
cpp/Makefile
+cpp/poppler-version.h
poppler.pc
poppler-cairo.pc
poppler-splash.pc
diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt
index 42fbca2..3f8e9d9 100644
--- a/cpp/CMakeLists.txt
+++ b/cpp/CMakeLists.txt
@@ -1,7 +1,10 @@
include_directories(
+ ${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
)
+configure_file(poppler-version.h.in ${CMAKE_CURRENT_BINARY_DIR}/poppler-version.h @ONLY)
+
set(poppler_cpp_SRCS
poppler-document.cpp
poppler-embedded-file.cpp
@@ -11,6 +14,7 @@
poppler-page-transition.cpp
poppler-private.cpp
poppler-toc.cpp
+ poppler-version.cpp
)
add_library(poppler-cpp SHARED ${poppler_cpp_SRCS})
@@ -30,5 +34,6 @@
poppler-page-transition.h
poppler-rectangle.h
poppler-toc.h
+ ${CMAKE_CURRENT_BINARY_DIR}/poppler-version.h
DESTINATION include/poppler/cpp)
diff --git a/cpp/Makefile.am b/cpp/Makefile.am
index 58b8dd1..b6c2d8e 100644
--- a/cpp/Makefile.am
+++ b/cpp/Makefile.am
@@ -13,7 +13,8 @@
poppler-page.h \
poppler-page-transition.h \
poppler-rectangle.h \
- poppler-toc.h
+ poppler-toc.h \
+ poppler-version.h
lib_LTLIBRARIES = libpoppler-cpp.la
libpoppler_cpp_la_SOURCES = \
@@ -24,7 +25,8 @@
poppler-page.cpp \
poppler-page-transition.cpp \
poppler-private.cpp \
- poppler-toc.cpp
+ poppler-toc.cpp \
+ poppler-version.cpp
libpoppler_cpp_la_LIBADD = \
$(top_builddir)/poppler/libpoppler.la
diff --git a/cpp/poppler-version.cpp b/cpp/poppler-version.cpp
new file mode 100644
index 0000000..89f95a3
--- /dev/null
+++ b/cpp/poppler-version.cpp
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2009, Pino Toscano <pino@kde.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include "poppler-version.h"
+
+using namespace poppler;
+
+std::string version_string()
+{
+ return std::string(POPPLER_VERSION);
+}
+
+unsigned int version_major()
+{
+ return POPPLER_VERSION_MAJOR;
+}
+
+unsigned int version_minor()
+{
+ return POPPLER_VERSION_MINOR;
+}
+
+unsigned int version_micro()
+{
+ return POPPLER_VERSION_MICRO;
+}
diff --git a/cpp/poppler-version.h.in b/cpp/poppler-version.h.in
new file mode 100644
index 0000000..cf6bce6
--- /dev/null
+++ b/cpp/poppler-version.h.in
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2009, Pino Toscano <pino@kde.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#ifndef POPPLER_VERSION_H
+#define POPPLER_VERSION_H
+
+#include "poppler-global.h"
+
+#define POPPLER_VERSION "@POPPLER_VERSION@"
+#define POPPLER_VERSION_MAJOR @POPPLER_MAJOR_VERSION@
+#define POPPLER_VERSION_MINOR @POPPLER_MINOR_VERSION@
+#define POPPLER_VERSION_MICRO @POPPLER_MICRO_VERSION@
+
+namespace poppler
+{
+
+POPPLER_CPP_EXPORT std::string version_string();
+POPPLER_CPP_EXPORT unsigned int version_major();
+POPPLER_CPP_EXPORT unsigned int version_minor();
+POPPLER_CPP_EXPORT unsigned int version_micro();
+
+}
+
+#endif