project('voyage', ['c', 'cpp'], default_options: ['buildtype=debug', 'b_sanitize=address', 'c_std=c17', 'cpp_std=c++14', 'warning_level=3', 'werror=true', 'b_vscrt=static_from_buildtype', 'default_library=static', 'b_rtti=false', 'cpp_eh=none']) compiler = meson.get_compiler('c') buildtype = get_option('buildtype') # Build options if compiler.get_argument_syntax() == 'gcc' add_project_arguments( ['-Wconversion', '-Wno-sign-conversion', '-Wdouble-promotion', '-Wno-unused-function', '-Wno-unused-parameter'], language : ['c', 'cpp'] ) elif compiler.get_argument_syntax() == 'msvc' add_project_arguments( ['/wd4146', '/wd4245', '/wd4100', '/D_CRT_SECURE_NO_WARNINGS'], language: ['c', 'cpp'] ) if buildtype == 'debug' add_project_arguments(['/RTCsu'], language : ['c', 'cpp']) endif # Allow nameless struct/unions (standard in C11) add_project_arguments(['/wd4201'], language : 'cpp') endif if get_option('default_library') == 'static' add_project_arguments(['-DRT_STATIC_LIB'], language : ['c', 'cpp']) endif if get_option('error_report_debugbreak') add_project_arguments(['-DRT_ERROR_REPORT_DEBUGBREAK'], language : ['c', 'cpp']) endif # Debug specific flags if buildtype == 'debug' or buildtype == 'debugoptimized' add_project_arguments([ '-DRT_DEBUG'], language : ['c', 'cpp']) endif # Gather dependencies common_incdirs = [include_directories(['contrib', 'src'])] thread_dep = dependency('threads') m_dep = compiler.find_library('m', required : false) vk_dep = dependency('vulkan', required : false) windowing_dep = [] if get_option('use_xlib') windowing_dep = dependency('x11', required : true) add_project_arguments(['-DRT_USE_XLIB'], language : ['c', 'cpp']) endif # Copy file utility copy_util = find_program('scripts/copy_util.py') runtime_incdirs = common_incdirs runtime_linkargs = [] runtime_additional_sources = [] runtime_cargs = [] runtime_deps = [thread_dep, m_dep, windowing_dep] if get_option('build_asset_compiler') runtime_cargs += ['-DRT_BUILD_ASSET_COMPILER'] # DXC for vulkan & directx shaders if get_option('enable_dxc_shader_compiler') # We package dxc binaries under contrib/dxc dxc_include = include_directories('contrib' / 'dxc' / 'inc') dxc_libdir = 'NONE' if host_machine.system() == 'windows' dxc_libdir = meson.project_source_root() / 'contrib' / 'dxc' / 'lib' / 'x64' custom_target('copy dxcompiler.dll', input : 'contrib' / 'dxc' / 'bin' / 'x64' / 'dxcompiler.dll', output : 'dxcompiler.dll', command : [copy_util, '@INPUT@', '@OUTPUT@'], install : false, build_by_default : true) endif dxc_dep = declare_dependency(link_args : ['-L'+dxc_libdir, '-ldxcompiler'], include_directories : dxc_include) runtime_deps += dxc_dep runtime_additional_sources += [ 'src/runtime/dxc_shader_compiler.cpp' ] runtime_cargs += ['-DRT_BUILD_DXC_SHADER_COMPILER'] endif # Asset compiler sources runtime_additional_sources += [ 'src/runtime/asset_compiler.h', 'src/runtime/description_parser.h', 'src/runtime/shader_compiler.h', 'src/runtime/asset_compiler.c', 'src/runtime/description_parser.c', 'src/runtime/framegraph_processor.c', 'src/runtime/pipeline_processor.c', 'src/runtime/shader_compiler.c', ] endif runtime_lib = library('rt', # Project Sources 'src/runtime/aio.h', 'src/runtime/app.h', 'src/runtime/buffer_manager.h', 'src/runtime/compression.h', 'src/runtime/config.h', 'src/runtime/ds.h', 'src/runtime/dynamic_libs.h', 'src/runtime/file_tab.h', 'src/runtime/fsutils.h', 'src/runtime/gfx.h', 'src/runtime/handles.h', 'src/runtime/hashing.h', 'src/runtime/jobs.h', 'src/runtime/mem_arena.h', 'src/runtime/renderer_api.h', 'src/runtime/resources.h', 'src/runtime/runtime.h', 'src/runtime/threading.h', 'src/runtime/aio.c', 'src/runtime/app.c', 'src/runtime/assert.c', 'src/runtime/buffer_manager.c', 'src/runtime/compression.c', 'src/runtime/config.c', 'src/runtime/ds_minheap.c', 'src/runtime/dynamic_libs.c', 'src/runtime/error_report.c', 'src/runtime/file_tab.c', 'src/runtime/fsutils.c', 'src/runtime/gfx_framegraph.c', 'src/runtime/gfx_main.c', 'src/runtime/hashing.c', 'src/runtime/init.c', 'src/runtime/jobs.c', 'src/runtime/mem_arena.c', 'src/runtime/resource_manager.c', 'src/runtime/sprint.c', 'src/runtime/text.c', 'src/runtime/threading_cond.c', 'src/runtime/threading_mutex.c', 'src/runtime/threading_rwlock.c', 'src/runtime/threading_thread.c', # Contrib Sources 'contrib/xxhash/xxhash.c', 'contrib/lz4/lz4.c', sources : runtime_additional_sources, dependencies : runtime_deps, include_directories : runtime_incdirs, link_args : runtime_linkargs, c_args : runtime_cargs, c_pch : 'pch/rt_pch.h', cpp_args : runtime_cargs, cpp_pch : 'pch/rt_pch.h') # Renderer libraries static_renderer_lib = 'NONE' if vk_dep.found() platform_defs = [] if get_option('use_xlib') platform_defs = ['-DVK_USE_PLATFORM_XLIB_KHR'] elif host_machine.system() == 'windows' platform_defs = ['-DVK_USE_PLATFORM_WIN32_KHR'] endif vk_inc_dep = vk_dep.partial_dependency(compile_args : true, includes : true) vk_renderer_lib = library('rtvk', # Project Sources 'src/renderer/vk/gpu.h', 'src/renderer/vk/pipelines.h', 'src/renderer/vk/render_targets.h', 'src/renderer/vk/swapchain.h', 'src/renderer/vk/helper.c', 'src/renderer/vk/init.c', 'src/renderer/vk/pipelines.c', 'src/renderer/vk/render_targets.c', 'src/renderer/vk/swapchain.c', # Contrib Sources 'contrib/volk/volk.h', 'contrib/volk/volk.c', 'contrib/vma/vk_mem_alloc.h', 'src/renderer/vk/vma_impl.cpp', dependencies : [m_dep, vk_inc_dep, windowing_dep], include_directories : common_incdirs, link_with : [runtime_lib], c_pch : 'pch/vk_pch.h', c_args : platform_defs, cpp_pch : 'pch/vk_pch.h', cpp_args : platform_defs) static_renderer_lib = vk_renderer_lib endif # Handle linking against both runtime and renderer if we build static libs engine_link_libs = [] if get_option('default_library') == 'static' engine_link_libs = [runtime_lib, static_renderer_lib] else engine_link_libs = [runtime_lib] endif # Game executable('voyage', 'src/game/entry.c', 'src/game/main.c', include_directories : common_incdirs, link_with : engine_link_libs, win_subsystem : 'windows') # Unit Tests rttest_exe = executable('rttest', 'src/tests/rttest.c', link_with : engine_link_libs, include_directories : common_incdirs, win_subsystem : 'console') test('runtime test', rttest_exe)