From c1dfc0ab5daf1b5750a04451f63e65999600c6d3 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Sun, 24 Mar 2019 12:57:25 -0400 Subject: [PATCH] And got the Windows build working. Woo! --- meson.build | 8 ++++++-- windows/meson.build | 20 ++++++++++++++------ 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/meson.build b/meson.build index 2afb9cfe..2f887045 100644 --- a/meson.build +++ b/meson.build @@ -24,8 +24,10 @@ project('libui', ['c', 'cpp'], 'b_pch=false', # we don't want precompiled headers 'b_staticpic=true', # use PIC even for static libraries 'c_std=c99', # strict C99 + 'c_winlibs=', # we define our own Windows libraries 'cpp_std=c++11', # strict C++11 'cpp_eh=sc', # shut the compiler up in some cases + 'cpp_winlibs=', # likewise as with c_winlibs ], license: 'MIT') @@ -44,12 +46,14 @@ libui_forced_options = { 'b_pch': 'false', # we don't want precompiled headers 'b_staticpic': 'true', # use PIC even for static libraries 'c_std': 'c99', # strict C99 + 'c_winlibs': '[]', # we define our own Windows libraries 'cpp_std': 'c++11', # strict C++11 'cpp_eh': 'sc', # shut the compiler up in some cases + 'cpp_winlibs': '[]', # likewise as with c_winlibs } foreach name, value : libui_forced_options - # TODO why does meson need this guard? - if name != 'cpp_eh' or libui_MSVC + # TODO why does meson need this guard? why aren't all options defined regardless of target?! + if not (name == 'cpp_eh' and not libui_MSVC) and not (name == 'c_std' and libui_MSVC) actual = '@0@'.format(get_option(name)) if actual != value error('sorry, but libui requires that option ' + name + ' has the default value ' + value) diff --git a/windows/meson.build b/windows/meson.build index 5edfdb68..db6c971a 100644 --- a/windows/meson.build +++ b/windows/meson.build @@ -1,5 +1,7 @@ # 23 march 2019 +windows = import('windows') + libui_sources += [ 'windows/alloc.cpp', 'windows/area.cpp', @@ -63,24 +65,30 @@ libui_sources += [ 'windows/winpublic.cpp', 'windows/winutil.cpp', ] + +libui_include_directories += [include_directories('.')] + # resources.rc only contains the libui manifest. # For a DLL, we have to include this directly, so we do so. # Windows won't link resources in static libraries, so including this would have no effect. # In those cases, we just need them to include the manifest with the executable (or link it directly into the output executable themselves); they can also customize the manifest as they see fit (assuming nothing breaks in the process). # TODO make sure this gets added to both binary-only archives and install rules in this case if libui_mode == 'shared' - libui_sources += ['windows/resources.rc'] + libui_sources += [ + # TODO settle the path thing once and for all + windows.compile_resources('resources.rc', + depend_files: ['libui.manifest'], + include_directories: libui_include_directories), + ] endif -libui_include_directories += [include_directories('.')] - libui_winlibs = 'user32 kernel32 gdi32 comctl32 uxtheme msimg32 comdlg32 d2d1 dwrite ole32 oleaut32 oleacc uuid windowscodecs'.split(' ') -for lib in libui_winlibs - libui_dep += [ +foreach lib : libui_winlibs + libui_deps += [ meson.get_compiler('cpp').find_library(lib, required: true), ] -endfor +endforeach if libui_OS == 'windows' and libui_mode == 'shared' and not libui_MSVC error('Sorry, but libui for Windows can currently only be built as a static library with MinGW. You will need to either build as a static library or switch to MSVC.')