mirror of
https://github.com/zeux/pugixml.git
synced 2024-12-26 12:41:06 +08:00
Auto-detect std::string_view support by default
Instead of opting in std::string_view support via PUGIXML_STRING_VIEW define, always enable it when C++17 is supported; this still requires enabling C++17 support in the compiler, which this change doesn't attempt to do yet.
This commit is contained in:
parent
4d0043fb6c
commit
ca4f7cfecc
4
.github/workflows/build.yml
vendored
4
.github/workflows/build.yml
vendored
@ -12,7 +12,7 @@ jobs:
|
|||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu, macos]
|
os: [ubuntu, macos]
|
||||||
compiler: [g++, clang++]
|
compiler: [g++, clang++]
|
||||||
defines: [standard, PUGIXML_WCHAR_MODE, PUGIXML_COMPACT, PUGIXML_NO_EXCEPTIONS, PUGIXML_STRING_VIEW]
|
defines: [standard, PUGIXML_WCHAR_MODE, PUGIXML_COMPACT, PUGIXML_NO_EXCEPTIONS]
|
||||||
exclude:
|
exclude:
|
||||||
- os: macos
|
- os: macos
|
||||||
compiler: g++
|
compiler: g++
|
||||||
@ -39,7 +39,7 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
arch: [Win32, x64]
|
arch: [Win32, x64]
|
||||||
defines: [standard, PUGIXML_WCHAR_MODE, PUGIXML_COMPACT, PUGIXML_NO_EXCEPTIONS, PUGIXML_STRING_VIEW]
|
defines: [standard, PUGIXML_WCHAR_MODE, PUGIXML_COMPACT, PUGIXML_NO_EXCEPTIONS]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v1
|
- uses: actions/checkout@v1
|
||||||
- name: cmake configure
|
- name: cmake configure
|
||||||
|
@ -48,8 +48,7 @@ option(PUGIXML_INSTALL "Enable installation rules" ON)
|
|||||||
option(PUGIXML_NO_XPATH "Disable XPath" OFF)
|
option(PUGIXML_NO_XPATH "Disable XPath" OFF)
|
||||||
option(PUGIXML_NO_STL "Disable STL" OFF)
|
option(PUGIXML_NO_STL "Disable STL" OFF)
|
||||||
option(PUGIXML_NO_EXCEPTIONS "Disable Exceptions" OFF)
|
option(PUGIXML_NO_EXCEPTIONS "Disable Exceptions" OFF)
|
||||||
option(PUGIXML_STRING_VIEW "Enable std::string_view overloads" OFF) # requires C++17 and for PUGIXML_NO_STL to be OFF
|
mark_as_advanced(PUGIXML_NO_XPATH PUGIXML_NO_STL PUGIXML_NO_EXCEPTIONS)
|
||||||
mark_as_advanced(PUGIXML_NO_XPATH PUGIXML_NO_STL PUGIXML_NO_EXCEPTIONS PUGIXML_STRING_VIEW)
|
|
||||||
|
|
||||||
set(PUGIXML_PUBLIC_DEFINITIONS
|
set(PUGIXML_PUBLIC_DEFINITIONS
|
||||||
$<$<BOOL:${PUGIXML_WCHAR_MODE}>:PUGIXML_WCHAR_MODE>
|
$<$<BOOL:${PUGIXML_WCHAR_MODE}>:PUGIXML_WCHAR_MODE>
|
||||||
@ -57,7 +56,6 @@ set(PUGIXML_PUBLIC_DEFINITIONS
|
|||||||
$<$<BOOL:${PUGIXML_NO_XPATH}>:PUGIXML_NO_XPATH>
|
$<$<BOOL:${PUGIXML_NO_XPATH}>:PUGIXML_NO_XPATH>
|
||||||
$<$<BOOL:${PUGIXML_NO_STL}>:PUGIXML_NO_STL>
|
$<$<BOOL:${PUGIXML_NO_STL}>:PUGIXML_NO_STL>
|
||||||
$<$<BOOL:${PUGIXML_NO_EXCEPTIONS}>:PUGIXML_NO_EXCEPTIONS>
|
$<$<BOOL:${PUGIXML_NO_EXCEPTIONS}>:PUGIXML_NO_EXCEPTIONS>
|
||||||
$<$<BOOL:${PUGIXML_STRING_VIEW}>:PUGIXML_STRING_VIEW>
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# This is used to backport a CMake 3.15 feature, but is also forwards compatible
|
# This is used to backport a CMake 3.15 feature, but is also forwards compatible
|
||||||
@ -66,10 +64,6 @@ if (NOT DEFINED CMAKE_MSVC_RUNTIME_LIBRARY)
|
|||||||
MultiThreaded$<$<CONFIG:Debug>:Debug>$<$<NOT:$<BOOL:${PUGIXML_STATIC_CRT}>>:DLL>)
|
MultiThreaded$<$<CONFIG:Debug>:Debug>$<$<NOT:$<BOOL:${PUGIXML_STATIC_CRT}>>:DLL>)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (PUGIXML_STRING_VIEW AND (NOT DEFINED CMAKE_CXX_STANDARD OR CMAKE_CXX_STANDARD LESS 17))
|
|
||||||
message(WARNING "PUGIXML_STRING_VIEW requires CMAKE_CXX_STANDARD to be set to 17 or later")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if (NOT DEFINED CMAKE_CXX_STANDARD_REQUIRED)
|
if (NOT DEFINED CMAKE_CXX_STANDARD_REQUIRED)
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
endif()
|
endif()
|
||||||
|
@ -46,13 +46,11 @@
|
|||||||
// Uncomment this to switch to header-only version
|
// Uncomment this to switch to header-only version
|
||||||
// #define PUGIXML_HEADER_ONLY
|
// #define PUGIXML_HEADER_ONLY
|
||||||
|
|
||||||
// Uncomment this to enable long long support
|
// Uncomment this to enable long long support (usually enabled automatically)
|
||||||
// #define PUGIXML_HAS_LONG_LONG
|
// #define PUGIXML_HAS_LONG_LONG
|
||||||
|
|
||||||
// Uncomment this to enable support for std::string_view (requires c++17 and for PUGIXML_NO_STL to not be set)
|
// Uncomment this to enable support for std::string_view (usually enabled automatically)
|
||||||
// Note: In a future version of pugixml this macro will become obsolete.
|
// #define PUGIXML_HAS_STRING_VIEW
|
||||||
// Support will then be enabled automatically if the used C++ standard supports it.
|
|
||||||
// #define PUGIXML_STRING_VIEW
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -38,8 +38,8 @@
|
|||||||
# include <string>
|
# include <string>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Check if std::string_view is both requested and available
|
// Check if std::string_view is available
|
||||||
#if defined(PUGIXML_STRING_VIEW) && !defined(PUGIXML_NO_STL)
|
#if !defined(PUGIXML_HAS_STRING_VIEW) && !defined(PUGIXML_NO_STL)
|
||||||
# if __cplusplus >= 201703L
|
# if __cplusplus >= 201703L
|
||||||
# define PUGIXML_HAS_STRING_VIEW
|
# define PUGIXML_HAS_STRING_VIEW
|
||||||
# elif defined(_MSVC_LANG) && _MSVC_LANG >= 201703L
|
# elif defined(_MSVC_LANG) && _MSVC_LANG >= 201703L
|
||||||
|
Loading…
x
Reference in New Issue
Block a user