summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Pipping <sebastian@pipping.org>2021-03-05 19:29:30 +0100
committerSebastian Pipping <sebastian@pipping.org>2021-03-05 20:54:03 +0100
commit41b5a874ce95eff4343f6499235482a24897d135 (patch)
tree559d19805d07497607e0a557133694305d1d526f
parent25f926a34025b0b01db892ca856e8a96063ffb7f (diff)
downloaduriparser-41b5a874ce95eff4343f6499235482a24897d135.tar.gz
CMake: Introducs build flag that turns warnings into errors
-rw-r--r--CMakeLists.txt9
-rw-r--r--ChangeLog2
-rw-r--r--README.md3
3 files changed, 14 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a217b89..a644bf0 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -65,6 +65,7 @@ option(URIPARSER_BUILD_TOOLS "Build tools (e.g. CLI \"uriparse\")" ON)
option(URIPARSER_BUILD_CHAR "Build code supporting data type 'char'" ON)
option(URIPARSER_BUILD_WCHAR_T "Build code supporting data type 'wchar_t'" ON)
option(URIPARSER_ENABLE_INSTALL "Enable installation of uriparser" ON)
+option(URIPARSER_WARNINGS_AS_ERRORS "Treat all compiler warnings as errors" OFF)
set(URIPARSER_MSVC_RUNTIME "" CACHE STRING "Use of specific runtime library (/MT /MTd /MD /MDd) with MSVC")
if(NOT URIPARSER_BUILD_CHAR AND NOT URIPARSER_BUILD_WCHAR_T)
@@ -103,6 +104,14 @@ if(URIPARSER_COMPILER_SUPPORTS_VISIBILITY)
set(URIPARSER_EXTRA_COMPILE_FLAGS "${URIPARSER_EXTRA_COMPILE_FLAGS} -fvisibility=hidden")
endif()
+if(URIPARSER_WARNINGS_AS_ERRORS)
+ if(MSVC)
+ add_definitions(/WX)
+ else()
+ set(URIPARSER_EXTRA_COMPILE_FLAGS "${URIPARSER_EXTRA_COMPILE_FLAGS} -Werror")
+ endif()
+endif()
+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${URIPARSER_EXTRA_COMPILE_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${URIPARSER_EXTRA_COMPILE_FLAGS}")
diff --git a/ChangeLog b/ChangeLog
index 6639ce8..13d89b1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -15,6 +15,8 @@ NOTE: uriparser is looking for help with a few things:
Thanks to jensenrichardson for the patch!
* Fixed: Link against pthreads for (default) -DURIPARSER_BUILD_TESTS=ON
(GitHub #99)
+ * Added: CMake option URIPARSER_WARNINGS_AS_ERRORS=(ON|OFF)
+ to turn compile warnings into errors, defaults to "OFF" (GitHub #102)
* Improved: pkg-config: Use ${prefix} and ${exec_prefix} to ease
overriding variables using --define-variable=NAME=VALUE,
e.g. as done on OpenWRT (GitHub #91)
diff --git a/README.md b/README.md
index d0512ca..5cfe5ff 100644
--- a/README.md
+++ b/README.md
@@ -78,4 +78,7 @@ URIPARSER_ENABLE_INSTALL:BOOL=ON
// Use of specific runtime library (/MT /MTd /MD /MDd) with MSVC
URIPARSER_MSVC_RUNTIME:STRING=
+
+// Treat all compiler warnings as errors
+URIPARSER_WARNINGS_AS_ERRORS:BOOL=OFF
```