Skip to content

Commit 23e617b

Browse files
authored
Warn if PUGIXML_STRING_VIEW is set without CMAKE_CXX_STANDARD (#638)
Even if the compiler supports C++17, we define CMAKE_CXX_STANDARD as 11 by default which implicitly disables string_view support; for now warn in this case.
1 parent 13beda2 commit 23e617b

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ option(PUGIXML_INSTALL "Enable installation rules" ON)
4848
option(PUGIXML_NO_XPATH "Disable XPath" OFF)
4949
option(PUGIXML_NO_STL "Disable STL" OFF)
5050
option(PUGIXML_NO_EXCEPTIONS "Disable Exceptions" OFF)
51-
option(PUGIXML_STRING_VIEW "Enable std::string_view overloads" OFF) # requires C++17 and for PUGI_NO_STL to be OFF
51+
option(PUGIXML_STRING_VIEW "Enable std::string_view overloads" OFF) # requires C++17 and for PUGIXML_NO_STL to be OFF
5252
mark_as_advanced(PUGIXML_NO_XPATH PUGIXML_NO_STL PUGIXML_NO_EXCEPTIONS PUGIXML_STRING_VIEW)
5353

5454
set(PUGIXML_PUBLIC_DEFINITIONS
@@ -66,6 +66,10 @@ if (NOT DEFINED CMAKE_MSVC_RUNTIME_LIBRARY)
6666
MultiThreaded$<$<CONFIG:Debug>:Debug>$<$<NOT:$<BOOL:${PUGIXML_STATIC_CRT}>>:DLL>)
6767
endif()
6868

69+
if (PUGIXML_STRING_VIEW AND (NOT DEFINED CMAKE_CXX_STANDARD OR CMAKE_CXX_STANDARD LESS 17))
70+
message(WARNING "PUGIXML_STRING_VIEW requires CMAKE_CXX_STANDARD to be set to 17 or later")
71+
endif()
72+
6973
if (NOT DEFINED CMAKE_CXX_STANDARD_REQUIRED)
7074
set(CMAKE_CXX_STANDARD_REQUIRED ON)
7175
endif()

0 commit comments

Comments
 (0)