no warnings from third parties

This commit is contained in:
veclav talica 2024-08-27 13:24:15 +03:00
parent 1bb33d3f34
commit 93f61018cd

View File

@ -45,11 +45,12 @@ else()
set(SYSTEM_SOURCE_FILES) set(SYSTEM_SOURCE_FILES)
endif() endif()
set(TWN_SOURCE_FILES set(TWN_THIRD_PARTY_SOURCE_FILES
third-party/physfs/extras/physfsrwops.c third-party/physfs/extras/physfsrwops.c
third-party/stb/stb_vorbis.c third-party/stb/stb_vorbis.c
third-party/glad/src/glad.c third-party/glad/src/glad.c)
set(TWN_SOURCE_FILES
townengine/twn_loop.c townengine/twn_loop.c
townengine/twn_main.c townengine/twn_main.c
townengine/config.h townengine/config.h
@ -68,11 +69,13 @@ set(TWN_SOURCE_FILES
list(TRANSFORM TWN_SOURCE_FILES PREPEND ${TWN_ROOT_DIR}/) list(TRANSFORM TWN_SOURCE_FILES PREPEND ${TWN_ROOT_DIR}/)
add_library(twn_third_parties STATIC ${TWN_THIRD_PARTY_SOURCE_FILES})
# base engine code, reused for games and tools # base engine code, reused for games and tools
if(TWN_FEATURE_DYNLIB_GAME) if(TWN_FEATURE_DYNLIB_GAME)
add_library(${TWN_TARGET} SHARED ${TWN_SOURCE_FILES}) add_library(${TWN_TARGET} SHARED ${TWN_SOURCE_FILES} ${twn_third_parties})
else() else()
add_library(${TWN_TARGET} STATIC ${TWN_SOURCE_FILES}) add_library(${TWN_TARGET} STATIC ${TWN_SOURCE_FILES} ${twn_third_parties})
endif() endif()
source_group(TREE ${TWN_ROOT_DIR} FILES ${TWN_SOURCE_FILES}) source_group(TREE ${TWN_ROOT_DIR} FILES ${TWN_SOURCE_FILES})
@ -96,25 +99,7 @@ set(PACKAGE_EXTENSION "btw" CACHE STRING
"File extension used to look for data archives") "File extension used to look for data archives")
function(give_options target) function(give_options_without_warnings target)
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
-Wpedantic
-Wshadow
-Wdouble-promotion
-Wconversion -Wno-sign-conversion
-Werror=vla
$<$<STREQUAL:${CMAKE_C_COMPILER_ID},Gnu>:-Wcast-align=strict>
$<$<STREQUAL:${CMAKE_C_COMPILER_ID},Clang>:${WARNING_FLAGS_CLANG}>)
set(BUILD_FLAGS set(BUILD_FLAGS
# these SHOULDN'T break anything... # these SHOULDN'T break anything...
-fno-math-errno -fno-math-errno
@ -144,7 +129,6 @@ function(give_options target)
-fsanitize=address) -fsanitize=address)
target_compile_options(${target} PRIVATE target_compile_options(${target} PRIVATE
${WARNING_FLAGS}
${BUILD_FLAGS} ${BUILD_FLAGS}
$<$<CONFIG:Release>:${BUILD_FLAGS_RELEASE}> $<$<CONFIG:Release>:${BUILD_FLAGS_RELEASE}>
$<$<CONFIG:Debug>:${BUILD_FLAGS_DEBUG}>) $<$<CONFIG:Debug>:${BUILD_FLAGS_DEBUG}>)
@ -162,6 +146,32 @@ function(give_options target)
endfunction() endfunction()
function(give_options target)
give_options_without_warnings(${target})
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
-Wpedantic
-Wshadow
-Wdouble-promotion
-Wconversion -Wno-sign-conversion
-Werror=vla
$<$<STREQUAL:${CMAKE_C_COMPILER_ID},Gnu>:-Wcast-align=strict>)
target_compile_options(${target} PRIVATE
${WARNING_FLAGS}
$<$<STREQUAL:${CMAKE_C_COMPILER_ID},Clang>:${WARNING_FLAGS_CLANG}>)
endfunction()
function(include_deps target) function(include_deps target)
# header-only libraries should be marked as "system includes" # header-only libraries should be marked as "system includes"
# to suppress compiler warnings in their code (it's not my problem after all) # to suppress compiler warnings in their code (it's not my problem after all)
@ -273,9 +283,14 @@ function(use_townengine target sources output_directory data_dir)
endif() endif()
endfunction() endfunction()
give_options_without_warnings(twn_third_parties)
include_deps(twn_third_parties)
link_deps(twn_third_parties)
give_options(${TWN_TARGET}) give_options(${TWN_TARGET})
include_deps(${TWN_TARGET}) include_deps(${TWN_TARGET})
link_deps(${TWN_TARGET}) link_deps(${TWN_TARGET})
target_link_libraries(${TWN_TARGET} PUBLIC twn_third_parties)
# build the testgame if this cmake list is built directly # build the testgame if this cmake list is built directly
if(${CMAKE_PROJECT_NAME} MATCHES townengine) if(${CMAKE_PROJECT_NAME} MATCHES townengine)