mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
chore(build): Migrate existing warning handling to new warnings project
This commit is contained in:
parent
df58c35998
commit
0afc11fafc
|
@ -31,7 +31,7 @@ option(SVGZ_ICON "Compress the SVG icon of qTox" ON)
|
|||
option(ASAN "Compile with AddressSanitizer" OFF)
|
||||
option(TSAN "Compile with ThreadSanitizer" OFF)
|
||||
option(DESKTOP_NOTIFICATIONS "Use snorenotify for desktop notifications" OFF)
|
||||
option(STRICT_OPTIONS "Enable strict compile options, used by CI" OFF)
|
||||
option(STRICT_OPTIONS "Error on compile warning, used by CI" OFF)
|
||||
|
||||
# process generated files if cmake >= 3.10
|
||||
if(POLICY CMP0071)
|
||||
|
@ -93,27 +93,8 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti")
|
|||
# Hardening flags (ASLR, warnings, etc)
|
||||
set(POSITION_INDEPENDENT_CODE True)
|
||||
|
||||
include(CheckCXXCompilerFlag)
|
||||
CHECK_CXX_COMPILER_FLAG(-Wweak-vtables COMPILER_SUPPORTS_WARNING_WEAK_VTABLES)
|
||||
if(COMPILER_SUPPORTS_WARNING_WEAK_VTABLES)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wweak-vtables")
|
||||
endif()
|
||||
|
||||
# Extra-strict compile options that we don't want to subject all users to by default
|
||||
if (STRICT_OPTIONS)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
|
||||
endif()
|
||||
|
||||
# avoid timestamps in binary for reproducible builds, not added until GCC 4.9
|
||||
include(CheckCXXCompilerFlag)
|
||||
CHECK_CXX_COMPILER_FLAG(-Wdate-time COMPILER_SUPPORTS_WDATE_TIME)
|
||||
if (COMPILER_SUPPORTS_WDATE_TIME)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wdate-time")
|
||||
endif()
|
||||
|
||||
if (NOT WIN32 AND NOT HAIKU)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fstack-protector-all")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wstack-protector")
|
||||
endif()
|
||||
|
||||
if (UNIX AND NOT APPLE)
|
||||
|
@ -123,7 +104,6 @@ endif()
|
|||
|
||||
include(CheckAtomic)
|
||||
|
||||
|
||||
# Use ccache when available to speed up builds.
|
||||
if (USE_CCACHE)
|
||||
find_program(CCACHE_FOUND ccache)
|
||||
|
|
|
@ -11,6 +11,10 @@ if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
|||
endif()
|
||||
endif()
|
||||
|
||||
include(CheckCXXCompilerFlag)
|
||||
CHECK_CXX_COMPILER_FLAG(-Wweak-vtables COMPILER_SUPPORTS_WARNING_WEAK_VTABLES)
|
||||
CHECK_CXX_COMPILER_FLAG(-Wdate-time COMPILER_SUPPORTS_WDATE_TIME)
|
||||
|
||||
target_compile_options(${PROJECT_NAME} INTERFACE
|
||||
$<$<OR:$<BOOL:${CLANG}>,$<CXX_COMPILER_ID:GNU>>:
|
||||
-fno-common;
|
||||
|
@ -20,7 +24,6 @@ target_compile_options(${PROJECT_NAME} INTERFACE
|
|||
-Wall;
|
||||
-Wcast-align;
|
||||
-Wdouble-promotion;
|
||||
-Werror;
|
||||
-Wextra;
|
||||
-Wformat=2;
|
||||
-Wmissing-declarations;
|
||||
|
@ -72,4 +75,16 @@ target_compile_options(${PROJECT_NAME} INTERFACE
|
|||
# loss of data # This one is sort of required for gtest.
|
||||
/WX;
|
||||
>
|
||||
$<$<BOOL:${STRICT_OPTIONS}>:
|
||||
-Werror;
|
||||
>
|
||||
$<$<BOOL:${COMPILER_SUPPORTS_WARNING_WEAK_VTABLES}>:
|
||||
-Wweak-vtables; # https://llvm.org/docs/CodingStandards.html#provide-a-virtual-method-anchor-for-classes-in-headers
|
||||
>
|
||||
$<$<BOOL:${COMPILER_SUPPORTS_WDATE_TIME}>:
|
||||
-Wdate-time; # avoid timestamps in binary for reproducible builds, not added until GCC 4.9
|
||||
>
|
||||
$<$<AND:$<NOT:$<BOOL:${WIN32}>>,$<NOT:$<BOOL:${HAIKU}>>>:
|
||||
-Wstack-protector;
|
||||
>
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue
Block a user