[CMAKE] Get rid of replace_compile_flags

Introduce a finer-grained remove_target_compile_option instead
This commit is contained in:
Jérôme Gardou 2020-09-18 11:49:18 +02:00 committed by Jérôme Gardou
parent b52fa999eb
commit 7e116f0ef3
27 changed files with 138 additions and 144 deletions

View File

@ -4,11 +4,6 @@ remove_definitions(-D_WIN32_IE=0x600)
add_definitions(-D__ROS_LONG64__)
include_directories(BEFORE ${REACTOS_SOURCE_DIR}/sdk/include/reactos/wine)
if(MSVC)
# Disable warning C4477 (printf format warnings)
add_compile_flags("/wd4477")
endif()
list(APPEND SOURCE
olecallback.c
print.c
@ -22,3 +17,8 @@ set_module_type(wordpad win32gui)
target_link_libraries(wordpad wine uuid)
add_importlibs(wordpad comdlg32 ole32 shell32 user32 gdi32 advapi32 comctl32 msvcrt kernel32 ntdll)
add_cd_file(TARGET wordpad DESTINATION reactos/system32 FOR all)
if(MSVC)
# Disable warning C4477 (printf format warnings)
target_compile_options(wordpad PRIVATE /wd4477)
endif()

View File

@ -7,12 +7,7 @@ include_directories(
${REACTOS_SOURCE_DIR}/drivers/filesystems/nfs
${REACTOS_SOURCE_DIR}/dll/np/nfs)
if(MSVC)
# Disable warning C4477 (printf format warnings)
add_compile_flags("/wd4477")
endif()
list(APPEND SOURCE
list(APPEND SOURCE
acl.c
callback_server.c
callback_xdr.c
@ -54,6 +49,8 @@ list(APPEND SOURCE
add_executable(nfsd ${SOURCE} nfsd.rc)
if(MSVC AND (NOT USE_CLANG_CL))
# Disable warning C4477 (printf format warnings)
target_compile_options(nfsd PRIVATE "/wd4477")
else()
# FIXME: Tons of warnings.
target_compile_options(nfsd PRIVATE "-w")

View File

@ -7,9 +7,6 @@ if(SEPARATE_DBG)
endif()
if(MSVC)
# We don't need hotpatching
replace_compile_flags("/hotpatch" " ")
# Explicitly use string pooling
add_compile_flags("/GF")
endif()
@ -285,6 +282,10 @@ if(MSVC)
add_target_link_flags(freeldr_pe_dbg "/ignore:4078 /ignore:4254 /DRIVER /FIXED /FILEALIGN:0x200 /ALIGN:0x200")
add_linker_script(freeldr_pe_dbg freeldr_i386.msvc.lds)
endif()
# We don't need hotpatching
remove_target_compile_option(freeldr_pe "/hotpatch")
remove_target_compile_option(freeldr_pe_dbg "/hotpatch")
remove_target_compile_option(freeldr_common "/hotpatch")
else()
add_target_link_flags(freeldr_pe "-Wl,--strip-all,--exclude-all-symbols,--file-alignment,0x200,--section-alignment,0x200")
add_linker_script(freeldr_pe freeldr_i386.lds)

View File

@ -5,14 +5,6 @@ add_definitions(
-DUSE_WIN32_FILEIO
-DTIF_PLATFORM_CONSOLE)
if(MSVC)
# error C4311: 'type cast': pointer truncation from 'thandle_t' to 'int'
replace_compile_flags("/we4311" " ")
# error C4312: 'type cast': conversion from 'int' to 'thandle_t' of greater size
replace_compile_flags("/we4312" " ")
endif()
include_directories(
${REACTOS_SOURCE_DIR}/sdk/include/reactos/libs/libtiff
${REACTOS_SOURCE_DIR}/sdk/include/reactos/libs/zlib)
@ -63,12 +55,18 @@ list(APPEND SOURCE
precomp.h)
add_library(libtiff MODULE ${SOURCE} libtiff.def)
set_module_type(libtiff win32dll)
target_link_libraries(libtiff zlib getopt)
add_importlibs(libtiff user32 msvcrt kernel32 ntdll)
add_pch(libtiff precomp.h SOURCE)
add_cd_file(TARGET libtiff DESTINATION reactos/system32 FOR all)
if(NOT MSVC)
if (MSVC)
# error C4311: 'type cast': pointer truncation from 'thandle_t' to 'int'
remove_target_compile_option(libtiff "/we4311")
# error C4312: 'type cast': conversion from 'int' to 'thandle_t' of greater size
remove_target_compile_option(libtiff "/we4312")
else()
target_compile_options(libtiff PRIVATE "-Wno-unused-but-set-variable")
endif()

View File

@ -6,14 +6,6 @@ add_definitions(-DUNICODE -D_WIN32 -DPORTMAP -Dstrdup=_strdup -D_CRT_NONSTDC_NO_
include_directories(${REACTOS_SOURCE_DIR}/dll/3rdparty/libtirpc/tirpc)
if(MSVC)
# error C4133: '=': incompatible types - from 'char *' to 'int32_t *'
replace_compile_flags("/we4133" " ")
# Disable warning C4477 (printf format warnings)
add_compile_flags("/wd4313")
endif()
list(APPEND SOURCE
src/asprintf.c
# src/auth_des.c
@ -101,9 +93,15 @@ add_library(libtirpc MODULE
libtirpc/libtirpc_ros.rc
${CMAKE_CURRENT_BINARY_DIR}/libtirpc.def)
if(MSVC AND (NOT USE_CLANG_CL))
replace_compile_flags("/we4101" " ")
target_compile_options(libtirpc PRIVATE /wd4101 /wd4133 /wd4473 /wd4477)
if(MSVC)
# error C4133: '=': incompatible types - from 'char *' to 'int32_t *'
remove_target_compile_option(libtirpc "/we4133")
# Disable warning C4477 (printf format warnings)
target_compile_options(libtirpc PRIVATE /wd4313)
if (NOT USE_CLANG_CL)
remove_target_compile_option(libtirpc "/we4101")
target_compile_options(libtirpc PRIVATE /wd4101 /wd4133 /wd4473 /wd4477)
endif()
else()
# FIXME: Tons of warnings.
target_compile_options(libtirpc PRIVATE "-w")

View File

@ -3,17 +3,18 @@ add_definitions(-D__WINESRC__)
include_directories(${REACTOS_SOURCE_DIR}/sdk/include/reactos/wine)
spec2def(clusapi.dll clusapi.spec)
if(MSVC)
# error C4312: 'type cast': conversion from 'unsigned int' to 'HCLUSTER' of greater size
replace_compile_flags("/we4312" " ")
endif()
list(APPEND SOURCE
clusapi.c
${CMAKE_CURRENT_BINARY_DIR}/clusapi_stubs.c
${CMAKE_CURRENT_BINARY_DIR}/clusapi.def)
add_library(clusapi MODULE ${SOURCE})
if(MSVC)
# error C4312: 'type cast': conversion from 'unsigned int' to 'HCLUSTER' of greater size
remove_target_compile_option(clusapi "/we4312")
endif()
set_module_type(clusapi win32dll)
target_link_libraries(clusapi wine)
add_importlibs(clusapi msvcrt kernel32 ntdll)

View File

@ -12,8 +12,7 @@ include_directories(BEFORE ${REACTOS_SOURCE_DIR}/sdk/include/reactos/wine)
spec2def(comctl32.dll comctl32.spec ADD_IMPORTLIB)
if(MSVC)
# Disable warning C4477 (printf format warnings)
add_compile_flags("/wd4477")
endif()
list(APPEND SOURCE
@ -65,6 +64,9 @@ add_library(comctl32 MODULE
rsrc.rc
${CMAKE_CURRENT_BINARY_DIR}/comctl32.def)
# Disable warning C4477 (printf format warnings)
target_compile_options(comctl32 PRIVATE $<$<BOOL:${MSVC}>:/wd4477>)
set_module_type(comctl32 win32dll UNICODE)
target_link_libraries(comctl32 uuid wine ${PSEH_LIB})
add_delay_importlibs(comctl32 winmm uxtheme)

View File

@ -11,11 +11,6 @@ add_definitions(
include_directories(${REACTOS_SOURCE_DIR}/sdk/include/reactos/wine)
spec2def(crypt32.dll crypt32.spec ADD_IMPORTLIB)
if(MSVC)
# error C4312: 'type cast': conversion from 'unsigned int' to 'void *' of greater size
replace_compile_flags("/we4312" " ")
endif()
list(APPEND SOURCE
base64.c
cert.c
@ -51,6 +46,11 @@ add_library(crypt32 MODULE
crypt32.rc
${CMAKE_CURRENT_BINARY_DIR}/crypt32.def)
if(MSVC)
# error C4312: 'type cast': conversion from 'unsigned int' to 'void *' of greater size
remove_target_compile_option(crypt32 "/we4312")
endif()
set_module_type(crypt32 win32dll)
target_link_libraries(crypt32 wine ${PSEH_LIB} oldnames)
add_delay_importlibs(crypt32 cryptnet)

View File

@ -1,9 +1,4 @@
if(MSVC)
# Disable warning C4477 (printf format warnings)
add_compile_flags("/wd4477")
endif()
if(NOT CMAKE_CROSSCOMPILING)
add_definitions(-DDBGHELP_STATIC_LIB)
@ -85,4 +80,7 @@ else()
add_pch(dbghelp precomp.h SOURCE)
add_cd_file(TARGET dbghelp DESTINATION reactos/system32 FOR all)
if (MSVC)
target_compile_options(dbghelp PRIVATE /wd4477)
endif()
endif()

View File

@ -11,11 +11,6 @@ include_directories(${REACTOS_SOURCE_DIR}/sdk/include/reactos/wine)
add_idl_headers(mshtml_nsiface_header nsiface.idl)
spec2def(mshtml.dll mshtml.spec ADD_IMPORTLIB)
if(MSVC)
# error C4028: formal parameter 3 different from declaration
replace_compile_flags("/we4028" " ")
endif()
list(APPEND SOURCE
conpoint.c
dispex.c
@ -105,6 +100,11 @@ add_library(mshtml MODULE
rsrc.rc
${CMAKE_CURRENT_BINARY_DIR}/mshtml.def)
if(MSVC)
# error C4028: formal parameter 3 different from declaration
remove_target_compile_option(mshtml "/we4028")
endif()
list(APPEND mshtml_rc_deps
${CMAKE_CURRENT_SOURCE_DIR}/blank.htm
${CMAKE_CURRENT_SOURCE_DIR}/mshtml.inf

View File

@ -7,14 +7,6 @@ add_definitions(-D__WINESRC__ -D__ROS_LONG64__ -DMSIRUNMODE=MSIRUNMODE_T)
spec2def(msi.dll msi.spec ADD_IMPORTLIB)
generate_idl_iids(msiserver.idl)
if(MSVC)
# error C4133: 'function': incompatible types - from 'UINT *' to 'MSIINSTALLCONTEXT *'
replace_compile_flags("/we4133" " ")
# error C4312: 'type cast': conversion from 'unsigned int' to 'HANDLE' of greater size
replace_compile_flags("/we4312" " ")
endif()
list(APPEND SOURCE
action.c
alter.c
@ -71,6 +63,14 @@ add_library(msi MODULE
msi.rc
${CMAKE_CURRENT_BINARY_DIR}/msi.def)
if(MSVC)
# error C4133: 'function': incompatible types - from 'UINT *' to 'MSIINSTALLCONTEXT *'
remove_target_compile_option(msi "/we4133")
# error C4312: 'type cast': conversion from 'unsigned int' to 'HANDLE' of greater size
remove_target_compile_option(msi "/we4312")
endif()
add_idl_headers(msi_idlheader msiserver.idl)
add_typelib(msiserver.idl)
set_source_files_properties(msi.rc PROPERTIES OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/msiserver.tlb)

View File

@ -3,16 +3,17 @@ add_definitions(-D__WINESRC__)
include_directories(${REACTOS_SOURCE_DIR}/sdk/include/reactos/wine)
spec2def(msrle32.dll msrle32.spec)
if(MSVC)
# error C4312: 'type cast': conversion from 'unsigned int' to 'LPVOID' of greater size
replace_compile_flags("/we4312" " ")
endif()
list(APPEND SOURCE
msrle32.c
${CMAKE_CURRENT_BINARY_DIR}/msrle32.def)
add_library(msrle32 MODULE ${SOURCE} rsrc.rc)
if(MSVC)
# error C4312: 'type cast': conversion from 'unsigned int' to 'LPVOID' of greater size
remove_target_compile_option(msrle32 "/we4312")
endif()
set_module_type(msrle32 win32dll)
target_link_libraries(msrle32 wine)
add_importlibs(msrle32 winmm user32 msvcrt kernel32 ntdll)

View File

@ -11,11 +11,6 @@ if(NOT MSVC)
add_compile_flags_language("-std=c++11" "CXX")
endif()
if(MSVC)
# error C4311: 'type cast': pointer truncation from 'HANDLE' to 'INT'
replace_compile_flags("/we4311" " ")
endif()
remove_definitions(-D_WIN32_WINNT=0x502)
add_definitions(-D_WIN32_WINNT=0x600)
@ -112,6 +107,11 @@ add_library(shell32 MODULE
shell32.rc
${CMAKE_CURRENT_BINARY_DIR}/shell32.def)
if (MSVC)
# error C4311: 'type cast': pointer truncation from 'HANDLE' to 'INT'
remove_target_compile_option(shell32 "/we4311")
endif()
add_typelib(shell32_shldisp.idl)
set_source_files_properties(shell32.rc PROPERTIES OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/shell32_shldisp.tlb)

View File

@ -9,11 +9,6 @@ add_definitions(
remove_definitions(-D_WIN32_WINNT=0x502)
add_definitions(-D_WIN32_WINNT=0x600)
if(MSVC)
# error C4133: 'function': incompatible types - from 'WICPixelFormatNumericRepresentation *' to 'DWORD *'
replace_compile_flags("/we4133" " ")
endif()
include_directories(
BEFORE ${REACTOS_SOURCE_DIR}/sdk/include/reactos/wine
${REACTOS_SOURCE_DIR}/sdk/include/reactos/libs/libjpeg
@ -79,6 +74,11 @@ add_library(windowscodecs MODULE
version.rc
${CMAKE_CURRENT_BINARY_DIR}/windowscodecs.def)
if(MSVC)
# error C4133: 'function': incompatible types - from 'WICPixelFormatNumericRepresentation *' to 'DWORD *'
remove_target_compile_option(windowscodecs "/we4133")
endif()
set_module_type(windowscodecs win32dll)
target_link_libraries(windowscodecs wine uuid ${PSEH_LIB})
add_importlibs(windowscodecs ole32 oleaut32 rpcrt4 shlwapi user32 gdi32 advapi32 advapi32_vista propsys msvcrt kernel32 ntdll)

View File

@ -3,11 +3,6 @@ add_definitions(-D_WINE)
include_directories(BEFORE ${REACTOS_SOURCE_DIR}/sdk/include/reactos/wine)
spec2def(winmm.dll winmm.spec ADD_IMPORTLIB)
if(MSVC)
# error C4312: 'type cast': conversion from 'DWORD' to 'HTASK' of greater size
replace_compile_flags("/we4312" " ")
endif()
list(APPEND SOURCE
driver.c
joystick.c
@ -26,6 +21,12 @@ add_library(winmm MODULE
winmm_res.rc
${CMAKE_CURRENT_BINARY_DIR}/winmm.def)
if(MSVC)
# error C4312: 'type cast': conversion from 'DWORD' to 'HTASK' of greater size
remove_target_compile_option(winmm "/we4312")
endif()
set_module_type(winmm win32dll)
target_link_libraries(winmm wine ${PSEH_LIB})
add_importlibs(winmm advapi32 user32 msvcrt kernel32 ntdll)

View File

@ -1,17 +1,18 @@
spec2def(midimap.dll midimap.spec)
if(MSVC)
# error C4133: 'function': incompatible types - from 'LPDWORD' to 'DWORD_PTR *'
replace_compile_flags("/we4133" " ")
endif()
add_library(midimap MODULE
midimap.c
midimap.rc
${CMAKE_CURRENT_BINARY_DIR}/midimap.def)
set_module_type(midimap win32dll UNICODE)
if(MSVC)
# error C4133: 'function': incompatible types - from 'LPDWORD' to 'DWORD_PTR *'
remove_target_compile_option(midimap "/we4133")
endif()
target_link_libraries(midimap uuid wine)
add_importlibs(midimap advapi32 user32 winmm msvcrt kernel32 ntdll)
add_cd_file(TARGET midimap DESTINATION reactos/system32 FOR all)

View File

@ -94,8 +94,8 @@ endif()
if(MSVC AND (NOT USE_CLANG_CL))
# Disable warnings: "unreferenced local variable", "initialized, but not used variable", "benign include"
replace_compile_flags("/we4101" " ")
replace_compile_flags("/we4189" " ")
remove_target_compile_option(ext2fs "/we4101")
remove_target_compile_option(ext2fs "/we4189")
target_compile_options(ext2fs PRIVATE /wd4189 /wd4142 /wd4101)
else()
target_compile_options(ext2fs PRIVATE -Wno-pointer-sign -Wno-unused-function)

View File

@ -87,8 +87,8 @@ if(USE_CLANG_CL OR (NOT MSVC))
endif()
else()
#disable warnings: "unreferenced local variable", "initialized, but not used variable", "benign include"
replace_compile_flags("/we4101" " ")
replace_compile_flags("/we4189" " ")
remove_target_compile_option(reiserfs "/we4101")
remove_target_compile_option(reiserfs "/we4189")
target_compile_options(reiserfs PRIVATE /wd4189 /wd4142 /wd4101)
endif()

View File

@ -2,16 +2,18 @@
add_definitions(-D__ROS_LONG64__)
if(MSVC)
add_compile_flags("/wd4090") # C4090: 'function': different 'const' qualifiers
add_compile_flags("/wd4133") # C4133: 'function': incompatible types - from '<enum> *' to 'UINT *'
add_compile_flags("/wd4146") # C4146: unary minus operator applied to unsigned type, result still unsigned
add_compile_flags("/wd4189") # C4189: 'x': local variable is initialized but not referenced
add_compile_flags("/wd4267") # C4267: '=': conversion from 'size_t' to 'int', possible loss of data
add_compile_flags("/wd4305") # C4305: '=': truncation from 'double' to 'FLOAT'
add_compile_options(
/wd4090 # C4090: 'function': different 'const' qualifiers
/wd4133 # C4133: 'function': incompatible types - from '<enum> *' to 'UINT *'
/wd4146 # C4146: unary minus operator applied to unsigned type, result still unsigned
/wd4189 # C4189: 'x': local variable is initialized but not referenced
/wd4267 # C4267: '=': conversion from 'size_t' to 'int', possible loss of data
/wd4305) # C4305: '=': truncation from 'double' to 'FLOAT'
if(ARCH STREQUAL "amd64")
add_compile_flags("/wd4101") # C4101: 'x': unreferenced local variable
add_compile_flags("/wd4312") # C4312: 'type cast': conversion from 'unsigned int' to 'char *' of greater size
add_compile_flags("/wd4334") # C4334: '<<': result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?)
add_compile_options(
/wd4101 # C4101: 'x': unreferenced local variable
/wd4312 # C4312: 'type cast': conversion from 'unsigned int' to 'char *' of greater size
/wd4334) # C4334: '<<': result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?)
endif()
endif()

View File

@ -42,9 +42,7 @@ add_executable(comctl32_winetest
${PCH_SKIP_SOURCE}
rsrc.rc)
if(USE_CLANG_CL OR (NOT MSVC))
target_compile_options(comctl32_winetest PRIVATE "-Wno-format")
endif()
target_compile_options(comctl32_winetest PRIVATE $<$<NOT:$<C_COMPILER_ID:MSVC>>:-Wno-format>)
set_module_type(comctl32_winetest win32cui)
add_importlibs(comctl32_winetest comctl32 ole32 user32 gdi32 advapi32 msvcrt kernel32)

View File

@ -1,11 +1,6 @@
add_definitions(-DUSE_WINE_TODOS)
if(MSVC)
# error C4133: 'function': incompatible types - from 'ImageFlags *' to 'UINT *'
replace_compile_flags("/we4133" " ")
endif()
list(APPEND SOURCE
brush.c
customlinecap.c
@ -33,3 +28,8 @@ set_module_type(gdiplus_winetest win32cui)
add_importlibs(gdiplus_winetest gdiplus user32 gdi32 ole32 msvcrt kernel32)
add_pch(gdiplus_winetest precomp.h "${PCH_SKIP_SOURCE}")
add_rostests_file(TARGET gdiplus_winetest)
if(MSVC)
# error C4133: 'function': incompatible types - from 'ImageFlags *' to 'UINT *'
remove_target_compile_option(gdiplus_winetest "/we4133")
endif()

View File

@ -3,11 +3,6 @@ include_directories(BEFORE ${REACTOS_SOURCE_DIR}/sdk/include/reactos/wine)
remove_definitions(-DWINVER=0x502 -D_WIN32_IE=0x600 -D_WIN32_WINNT=0x502)
add_definitions(-DWINVER=0x600 -D_WIN32_WINNT=0x601)
if(MSVC)
# Disable warning C4477 (printf format warnings)
add_compile_flags("/wd4477")
endif()
list(APPEND SOURCE
actctx.c
atom.c
@ -50,6 +45,11 @@ add_executable(kernel32_winetest
${PCH_SKIP_SOURCE}
resource.rc)
if(MSVC)
# Disable warning C4477 (printf format warnings)
target_compile_options(kernel32_winetest PRIVATE /wd4477)
endif()
if(USE_CLANG_CL OR (NOT MSVC))
target_compile_options(kernel32_winetest PRIVATE "-Wno-format")
endif()

View File

@ -2,13 +2,6 @@
remove_definitions(-DWINVER=0x502 -D_WIN32_WINNT=0x502)
add_definitions(-DWINVER=0x602 -D_WIN32_WINNT=0x602)
if(MSVC)
# Disable warning C4477 (printf format warnings)
add_compile_flags("/wd4477")
elseif(GCC)
add_compile_flags("-Wno-format-overflow")
endif()
list(APPEND SOURCE
broadcast.c
class.c
@ -44,6 +37,13 @@ add_executable(user32_winetest
${PCH_SKIP_SOURCE}
resource.rc)
if(MSVC)
# Disable warning C4477 (printf format warnings)
target_compile_options(user32_winetest PRIVATE /wd4477)
elseif(GCC)
target_compile_options(user32_winetest PRIVATE -Wno-format-overflow)
endif()
add_pch(user32_winetest precomp.h "${PCH_SKIP_SOURCE}")
# some tests need to be run from an app compiled as GUI
set_module_type(user32_winetest win32gui)

View File

@ -24,6 +24,15 @@ function(add_target_property _module _propname)
set_property(TARGET ${_module} PROPERTY ${_propname} ${_newvalue})
endfunction()
# remove_target_compile_options
# Remove one option from the target COMPILE_OPTIONS property,
# previously added through add_compile_options
function(remove_target_compile_option _module _option)
get_target_property(_options ${_module} COMPILE_OPTIONS)
list(REMOVE_ITEM _options ${_option})
set_target_properties(${_module} PROPERTIES COMPILE_OPTIONS "${_options}")
endfunction()
# Wrapper functions for the important properties, using add_target_property
# where appropriate.
# Note that the functions for string properties take a single string
@ -63,14 +72,12 @@ endmacro(replace_compiler_option)
# add_compile_flags
# add_compile_flags_language
# replace_compile_flags
# Add or replace compiler flags in the global scope for either all source
# files or only those of the specified language.
#
# Examples:
# add_compile_flags("-pedantic -O5")
# add_compile_flags_language("-std=gnu99" "C")
# replace_compile_flags("-O5" "-O3")
function(add_compile_flags _flags)
if(${ARGC} GREATER 1)
message(FATAL_ERROR "Excess arguments to add_compile_flags! Args ${ARGN}")
@ -89,12 +96,3 @@ function(add_compile_flags_language _flags _lang)
set(CMAKE_${_lang}_FLAGS "${CMAKE_${_lang}_FLAGS} ${_flags}" PARENT_SCOPE)
endfunction()
macro(replace_compile_flags _oldflags _newflags)
if(NOT ${ARGC} EQUAL 2)
message(FATAL_ERROR "Wrong arguments to replace_compile_flags! Args ${ARGN}")
endif()
replace_compiler_option(CMAKE_C_FLAGS ${_oldflags} ${_newflags})
replace_compiler_option(CMAKE_CXX_FLAGS ${_oldflags} ${_newflags})
replace_compiler_option(CMAKE_ASM_FLAGS ${_oldflags} ${_newflags})
endmacro()

View File

@ -112,12 +112,12 @@ add_compile_flags("/wd4018")
# - C4700: uninitialized variable usage
# - C4715: 'function': not all control paths return a value
# - C4716: function must return a value
add_compile_flags("/we4013 /we4020 /we4022 /we4028 /we4047 /we4098 /we4101 /we4113 /we4129 /we4133 /we4163 /we4229 /we4311 /we4312 /we4313 /we4477 /we4603 /we4700 /we4715 /we4716")
add_compile_options(/we4013 /we4020 /we4022 /we4028 /we4047 /we4098 /we4101 /we4113 /we4129 /we4133 /we4163 /we4229 /we4311 /we4312 /we4313 /we4477 /we4603 /we4700 /we4715 /we4716)
# - C4189: local variable initialized but not referenced
# Not in Release mode
if(NOT CMAKE_BUILD_TYPE STREQUAL "Release")
add_compile_flags("/we4189")
add_compile_options(/we4189)
endif()
# Enable warnings above the default level, but don't treat them as errors:
@ -143,7 +143,7 @@ endif()
# Hotpatchable images
if(ARCH STREQUAL "i386")
if(NOT USE_CLANG_CL)
add_compile_flags("/hotpatch")
add_compile_options(/hotpatch)
endif()
set(_hotpatch_link_flag "/FUNCTIONPADMIN:5")
elseif(ARCH STREQUAL "amd64")

View File

@ -5,11 +5,6 @@ add_definitions(
include_directories(include)
if(MSVC)
# error C4312: 'type cast': conversion from 'unsigned long' to 'void *' of greater size
replace_compile_flags("/we4312" " ")
endif()
list(APPEND SOURCE
src/autofit/autofit.c
src/base/ftadvanc.c
@ -60,7 +55,10 @@ list(APPEND SOURCE
add_library(freetype ${SOURCE})
if(GCC)
if (MSVC)
# error C4312: 'type cast': conversion from 'unsigned long' to 'void *' of greater size
remove_target_compile_option(freetype "/we4312")
elseif(GCC)
target_compile_options(freetype PRIVATE -fno-builtin-malloc)
elseif(CLANG)
target_compile_options(freetype PRIVATE -Wno-tautological-constant-compare)

View File

@ -66,10 +66,10 @@ add_library(libxml2 ${SOURCE})
if(MSVC AND (NOT USE_CLANG_CL))
# Unreferenced local variable
replace_compile_flags("/we4101" " ")
remove_target_compile_option(libxml2 "/we4101")
target_compile_options(libxml2 PRIVATE "/wd4101")
# Local variable initialized but not referenced
replace_compile_flags("/we4189" " ")
remove_target_compile_option(libxml2 "/we4189")
else()
target_compile_options(libxml2 PRIVATE "-w")
endif()