2024-03-13 18:13:55 +00:00
|
|
|
if(X86_32 OR X86_64)
|
|
|
|
add_compile_options(-mfpmath=sse -msse2)
|
|
|
|
endif()
|
|
|
|
|
2024-03-30 21:57:26 +00:00
|
|
|
if(UPSTREAM_RELEASE)
|
|
|
|
if(X86_64)
|
|
|
|
# Require and optimize for Core2 level support, tune for generic.
|
|
|
|
add_compile_options(-march=core2 -mtune=generic)
|
|
|
|
elseif(X86_32)
|
|
|
|
# Optimize for pentium-mmx and tune for generic for older builds.
|
|
|
|
add_compile_options(-march=pentium-mmx -mtune=generic)
|
|
|
|
endif()
|
2024-03-13 18:13:55 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
# Common flags.
|
|
|
|
add_compile_options(
|
|
|
|
-pipe
|
2024-03-30 20:14:32 +00:00
|
|
|
$<$<COMPILE_LANGUAGE:CXX>:-Wno-deprecated-copy>
|
2024-03-13 18:13:55 +00:00
|
|
|
-Wformat
|
|
|
|
-Wformat-security
|
|
|
|
-fdiagnostics-color=always
|
|
|
|
)
|
|
|
|
|
2024-03-30 20:14:32 +00:00
|
|
|
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
|
|
|
add_compile_options(-Wno-unused-command-line-argument)
|
2024-04-15 23:30:34 +00:00
|
|
|
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
|
|
|
add_compile_options(-feliminate-unused-debug-types)
|
2024-03-30 20:14:32 +00:00
|
|
|
endif()
|
|
|
|
|
2024-03-13 18:13:55 +00:00
|
|
|
# check if ssp flags are supported.
|
2024-04-03 10:30:04 +00:00
|
|
|
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
2024-03-13 18:13:55 +00:00
|
|
|
check_cxx_compiler_flag(-fstack-protector-strong STACK_PROTECTOR_SUPPORTED)
|
|
|
|
|
|
|
|
if(STACK_PROTECTOR_SUPPORTED)
|
|
|
|
add_compile_options(-fstack-protector-strong)
|
|
|
|
|
|
|
|
check_cxx_compiler_flag("--param ssp-buffer-size=4" SSP_BUFFER_SIZE_SUPPORTED)
|
|
|
|
if(SSP_BUFFER_SIZE_SUPPORTED)
|
|
|
|
add_compile_options(--param ssp-buffer-size=4)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(NOT ENABLE_ASM) # inline asm is not allowed with -fPIC
|
|
|
|
add_compile_options(-fPIC)
|
|
|
|
endif()
|
|
|
|
|
2024-04-03 10:30:04 +00:00
|
|
|
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
2024-09-29 20:59:19 +00:00
|
|
|
add_compile_options(-ggdb3 -fno-omit-frame-pointer -Wall -Wextra)
|
2024-03-13 18:13:55 +00:00
|
|
|
else()
|
|
|
|
add_compile_options(-Ofast -fomit-frame-pointer)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# for some reason this is necessary
|
2024-04-03 10:30:04 +00:00
|
|
|
if(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
|
2024-03-13 18:13:55 +00:00
|
|
|
include_directories(/usr/local/include)
|
|
|
|
endif()
|
2024-03-30 18:06:25 +00:00
|
|
|
|
|
|
|
if(VBAM_STATIC)
|
2024-04-10 22:52:35 +00:00
|
|
|
if(APPLE)
|
|
|
|
add_link_options(-static-libstdc++)
|
|
|
|
else()
|
2024-04-12 15:44:27 +00:00
|
|
|
add_link_options(-static-libgcc -static-libstdc++ -Wl,-Bstatic -lstdc++ -lpthread)
|
2024-04-10 22:52:35 +00:00
|
|
|
endif()
|
2024-03-30 18:06:25 +00:00
|
|
|
endif()
|
2024-03-30 21:57:26 +00:00
|
|
|
|
|
|
|
# To support LTO, this must always fail.
|
2024-04-03 10:30:04 +00:00
|
|
|
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()
|