mkxp-z/meson.build

198 lines
5 KiB
Meson
Raw Normal View History

2023-05-04 16:42:31 -04:00
project('mkxp-z', 'c', 'cpp', version: '2.4.2', meson_version: '>=0.56.0', default_options: ['cpp_std=c++14', 'buildtype=release'])
2019-07-29 07:56:45 -04:00
host_system = host_machine.system()
2020-12-30 18:21:59 -05:00
if host_system == 'darwin'
error('\nThis Meson project no longer supports macOS. Please use the Xcode project instead.')
endif
xxd = find_program('xxd', native: true)
git_hash = run_command('git', 'rev-parse', '--short', 'HEAD').stdout().strip()
2020-11-22 03:48:03 -05:00
compilers = {'cpp': meson.get_compiler('cpp')}
2019-12-17 22:23:13 -05:00
global_sources = []
global_dependencies = []
global_include_dirs = []
global_args = []
global_link_args = []
2020-02-28 03:23:16 -05:00
sizeof = {'void*': compilers['cpp'].sizeof('void*'),
'long': compilers['cpp'].sizeof('long')
}
win64 = (sizeof['void*'] != sizeof['long'])
global_args += '-DMKXPZ_BUILD_MESON'
2020-12-31 17:26:14 -05:00
global_args += '-DMKXPZ_VERSION="@0@"'.format(meson.project_version())
global_args += '-DMKXPZ_GIT_HASH="@0@"'.format(git_hash)
2021-03-28 15:32:24 -04:00
global_args += '-DHAVE_NANOSLEEP'
2019-09-04 05:48:23 -04:00
# ====================
# Ext libs
# ====================
2020-02-28 03:23:16 -05:00
# STEAMWORKS
steamworks = false
steamworks_path = get_option('steamworks_path')
if steamworks_path != ''
libname = 'steam_api'
if host_system == 'linux'
if sizeof['void*'] == 4
bindir = 'linux32'
else
bindir = 'linux64'
endif
2020-12-30 18:21:59 -05:00
else
2020-02-28 03:23:16 -05:00
if win64 == true
bindir = 'win64'
libname += '64'
else
bindir = ''
endif
endif
steam_libpath = steamworks_path + '/redistributable_bin/' + bindir
steamlib = compilers['cpp'].find_library(libname, required: false, dirs: [steam_libpath])
if steamlib.found() == true
global_include_dirs += include_directories('steamshim')
global_args += '-DMKXPZ_STEAM'
global_sources += 'steamshim/steamshim_child.c'
steamworks = true
2020-02-28 03:23:16 -05:00
endif
endif
# GLES
gfx_backend = get_option('gfx_backend')
if gfx_backend == 'gles'
2020-11-16 20:26:49 -05:00
# Needs to be manually set up for now
global_args += '-DGLES2_HEADER'
elif gfx_backend == 'gl'
global_dependencies += dependency('gl')
# boop
endif
2019-09-04 05:48:23 -04:00
# ====================
# Main source
# ====================
# Suppress warnings
2021-05-23 21:55:02 -04:00
global_args += ['-Wno-non-virtual-dtor', '-Wno-reorder', '-Wno-uninitialized', '-Wno-unknown-pragmas', '-Wno-stringop-truncation']
2020-11-22 03:48:03 -05:00
if compilers['cpp'].get_id() == 'clang'
2019-12-17 22:23:13 -05:00
global_args += ['-Wno-undefined-var-template', '-Wno-delete-non-abstract-non-virtual-dtor']
endif
if host_system == 'windows'
if compilers['cpp'].get_id() != 'clang'
global_args += '-masm=intel'
endif
endif
2019-09-04 05:48:23 -04:00
# Decide whether or not to use MiniFFI
miniffi = get_option('use_miniffi')
if miniffi == true
2020-12-31 16:58:47 -05:00
miniffi = true
global_args += '-DMKXPZ_MINIFFI'
endif
# Defines
if get_option('workdir_current')
global_args += '-DWORKDIR_CURRENT'
2019-07-29 08:20:40 -04:00
endif
if get_option('cxx11_experimental') == true
global_args += '-DMKXPZ_EXP_FS'
endif
2020-04-29 21:59:19 -04:00
if get_option('force32') == true
global_args += '-m32'
endif
2020-02-28 05:35:14 -05:00
build_static = false
2022-01-19 04:06:43 -05:00
if get_option('static_executable') == true
2020-02-28 05:35:14 -05:00
build_static = true
endif
global_args += '-DMKXPZ_INIT_GL_LATER'
2019-07-29 07:56:45 -04:00
subdir('src')
2019-07-31 08:47:44 -04:00
subdir('binding')
2019-07-29 07:56:45 -04:00
subdir('shader')
subdir('assets')
global_include_dirs += include_directories('src', 'binding')
2019-08-19 08:59:35 -04:00
2020-04-29 23:27:28 -04:00
rpath = ''
2019-07-29 07:56:45 -04:00
if host_system == 'windows'
windows_resource_directory = '../' + get_option('windows_resource_directory')
subdir('windows')
global_sources += windows_resources
global_include_dirs += include_directories('windows')
2019-10-22 02:30:07 -04:00
else
subdir('linux')
2020-04-29 23:27:28 -04:00
rpath = '$ORIGIN/lib'
if get_option('appimage') != true
2020-04-29 23:46:05 -04:00
if sizeof['long'] == 8 and get_option('force32') != true
2020-04-29 23:27:28 -04:00
rpath += '64'
else
rpath += '32'
endif
endif
2019-07-29 07:56:45 -04:00
endif
exe_name = meson.project_name()
2022-01-19 04:06:43 -05:00
if host_system == 'linux' and get_option('appimage') == false
exe_name += '.' + host_machine.cpu()
endif
if steamworks == true
exe_name = 'steam_' + exe_name
la = ''
if build_static == true
2022-01-19 04:06:43 -05:00
if host_system == 'windows'
la = '-static'
else
la = '-static-libgcc -static-libstdc++'
endif
endif
shim_args = [
'-DGAME_LAUNCH_NAME="' + exe_name + '"',
'-I' + steamworks_path + '/public'
]
if get_option('steam_appid') != ''
shim_args += '-DSTEAM_APPID=' + get_option('steam_appid')
endif
2021-03-15 23:13:25 -04:00
if get_option('steamshim_debug') == true
2020-03-11 13:55:47 -04:00
shim_args += '-DSTEAMSHIM_DEBUG'
2022-07-05 21:37:18 -04:00
shim_ws = 'console'
else
shim_ws = 'windows'
2020-03-11 13:55:47 -04:00
endif
executable(meson.project_name(),
sources: files('steamshim/steamshim_parent.cpp'),
dependencies: steamlib,
cpp_args: shim_args,
link_args: la.split(),
2022-07-05 21:37:18 -04:00
win_subsystem: shim_ws,
install: (host_system != 'windows'))
endif
executable(exe_name,
sources: global_sources,
dependencies: global_dependencies,
include_directories: global_include_dirs,
2020-04-29 23:27:28 -04:00
install_rpath: rpath,
link_args: global_link_args,
cpp_args: global_args,
objc_args: global_args,
objcpp_args: global_args,
2022-04-02 20:58:52 -04:00
win_subsystem: 'windows',
2019-10-22 02:30:07 -04:00
install: (host_system != 'windows')
2019-07-29 07:56:45 -04:00
)