diff --git a/CMakeLists.txt b/CMakeLists.txt index c92d173..c8722ba 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -45,11 +45,12 @@ else() set(SYSTEM_SOURCE_FILES) endif() -set(TWN_SOURCE_FILES +set(TWN_THIRD_PARTY_SOURCE_FILES third-party/physfs/extras/physfsrwops.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_main.c townengine/config.h @@ -68,11 +69,13 @@ set(TWN_SOURCE_FILES 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 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() - add_library(${TWN_TARGET} STATIC ${TWN_SOURCE_FILES}) + add_library(${TWN_TARGET} STATIC ${TWN_SOURCE_FILES} ${twn_third_parties}) endif() 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") -function(give_options 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 - $<$:-Wcast-align=strict> - $<$:${WARNING_FLAGS_CLANG}>) - +function(give_options_without_warnings target) set(BUILD_FLAGS # these SHOULDN'T break anything... -fno-math-errno @@ -144,7 +129,6 @@ function(give_options target) -fsanitize=address) target_compile_options(${target} PRIVATE - ${WARNING_FLAGS} ${BUILD_FLAGS} $<$:${BUILD_FLAGS_RELEASE}> $<$:${BUILD_FLAGS_DEBUG}>) @@ -162,6 +146,32 @@ function(give_options target) 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 + $<$:-Wcast-align=strict>) + + target_compile_options(${target} PRIVATE + ${WARNING_FLAGS} + $<$:${WARNING_FLAGS_CLANG}>) +endfunction() + + function(include_deps target) # header-only libraries should be marked as "system includes" # 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() endfunction() +give_options_without_warnings(twn_third_parties) +include_deps(twn_third_parties) +link_deps(twn_third_parties) + give_options(${TWN_TARGET}) include_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 if(${CMAKE_PROJECT_NAME} MATCHES townengine)