mkxp-z/meson.build

141 lines
4.4 KiB
Meson
Raw Normal View History

project('mkxp-z', 'cpp', 'objc', 'objcpp', version: '1.2.0', meson_version: '>=0.47.0', default_options: ['cpp_std=c++11', 'buildtype=release', 'warning_level=0'])
2019-07-29 07:56:45 -04:00
minimum_macos_version = get_option('macos_min_version')
2019-08-31 19:12:54 -04:00
2019-08-04 12:00:20 -04:00
xxd = find_program('xxd', native: true)
objfw = find_program('objfw-config', native: true)
2019-07-29 07:56:45 -04:00
host_system = host_machine.system()
compilers = {'cpp': meson.get_compiler('cpp'), 'objc': meson.get_compiler('objc'), 'objcpp': meson.get_compiler('objcpp')}
2019-07-29 07:56:45 -04:00
2019-12-17 22:23:13 -05:00
if compilers['objc'].get_id() != 'clang'
error('This program must be built with Clang! ( try: OBJC=clang CXX=clang++ OBJCXX=clang++ meson build )')
endif
global_sources = []
global_dependencies = []
global_include_dirs = []
global_args = []
global_link_args = []
2019-09-04 05:48:23 -04:00
# ====================
# Ext libs
# ====================
# DISCORD
discord = false
discord_libpath = get_option('discord_sdk_path')
if discord_libpath != ''
discordlib = compilers['cpp'].find_library('discord_game_sdk', required: false, dirs: [discord_libpath+'/lib/x86', discord_libpath+'/lib/x86_64'])
2019-09-04 05:48:23 -04:00
if discordlib.found() == true
global_include_dirs += include_directories(discord_libpath+'/c')
global_args += ['-I@0@/c'.format(discord_libpath), '-DHAVE_DISCORDSDK']
global_dependencies += discordlib
2019-09-04 05:48:23 -04:00
discord = true
endif
endif
2019-12-17 19:13:10 -05:00
# BOOST UNORDERED
global_include_dirs += include_directories('boost-unordered')
2019-09-04 05:48:23 -04:00
# ====================
# Main source
# ====================
# Suppress warnings
global_args += ['-Wno-non-virtual-dtor', '-Wno-reorder', '-Wno-uninitialized', '-Wno-unknown-pragmas', '-Wno-unknown-warning-option']
if compilers['objc'].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
2019-09-04 05:48:23 -04:00
# Decide whether or not to use MiniFFI
miniffi = get_option('use_miniffi')
if miniffi == true
if compilers['cpp'].sizeof('void*') == compilers['cpp'].sizeof('long')
miniffi = true
global_args += '-DUSE_MINIFFI'
else
warning('64-bit MiniFFI is only supported on Linux and macOS.')
warning('To use MiniFFI/Win32API on Windows, target 32-bit.')
miniffi = false
endif
endif
# Defines
if get_option('workdir_current')
global_args += '-DWORKDIR_CURRENT'
2019-07-29 08:20:40 -04:00
endif
if get_option('independent_appimage')
global_args += '-DINDEPENDENT_APPIMAGE'
endif
if get_option('use_fakeapi') == true and miniffi == true
global_args += '-DUSE_FAKEAPI'
endif
if not get_option('console')
global_args += '-DNO_CONSOLE'
endif
2019-09-19 03:32:50 -04:00
if get_option('mk')
global_args += '-DMARIN'
endif
# This MUST be disabled if building for macOS >= 10.15
if get_option('threaded_gl_init')
global_args += '-DTHREADED_GLINIT'
endif
2019-12-14 18:56:52 -05:00
# Objectify our C
global_args += run_command(objfw,'--cppflags').stdout().split()
2019-12-15 05:37:06 -05:00
add_project_arguments(run_command(objfw,'--objcflags').stdout().split(), language:['objc','objcpp'])
add_project_link_arguments(run_command(objfw,'--libs','--ldflags').stdout().split(), language:['objc','objcpp'])
2019-12-14 18:56:52 -05:00
# Make sure to use ARC
2019-12-17 22:23:13 -05:00
add_project_arguments(run_command(objfw,'--arc').stdout().split(), language:['objc','objcpp'])
if host_system != 'darwin'
add_project_arguments('-fobjc-runtime=objfw', language:['objc','objcpp'])
2019-09-19 03:32:50 -04:00
endif
# (Fix cquery thinking ObjC headers are C++ headers in VSCode)
add_project_arguments('-ObjC', language:'objc')
add_project_arguments('-ObjC++', language:'objcpp')
2019-12-14 18:56:52 -05:00
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
2019-07-29 07:56:45 -04:00
if host_system == 'windows'
subdir('windows')
global_sources += windows_resources
global_include_dirs += include_directories('windows')
2019-07-29 07:56:45 -04:00
elif host_system == 'darwin'
2019-08-26 01:57:12 -04:00
subdir('macos')
2019-12-17 22:23:13 -05:00
add_project_arguments('-stdlib=libc++', language: ['cpp','objcpp'])
2020-01-04 12:47:06 -05:00
add_project_arguments('-std=c++11', language: 'objcpp') # Meson's cpp_std doesn't work on ObjC for some reason
2019-12-17 22:23:13 -05:00
global_args += '-mmacosx-version-min='+minimum_macos_version
global_link_args += '-mmacosx-version-min='+minimum_macos_version
2019-10-22 02:30:07 -04:00
else
subdir('linux')
add_project_arguments('-std=c++11', language: 'objcpp')
2019-07-29 07:56:45 -04:00
endif
2019-07-31 09:45:12 -04:00
executable(meson.project_name(),
sources: global_sources,
dependencies: global_dependencies,
include_directories: global_include_dirs,
link_args: global_link_args,
cpp_args: global_args,
objc_args: global_args,
objcpp_args: global_args,
2019-08-26 01:57:12 -04:00
gui_app: (get_option('console') == false),
2019-10-22 02:30:07 -04:00
install: (host_system != 'windows')
2019-07-29 07:56:45 -04:00
)