mirror of
https://github.com/curl/curl.git
synced 2026-07-22 18:47:17 +03:00
cmake: merge CURL_WERROR logic into PickyWarnings.cmake
Safe to do this now, as the code no longer relies on setting these
options after feature detection.
Also: Tidy up the way we handle options not to be passed to feature
checks, and make sure to show them in the configure log.
Follow-up to e86542038d #17047
Closes #17062
This commit is contained in:
parent
00e8ebf567
commit
01c429c4a8
2 changed files with 31 additions and 27 deletions
|
|
@ -24,13 +24,21 @@
|
|||
include(CheckCCompilerFlag)
|
||||
|
||||
set(_picky "")
|
||||
set(_picky_nocheck "") # not to pass to feature checks
|
||||
|
||||
if(CURL_WERROR AND
|
||||
((CMAKE_C_COMPILER_ID STREQUAL "GNU" AND
|
||||
NOT DOS AND # Watt-32 headers use the '#include_next' GCC extension
|
||||
CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 5.0) OR
|
||||
CMAKE_C_COMPILER_ID MATCHES "Clang"))
|
||||
list(APPEND _picky "-pedantic-errors")
|
||||
if(CURL_WERROR)
|
||||
if(MSVC)
|
||||
list(APPEND _picky_nocheck "-WX")
|
||||
else() # llvm/clang and gcc style options
|
||||
list(APPEND _picky_nocheck "-Werror")
|
||||
endif()
|
||||
|
||||
if((CMAKE_C_COMPILER_ID STREQUAL "GNU" AND
|
||||
NOT DOS AND # Watt-32 headers use the '#include_next' GCC extension
|
||||
CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 5.0) OR
|
||||
CMAKE_C_COMPILER_ID MATCHES "Clang")
|
||||
list(APPEND _picky_nocheck "-pedantic-errors")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(APPLE AND
|
||||
|
|
@ -44,6 +52,7 @@ if(CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID MATCHES "Clang")
|
|||
endif()
|
||||
|
||||
if(MSVC)
|
||||
# Use the highest warning level for Visual Studio.
|
||||
string(REGEX REPLACE "[/-]W[0-4]" "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
|
||||
list(APPEND _picky "-W4")
|
||||
elseif(BORLAND)
|
||||
|
|
@ -278,25 +287,28 @@ endif()
|
|||
if(CMAKE_C_COMPILER_ID STREQUAL "Clang" AND MSVC)
|
||||
list(APPEND _picky "-Wno-language-extension-token") # Allow __int64
|
||||
|
||||
set(_picky_tmp "")
|
||||
foreach(_ccopt IN LISTS _picky)
|
||||
# Prefix -Wall, otherwise clang-cl interprets it as an MSVC option and translates it to -Weverything
|
||||
if(_ccopt MATCHES "^-W" AND NOT _ccopt STREQUAL "-Wall")
|
||||
list(APPEND _picky_tmp ${_ccopt})
|
||||
else()
|
||||
list(APPEND _picky_tmp "-clang:${_ccopt}")
|
||||
endif()
|
||||
foreach(_wlist IN ITEMS _picky_nocheck _picky)
|
||||
set(_picky_tmp "")
|
||||
foreach(_ccopt IN LISTS "${_wlist}")
|
||||
# Prefix -Wall, otherwise clang-cl interprets it as an MSVC option and translates it to -Weverything
|
||||
if(_ccopt MATCHES "^-W" AND NOT _ccopt STREQUAL "-Wall")
|
||||
list(APPEND _picky_tmp ${_ccopt})
|
||||
else()
|
||||
list(APPEND _picky_tmp "-clang:${_ccopt}")
|
||||
endif()
|
||||
endforeach()
|
||||
set("${_wlist}" ${_picky_tmp})
|
||||
endforeach()
|
||||
set(_picky ${_picky_tmp})
|
||||
endif()
|
||||
|
||||
if(_picky)
|
||||
string(REPLACE ";" " " _picky_tmp "${_picky}")
|
||||
if(_picky_nocheck OR _picky)
|
||||
set(_picky_tmp "${_picky_nocheck}" "${_picky}")
|
||||
string(REPLACE ";" " " _picky_tmp "${_picky_tmp}")
|
||||
string(STRIP "${_picky_tmp}" _picky_tmp)
|
||||
message(STATUS "Picky compiler options: ${_picky_tmp}")
|
||||
set_property(DIRECTORY APPEND PROPERTY COMPILE_OPTIONS "${_picky}")
|
||||
set_property(DIRECTORY APPEND PROPERTY COMPILE_OPTIONS "${_picky_nocheck}" "${_picky}")
|
||||
|
||||
# Apply to all feature checks
|
||||
list(REMOVE_ITEM _picky "-pedantic-errors") # Must not pass to feature checks
|
||||
string(REPLACE ";" " " _picky_tmp "${_picky}")
|
||||
string(APPEND CMAKE_REQUIRED_FLAGS " ${_picky_tmp}")
|
||||
|
||||
|
|
|
|||
|
|
@ -2009,14 +2009,6 @@ if(CMAKE_C_COMPILER_ID STREQUAL "MSVC") # MSVC but exclude clang-cl
|
|||
set_property(DIRECTORY APPEND PROPERTY COMPILE_OPTIONS "-MP") # Parallel compilation
|
||||
endif()
|
||||
|
||||
if(CURL_WERROR)
|
||||
if(MSVC)
|
||||
set_property(DIRECTORY APPEND PROPERTY COMPILE_OPTIONS "-WX")
|
||||
else()
|
||||
set_property(DIRECTORY APPEND PROPERTY COMPILE_OPTIONS "-Werror") # This assumes clang or gcc style options
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(CURL_LTO)
|
||||
if(CMAKE_VERSION VERSION_LESS 3.9)
|
||||
message(FATAL_ERROR "LTO has been requested, but your cmake version ${CMAKE_VERSION} is to old. You need at least 3.9")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue