build: only use -Werror=lto-type-mismatch on gcc

Only pass -Werror=lto-type-mismatch to gcc, clang does not have this
option and throws a warning.

Also quote some barewords in if() statements.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
This commit is contained in:
Rafael Kitover 2024-04-03 10:30:04 +00:00
parent 4ace296b3a
commit 045c98d8fa
No known key found for this signature in database
GPG Key ID: 08AB596679D86240
1 changed files with 10 additions and 5 deletions

View File

@ -27,7 +27,7 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
endif()
# check if ssp flags are supported.
if(CMAKE_BUILD_TYPE STREQUAL Debug)
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
check_cxx_compiler_flag(-fstack-protector-strong STACK_PROTECTOR_SUPPORTED)
if(STACK_PROTECTOR_SUPPORTED)
@ -44,14 +44,14 @@ if(NOT ENABLE_ASM) # inline asm is not allowed with -fPIC
add_compile_options(-fPIC)
endif()
if(CMAKE_BUILD_TYPE STREQUAL Debug)
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
add_compile_options(-ggdb3 -Og -fno-omit-frame-pointer -Wall -Wextra)
else()
add_compile_options(-Ofast -fomit-frame-pointer)
endif()
# for some reason this is necessary
if(CMAKE_SYSTEM_NAME STREQUAL FreeBSD)
if(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
include_directories(/usr/local/include)
endif()
@ -60,5 +60,10 @@ if(VBAM_STATIC)
endif()
# To support LTO, this must always fail.
add_compile_options(-Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing)
add_link_options( -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing)
add_compile_options(-Werror=odr -Werror=strict-aliasing)
add_link_options( -Werror=odr -Werror=strict-aliasing)
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
add_compile_options(-Werror=lto-type-mismatch)
add_link_options( -Werror=lto-type-mismatch)
endif()