From c6316d3d8f2beea178c3d374eeb8f8ec191a868f Mon Sep 17 00:00:00 2001 From: Kai Tindall Date: Wed, 9 Dec 2020 18:14:09 +0000 Subject: [PATCH] Cmake-ified pugiconfig --- CMakeLists.txt | 38 ++++++++++++++++++++++++++++++++++++++ src/pugiconfig.hpp | 28 ---------------------------- 2 files changed, 38 insertions(+), 28 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 96c0160..1602124 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,6 +27,44 @@ option(BUILD_SHARED_AND_STATIC_LIBS "Build both shared and static libraries" OFF # Technically not needed for this file. This is builtin. option(BUILD_SHARED_LIBS "Build shared instead of static library" OFF) +# Options from the pugiconfig.hpp file. + +option(PUGIXML_WCHAR_MODE "Enable wchar_t mode" OFF) +option(PUGIXML_COMPACT "Enable compact mode" OFF) +option(PUGIXML_NO_XPATH "Disable XPath" OFF) +option(PUGIXML_NO_STL "Disable STL" OFF) +option(PUGIXML_NO_EXCEPTIONS "Disable Exceptions" OFF) +option(PUGIXML_HEADER_ONLY "Switch to header only" OFF) +option(PUGIXML_HAS_LONG_LONG "Enable long long support" OFF) + +# Tune these to adjust memory-related behaviour +set(PUGIXML_MEMORY_PAGE_SIZE 32768) +set(PUGIXML_MEMORY_OUTPUT_STACK 10240) +set(PUGIXML_MEMORY_XPATH_PAGE_SIZE 4096) + +# Tune this to adjust max nesting for XPath queries +set(PUGIXML_XPATH_DEPTH_LIMIT 1024) + +# Set these to control attributes for public classes/functions (Not 100% sure if these will work.) + +option(PUGIXML_OVERRIDE_API "Export all public symbols from DLL" OFF) +option(PUGIXML_OVERRIDE_CLASS "Import all classes from DLL" OFF) +option(PUGIXML_OVERRIDE_FUNCTION "Set calling conventions to all public functions to fastcall" OFF) + +if(${PUGIXML_OVERRIDE_API}) + set(PUGIXML_API __declspec(dllexport)) +endif() + +if(${PUGIXML_OVERRIDE_CLASS}) + set(PUGIXML_CLASS __declspec(dllimport) +endif() + +if(${PUGIXML_OVERRIDE_FUNCTION}) + set(PUGIXML_FUNCTION __fastcall) +endif() + +# End of options + set(BUILD_DEFINES CACHE STRING "Build defines") # This is used to backport a CMake 3.15 feature, but is also forwards compatible diff --git a/src/pugiconfig.hpp b/src/pugiconfig.hpp index 405a66b..24d3433 100644 --- a/src/pugiconfig.hpp +++ b/src/pugiconfig.hpp @@ -14,20 +14,6 @@ #ifndef HEADER_PUGICONFIG_HPP #define HEADER_PUGICONFIG_HPP -// Uncomment this to enable wchar_t mode -// #define PUGIXML_WCHAR_MODE - -// Uncomment this to enable compact mode -// #define PUGIXML_COMPACT - -// Uncomment this to disable XPath -// #define PUGIXML_NO_XPATH - -// Uncomment this to disable STL -// #define PUGIXML_NO_STL - -// Uncomment this to disable exceptions -// #define PUGIXML_NO_EXCEPTIONS // Set this to control attributes for public classes/functions, i.e.: // #define PUGIXML_API __declspec(dllexport) // to export all public symbols from DLL @@ -35,20 +21,6 @@ // #define PUGIXML_FUNCTION __fastcall // to set calling conventions to all public functions to fastcall // In absence of PUGIXML_CLASS/PUGIXML_FUNCTION definitions PUGIXML_API is used instead -// Tune these constants to adjust memory-related behavior -// #define PUGIXML_MEMORY_PAGE_SIZE 32768 -// #define PUGIXML_MEMORY_OUTPUT_STACK 10240 -// #define PUGIXML_MEMORY_XPATH_PAGE_SIZE 4096 - -// Tune this constant to adjust max nesting for XPath queries -// #define PUGIXML_XPATH_DEPTH_LIMIT 1024 - -// Uncomment this to switch to header-only version -// #define PUGIXML_HEADER_ONLY - -// Uncomment this to enable long long support -// #define PUGIXML_HAS_LONG_LONG - #endif /**