mirror of
https://github.com/LostArtefacts/TRX.git
synced 2025-04-28 12:47:58 +03:00
build: add meson option to disable static linking
In the current state, meson is searching for static dependencies, and if it does not find them, it will link dynamically anyway. On a system without any static libraries, meson produces 90 warnings at setup phase like this one : > WARNING: Static library 'avcodec' not found for dependency > 'libavcodec', may not be statically linked This commit is adding a meson *staticdeps* option (defaulting to true). This allow us to disable static dependencies search if we know that we don't want to link statically. You can disable static linking by using this option at setup phase : > $ meson setup [...] -Dstaticdeps=false Linking dynamically will require two additional dependencies : * zlib * glibc's libm Without linking to zlib, build is failing with : > [...]x86_64-pc-linux-gnu/bin/ld: > TR1X.p/src_game_savegame_savegame_bson.c.o: undefined reference > to symbol 'compressBound@@ZLIB_1.2.0' > [..]x86_64-pc-linux-gnu/bin/ld: > /lib64/libz.so.1: error adding symbols: DSO missing from command line > collect2: error: ld returned 1 exit status Without linking to libm, build is failing with : > [...]x86_64-pc-linux-gnu/bin/ld: > TR1X.p/src_game_screen.c.o: undefined reference > to symbol 'round@@GLIBC_2.2.5' > [...]x86_64-pc-linux-gnu/bin/ld: > /lib64/libm.so.6: error adding symbols: DSO missing from command line > collect2: error: ld returned 1 exit status Signed-off-by: Fabrice Delliaux <netbox253@gmail.com>
This commit is contained in:
parent
420143d76e
commit
f846c693f2
2 changed files with 20 additions and 6 deletions
25
meson.build
25
meson.build
|
@ -22,19 +22,28 @@ build_opts = [
|
|||
c_opts = []
|
||||
add_project_arguments(build_opts + c_opts, language: 'c')
|
||||
|
||||
staticdeps = get_option('staticdeps')
|
||||
|
||||
if host_machine.system() == 'windows'
|
||||
dep_opengl32 = c_compiler.find_library('opengl32')
|
||||
else
|
||||
dep_opengl32 = dependency('GL')
|
||||
endif
|
||||
|
||||
dep_avcodec = dependency('libavcodec', static: true)
|
||||
dep_avformat = dependency('libavformat', static: true)
|
||||
dep_avutil = dependency('libavutil', static: true)
|
||||
dep_swscale = dependency('libswscale', static: true)
|
||||
dep_swresample = dependency('libswresample', static: true)
|
||||
null_dep = dependency('', required: false)
|
||||
|
||||
dep_sdl2 = dependency('SDL2', static: true)
|
||||
dep_avcodec = dependency('libavcodec', static: staticdeps)
|
||||
dep_avformat = dependency('libavformat', static: staticdeps)
|
||||
dep_avutil = dependency('libavutil', static: staticdeps)
|
||||
dep_swscale = dependency('libswscale', static: staticdeps)
|
||||
dep_swresample = dependency('libswresample', static: staticdeps)
|
||||
|
||||
dep_zlib = null_dep
|
||||
if not staticdeps
|
||||
dep_zlib = dependency('zlib', static: staticdeps)
|
||||
endif
|
||||
|
||||
dep_sdl2 = dependency('SDL2', static: staticdeps)
|
||||
|
||||
# autogenerated files
|
||||
resources = []
|
||||
|
@ -79,6 +88,9 @@ if host_machine.system() == 'windows'
|
|||
link_args = ['-static']
|
||||
else
|
||||
link_args = []
|
||||
if not staticdeps
|
||||
link_args += ['-lm']
|
||||
endif
|
||||
endif
|
||||
|
||||
sources = [
|
||||
|
@ -283,6 +295,7 @@ dependencies = [
|
|||
dep_sdl2,
|
||||
dep_swresample,
|
||||
dep_swscale,
|
||||
dep_zlib,
|
||||
]
|
||||
|
||||
executable(
|
||||
|
|
1
meson.options
Normal file
1
meson.options
Normal file
|
@ -0,0 +1 @@
|
|||
option('staticdeps', type: 'boolean', value: true, description: 'Try to build against static dependencies. default: true')
|
Loading…
Add table
Add a link
Reference in a new issue