From c9f4f85fcec4dee72937144426b821da3ccab857 Mon Sep 17 00:00:00 2001 From: veclavtalica Date: Sun, 28 Jul 2024 21:47:57 +0300 Subject: [PATCH] have avx enabled by default --- CMakeLists.txt | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cbd9348..73a5efe 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -85,9 +85,18 @@ if(MSVC) target_compile_options(${PROJECT_NAME} PRIVATE /W4 $<$:/GL>) + target_link_options(${PROJECT_NAME} PRIVATE $<$:/LTCG>) + else() + set(WARNING_FLAGS_CLANG + -Weverything + -Wno-padded + -Wno-declaration-after-statement + -Wno-unsafe-buffer-usage + -Wno-unused-command-line-argument) + set(WARNING_FLAGS -Wall -Wextra @@ -95,7 +104,9 @@ else() -Wshadow -Wdouble-promotion -Wconversion -Wno-sign-conversion - -Werror=vla) + -Werror=vla + $<$:${WARNING_FLAGS_CLANG}>) + set(BUILD_FLAGS # these SHOULDN'T break anything... -fno-math-errno @@ -103,15 +114,18 @@ else() -fno-signed-zeros -fno-trapping-math -freciprocal-math) + set(BUILD_FLAGS_RELEASE -O3 -flto - -Wl,-gc-sections + -mavx -mavx2 + -Wl,--gc-sections -fdata-sections -ffunction-sections -funroll-loops -fomit-frame-pointer - -fallow-store-data-races) + $<$:-fallow-store-data-races>) + set(BUILD_FLAGS_DEBUG -O0 -g3 @@ -120,11 +134,13 @@ else() -fstack-protector-all -fsanitize=undefined -fsanitize=address) + target_compile_options(${PROJECT_NAME} PRIVATE ${WARNING_FLAGS} ${BUILD_FLAGS} $<$:${BUILD_FLAGS_RELEASE}> $<$:${BUILD_FLAGS_DEBUG}>) + target_link_options(${PROJECT_NAME} PRIVATE ${BUILD_FLAGS} $<$:${BUILD_FLAGS_RELEASE}> @@ -137,19 +153,15 @@ target_compile_definitions(${PROJECT_NAME} PRIVATE APP_NAME="${APP_NAME}" PACKAGE_EXTENSION="${PACKAGE_EXTENSION}") -target_include_directories(${PROJECT_NAME} - PRIVATE - third-party/physfs/src - third-party/physfs/extras - third-party/libxm/include - third-party/glad/include -) - # header-only libraries should be marked as "system includes" # to suppress compiler warnings in their code (it's not my problem after all) target_include_directories(${PROJECT_NAME} SYSTEM PRIVATE + third-party/physfs/src + third-party/physfs/extras + third-party/libxm/include + third-party/glad/include third-party/stb )