From 189f1d4dfb0c9c78c3a3bed22f76fa4ed2e0196a Mon Sep 17 00:00:00 2001 From: Isaac Aronson Date: Tue, 30 Apr 2024 02:42:05 -0500 Subject: [PATCH] Support real platforms with static binaries --- .gitmodules | 2 +- countchan.cpp | 1 + meson.build | 22 ++++++++++++++++++++-- subprojects/{libopenmpt => openmpt} | 0 4 files changed, 22 insertions(+), 3 deletions(-) rename subprojects/{libopenmpt => openmpt} (100%) diff --git a/.gitmodules b/.gitmodules index afc4650..ed3f11b 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ [submodule "subprojects/libopenmpt"] - path = subprojects/libopenmpt + path = subprojects/openmpt url = https://gitea.com/Apotris/libopenmpt.git diff --git a/countchan.cpp b/countchan.cpp index 3972054..8c67f01 100644 --- a/countchan.cpp +++ b/countchan.cpp @@ -1,5 +1,6 @@ #include #include +#include #include #include diff --git a/meson.build b/meson.build index 54467fb..cf1f92b 100644 --- a/meson.build +++ b/meson.build @@ -1,4 +1,4 @@ -project('countchan', 'cpp', default_options : ['cpp_std=c++17', 'buildtype=debugoptimized', 'b_lto=true', 'warning_level=1']) +project('countchan', 'cpp', default_options : ['cpp_std=c++17', 'buildtype=minsize', 'default_library=static', 'b_lto=true', 'warning_level=1']) add_global_arguments('-fexceptions', language : ['cpp']) add_global_arguments('-frtti', language : ['cpp']) @@ -7,9 +7,27 @@ mpt = dependency('openmpt', static : true, fallback : ['openmpt', 'openmpt_dep'] sources = files('countchan.cpp') +if meson.get_compiler('cpp').get_id() != 'clang' + link_args = [ + '-static-libgcc', + '-static-libstdc++', + ] +else + link_args = [] +endif + +if host_machine.system() == 'windows' + link_args += '-Wl,-Bstatic,--whole-archive' + link_args += '-lwinpthread' + link_args += '-Wl,--no-whole-archive' +elif host_machine.system() == 'darwin' + link_args += '-mmacosx-version-min=10.15' +endif + executable('countchan', - dependencies : [mpt], + dependencies : [dependency('threads'), mpt], win_subsystem : 'console', + link_args : link_args, sources : sources ) diff --git a/subprojects/libopenmpt b/subprojects/openmpt similarity index 100% rename from subprojects/libopenmpt rename to subprojects/openmpt