[CMAKE] Get rid of add_compile_flags

Use add_compile_options and the like instead
This commit is contained in:
Jérôme Gardou 2020-09-21 12:16:02 +02:00 committed by Jérôme Gardou
parent 84621b3634
commit 00ed72d7e8
26 changed files with 158 additions and 198 deletions

View file

@ -35,18 +35,17 @@ if(USE_DUMMY_PSEH)
endif()
if(STACK_PROTECTOR)
add_compile_flags(${MODULE} "-fstack-protector-all")
add_compile_options(-fstack-protector-all)
endif()
# Compiler Core
add_compile_flags("-pipe -fms-extensions -fno-strict-aliasing")
add_compile_options(-pipe -fms-extensions -fno-strict-aliasing)
# Prevent GCC from searching any of the default directories.
# The case for C++ is handled through the reactos_c++ INTERFACE library
add_compile_options("$<$<NOT:$<COMPILE_LANGUAGE:CXX>>:-nostdinc>")
add_compile_flags("-mstackrealign")
add_compile_flags("-fno-aggressive-loop-optimizations")
add_compile_options(-mstackrealign -fno-aggressive-loop-optimizations)
if(CMAKE_C_COMPILER_ID STREQUAL "Clang")
add_compile_options("$<$<COMPILE_LANGUAGE:C>:-std=gnu99;-Wno-microsoft>")
@ -72,81 +71,81 @@ endif()
# Debugging
if(NOT CMAKE_BUILD_TYPE STREQUAL "Release")
if(SEPARATE_DBG)
add_compile_flags("-gdwarf-2 -ggdb")
add_compile_options(-gdwarf-2 -ggdb)
else()
add_compile_flags("-gdwarf-2 -gstrict-dwarf")
if(NOT CMAKE_C_COMPILER_ID STREQUAL "Clang")
add_compile_flags("-femit-struct-debug-detailed=none -feliminate-unused-debug-symbols")
add_compile_options(-gdwarf-2 -gstrict-dwarf)
if(NOT CMAKE_C_COMPILER_ID STREQUAL Clang)
add_compile_options(-femit-struct-debug-detailed=none -feliminate-unused-debug-symbols)
endif()
endif()
endif()
# Tuning
if(ARCH STREQUAL "i386")
add_compile_flags("-march=${OARCH} -mtune=${TUNE}")
add_compile_options(-march=${OARCH} -mtune=${TUNE})
else()
add_compile_flags("-march=${OARCH}")
add_compile_options(-march=${OARCH})
endif()
# Warnings, errors
if((NOT CMAKE_BUILD_TYPE STREQUAL "Release") AND (NOT CMAKE_C_COMPILER_ID STREQUAL "Clang"))
add_compile_flags("-Werror")
if((NOT CMAKE_BUILD_TYPE STREQUAL "Release") AND (NOT CMAKE_C_COMPILER_ID STREQUAL Clang))
add_compile_options(-Werror)
endif()
add_compile_flags("-Wall -Wpointer-arith")
add_compile_flags("-Wno-char-subscripts -Wno-multichar -Wno-unused-value")
add_compile_flags("-Wno-unused-const-variable")
add_compile_flags("-Wno-unused-local-typedefs")
add_compile_flags("-Wno-deprecated")
add_compile_options(-Wall -Wpointer-arith)
add_compile_options(-Wno-char-subscripts -Wno-multichar -Wno-unused-value)
add_compile_options(-Wno-unused-const-variable)
add_compile_options(-Wno-unused-local-typedefs)
add_compile_options(-Wno-deprecated)
if(NOT CMAKE_C_COMPILER_ID STREQUAL "Clang")
add_compile_flags("-Wno-maybe-uninitialized")
add_compile_options(-Wno-maybe-uninitialized)
endif()
if(ARCH STREQUAL "amd64")
add_compile_flags("-Wno-format")
add_compile_options(-Wno-format)
elseif(ARCH STREQUAL "arm")
add_compile_flags("-Wno-attributes")
add_compile_options(-Wno-attributes)
endif()
# Optimizations
# FIXME: Revisit this to see if we even need these levels
if(CMAKE_BUILD_TYPE STREQUAL "Release")
add_compile_flags("-O2 -DNDEBUG")
add_compile_options(-O2 -DNDEBUG)
else()
if(OPTIMIZE STREQUAL "1")
add_compile_flags("-Os -ftracer")
add_compile_options(-Os -ftracer)
elseif(OPTIMIZE STREQUAL "2")
add_compile_flags("-Os")
add_compile_options(-Os)
elseif(OPTIMIZE STREQUAL "3")
add_compile_flags("-Og")
add_compile_options(-Og)
elseif(OPTIMIZE STREQUAL "4")
add_compile_flags("-O1")
add_compile_options(-O1)
elseif(OPTIMIZE STREQUAL "5")
add_compile_flags("-O2")
add_compile_options(-O2)
elseif(OPTIMIZE STREQUAL "6")
add_compile_flags("-O3")
add_compile_options(-O3)
elseif(OPTIMIZE STREQUAL "7")
add_compile_flags("-Ofast")
add_compile_options(-Ofast)
endif()
endif()
# Link-time code generation
if(LTCG)
add_compile_flags("-flto -fno-fat-lto-objects")
add_compile_options(-flto -fno-fat-lto-objects)
endif()
if(ARCH STREQUAL "i386")
add_compile_flags("-fno-optimize-sibling-calls -fno-omit-frame-pointer")
add_compile_options(-fno-optimize-sibling-calls -fno-omit-frame-pointer)
if(NOT CMAKE_C_COMPILER_ID STREQUAL "Clang")
add_compile_flags("-mpreferred-stack-boundary=3 -fno-set-stack-executable")
add_compile_options(-mpreferred-stack-boundary=3 -fno-set-stack-executable)
endif()
# FIXME: this doesn't work. CMAKE_BUILD_TYPE is always "Debug"
if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
add_compile_flags("-momit-leaf-frame-pointer")
add_compile_options(-momit-leaf-frame-pointer)
endif()
elseif(ARCH STREQUAL "amd64")
add_compile_flags("-mpreferred-stack-boundary=4")
add_compile_options(-mpreferred-stack-boundary=4)
endif()
# Other