]> granicus.if.org Git - curl/commitdiff
cmake: add CURL_WERROR for enabling "warning as errors"
authorDaniel Stenberg <daniel@haxx.se>
Thu, 6 Jul 2017 10:12:31 +0000 (12:12 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Thu, 6 Jul 2017 15:06:24 +0000 (17:06 +0200)
CMakeLists.txt

index 086c37197cd1a0c22e85508966f8ddd2698348a4..25d8fd8f0f998258f7159030f8b7debd6029226a 100644 (file)
@@ -72,6 +72,7 @@ set(OS "\"${CMAKE_SYSTEM_NAME}\"")
 include_directories(${PROJECT_BINARY_DIR}/include/curl)
 include_directories( ${CURL_SOURCE_DIR}/include )
 
+option(CURL_WERROR "Turn compiler warnings into errors" OFF)
 option(BUILD_CURL_EXE "Set to ON to build curl executable." ON)
 option(CURL_STATICLIB "Set to ON to build libcurl with static linking." OFF)
 option(ENABLE_ARES "Set to ON to enable c-ares support" OFF)
@@ -244,6 +245,16 @@ if(BORLAND)
   set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w-")
 endif(BORLAND)
 
+if(CURL_WERROR)
+  if(MSVC_VERSION)
+    set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /WX")
+    set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_RELEASE} /WX")
+  else()
+    # this assumes clang or gcc style options
+    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror")
+  endif()
+endif(CURL_WERROR)
+
 # If we are on AIX, do the _ALL_SOURCE magic
 if(${CMAKE_SYSTEM_NAME} MATCHES AIX)
   set(_ALL_SOURCE 1)