Unverified Commit 866e0293 authored by Marcel Raad's avatar Marcel Raad
Browse files

CMake: set MSVC warning level to 4

The MSVC warning level defaults to 3 in CMake. Change it to 4, which is
consistent with the Visual Studio and NMake builds. Disable level 4
warning C4127 for the library and additionally C4306 for the test
servers to get a clean CURL_WERROR build as that warning is raised in
some macros in older Visual Studio versions.

Ref: https://github.com/curl/curl/pull/1667#issuecomment-314082794
Closes https://github.com/curl/curl/pull/1711
parent 70934885
Loading
Loading
Loading
Loading
+5 −0
Original line number Original line Diff line number Diff line
@@ -1161,6 +1161,11 @@ endif(WIN32)


if(MSVC)
if(MSVC)
  add_definitions(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE)
  add_definitions(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE)
  if(CMAKE_C_FLAGS MATCHES "/W[0-4]")
    string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
  else(CMAKE_C_FLAGS MATCHES "/W[0-4]")
    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W4")
  endif(CMAKE_C_FLAGS MATCHES "/W[0-4]")
endif(MSVC)
endif(MSVC)


# Ugly (but functional) way to include "Makefile.inc" by transforming it (= regenerate it).
# Ugly (but functional) way to include "Makefile.inc" by transforming it (= regenerate it).
+1 −0
Original line number Original line Diff line number Diff line
@@ -12,6 +12,7 @@ list(APPEND HHEADERS


if(MSVC)
if(MSVC)
  list(APPEND CSOURCES libcurl.rc)
  list(APPEND CSOURCES libcurl.rc)
  set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4127")
endif()
endif()


# SET(CSOURCES
# SET(CSOURCES
+4 −0
Original line number Original line Diff line number Diff line
set(TARGET_LABEL_PREFIX "Test server ")
set(TARGET_LABEL_PREFIX "Test server ")


if(MSVC)
  set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4127 /wd4306")
endif()

function(SETUP_EXECUTABLE TEST_NAME)    # ARGN are the files in the test
function(SETUP_EXECUTABLE TEST_NAME)    # ARGN are the files in the test
  add_executable( ${TEST_NAME} ${ARGN} )
  add_executable( ${TEST_NAME} ${ARGN} )
  string(TOUPPER ${TEST_NAME} UPPER_TEST_NAME)
  string(TOUPPER ${TEST_NAME} UPPER_TEST_NAME)