summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/pugiconfig.hpp1
-rw-r--r--src/pugixml.hpp7
-rw-r--r--tests/test_header_only.cpp16
3 files changed, 23 insertions, 1 deletions
diff --git a/src/pugiconfig.hpp b/src/pugiconfig.hpp
index 1c216e3..6219dbe 100644
--- a/src/pugiconfig.hpp
+++ b/src/pugiconfig.hpp
@@ -39,7 +39,6 @@
// Uncomment this to switch to header-only version
// #define PUGIXML_HEADER_ONLY
-// #include "pugixml.cpp"
// Uncomment this to enable long long support
// #define PUGIXML_HAS_LONG_LONG
diff --git a/src/pugixml.hpp b/src/pugixml.hpp
index 917ef4a..2432a3f 100644
--- a/src/pugixml.hpp
+++ b/src/pugixml.hpp
@@ -1329,6 +1329,13 @@ namespace std
#endif
+// Make sure implementation is included in header-only mode
+// Use macro expansion in #include to work around QMake (QTBUG-11923)
+#if defined(PUGIXML_HEADER_ONLY) && !defined(PUGIXML_SOURCE)
+# define PUGIXML_SOURCE "pugixml.cpp"
+# include PUGIXML_SOURCE
+#endif
+
/**
* Copyright (c) 2006-2014 Arseny Kapoulkine
*
diff --git a/tests/test_header_only.cpp b/tests/test_header_only.cpp
new file mode 100644
index 0000000..f1990dd
--- /dev/null
+++ b/tests/test_header_only.cpp
@@ -0,0 +1,16 @@
+#define PUGIXML_HEADER_ONLY
+#define pugi pugih
+
+#include "common.hpp"
+
+// Check header guards
+#include "../src/pugixml.hpp"
+#include "../src/pugixml.hpp"
+
+TEST(header_only)
+{
+ xml_document doc;
+ CHECK(doc.load_string(STR("<node/>")));
+ CHECK_STRING(doc.first_child().name(), STR("node"));
+ CHECK(doc.first_child() == doc.select_node(STR("//*")).node());
+}