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 )