Skip to content

Commit

Permalink
alternative fix for meson unity
Browse files Browse the repository at this point in the history
  • Loading branch information
DadSchoorse committed Jan 12, 2021
1 parent b531546 commit ee98003
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
10 changes: 3 additions & 7 deletions src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ vkBasalt_src = [
'reshade_uniforms.cpp',
'sampler.cpp',
'shader.cpp',
'stb_image.c',
'stb_image_resize.c',
'util.cpp',
'vkdispatch.cpp',
]
Expand All @@ -45,19 +47,13 @@ conf_paths.set_quoted('DATADIR', join_paths(get_option('prefix'), get_option('da
configure_file(output: 'config_paths.hpp',
configuration : conf_paths)

# Compile stb_image implementations separatelly.
# This allows to build project with Meson --unity=on option, for faster compilation
# and potentially better optimization.
stb_image_lib = static_library('stb_image', 'stb_image.c')
stb_image_resize_lib = static_library('stb_image_resize', 'stb_image_resize.c')

# X11/X.h library contains many definitions (e.g. None)
# which conflicts with the rest codebase with with Meson --unity=on option
keyboard_input_x11_lib = static_library('keyboard_input_x11', 'keyboard_input_x11.cpp')

shared_library(meson.project_name().to_lower(),
vkBasalt_src, shader_include,
link_with: [ stb_image_lib, stb_image_resize_lib, keyboard_input_x11_lib ],
link_with: [keyboard_input_x11_lib],
include_directories : vkBasalt_include_path,
dependencies : [x11_dep, reshade_dep],
install : true,
Expand Down
3 changes: 3 additions & 0 deletions src/stb_image.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@
#define STB_IMAGE_DDS_IMPLEMENTATION
#include "stb_image.h"
#include "stb_image_dds.h"

#undef STB_IMAGE_IMPLEMENTATION
#undef STB_IMAGE_DDS_IMPLEMENTATION
2 changes: 2 additions & 0 deletions src/stb_image_resize.c
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
#define STB_IMAGE_RESIZE_IMPLEMENTATION
#include "stb_image_resize.h"

#undef STB_IMAGE_RESIZE_IMPLEMENTATION

0 comments on commit ee98003

Please sign in to comment.