mirror of
https://github.com/reactos/reactos.git
synced 2025-07-29 16:11:42 +00:00
[CMAKE] Get rid of replace_compile_flags
Introduce a finer-grained remove_target_compile_option instead
This commit is contained in:
parent
b52fa999eb
commit
7e116f0ef3
27 changed files with 138 additions and 144 deletions
|
@ -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()
|
||||
|
||||
|
|
|
@ -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")
|
||||
|
|
10
sdk/lib/3rdparty/freetype/CMakeLists.txt
vendored
10
sdk/lib/3rdparty/freetype/CMakeLists.txt
vendored
|
@ -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)
|
||||
|
|
4
sdk/lib/3rdparty/libxml2/CMakeLists.txt
vendored
4
sdk/lib/3rdparty/libxml2/CMakeLists.txt
vendored
|
@ -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()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue