2019-03-17 20:26:52 -05:00
# 17 march 2019
2019-03-30 10:30:55 -05:00
# TODO I'm not sure how to allow building 32-bit instead of 64-bit with meson
2019-03-30 14:43:33 -05:00
# TODO remove cpp from this list once https://github.com/mesonbuild/meson/issues/5181 is settled; move it to the OS checks and under cpp-multithread
2019-03-23 20:06:19 -05:00
project ( 'libui' , [ 'c' , 'cpp' ] ,
2019-03-23 20:50:54 -05:00
meson_version : '>=0.48.0' ,
2019-03-23 15:18:13 -05:00
default_options : [
'buildtype=debug' , # build debug by default
'default_library=shared' , # build shared libraries by default
2019-03-31 10:04:20 -05:00
'layout=flat' , # keep all outputs together by default
2019-03-23 15:18:13 -05:00
2019-03-30 14:43:33 -05:00
# these are forced options, but meson doesn't let me set these up separately before I call project() (TODO https://github.com/mesonbuild/meson/issues/5179)
2019-03-23 15:18:13 -05:00
'warning_level=3' , # always max warnings
'b_pch=false' , # we don't want precompiled headers
'b_staticpic=true' , # use PIC even for static libraries
'c_std=c99' , # strict C99
2019-03-24 11:57:25 -05:00
'c_winlibs=' , # we define our own Windows libraries
2019-03-23 15:18:13 -05:00
'cpp_std=c++11' , # strict C++11
'cpp_eh=sc' , # shut the compiler up in some cases
2019-03-24 11:57:25 -05:00
'cpp_winlibs=' , # likewise as with c_winlibs
2019-03-23 15:18:13 -05:00
] ,
license : 'MIT' )
2019-03-30 14:43:33 -05:00
# TODO after https://github.com/mesonbuild/meson/issues/5179 is settled, remove these
2019-03-23 15:18:13 -05:00
libui_OS = host_machine . system ( )
libui_MSVC = meson . get_compiler ( 'c' ) . get_id ( ) == 'msvc'
2019-03-30 14:43:33 -05:00
# TODO switch to tabs; the spaces are just so I can share this file while I'm writing it
2019-03-17 20:26:52 -05:00
libui_forced_options = {
2019-03-21 22:21:30 -05:00
'warning_level' : '3' , # always max warnings
'b_pch' : 'false' , # we don't want precompiled headers
'b_staticpic' : 'true' , # use PIC even for static libraries
'c_std' : 'c99' , # strict C99
2019-03-24 11:57:25 -05:00
'c_winlibs' : '[]' , # we define our own Windows libraries
2019-03-21 22:21:30 -05:00
'cpp_std' : 'c++11' , # strict C++11
'cpp_eh' : 'sc' , # shut the compiler up in some cases
2019-03-24 11:57:25 -05:00
'cpp_winlibs' : '[]' , # likewise as with c_winlibs
2019-03-17 20:26:52 -05:00
}
foreach name , value : libui_forced_options
2019-03-30 14:43:33 -05:00
# TODO rewrite this when https://github.com/mesonbuild/meson/issues/5181 is settled
2019-03-24 13:11:02 -05:00
if not ( ( name == 'c_winlibs' or name == 'cpp_eh' or name == 'cpp_winlibs' ) and not libui_MSVC ) and not ( name == 'c_std' and libui_MSVC )
2019-03-23 15:18:13 -05:00
actual = '@0@' . format ( get_option ( name ) )
if actual != value
error ( 'sorry, but libui requires that option ' + name + ' has the default value ' + value )
endif
2019-03-17 20:26:52 -05:00
endif
endforeach
2019-03-30 14:43:33 -05:00
libui_OS = host_machine . system ( )
libui_MSVC = meson . get_compiler ( 'c' ) . get_id ( ) == 'msvc'
if libui_OS == 'darwin'
add_languages ( 'objc' ,
required : true )
endif
2019-03-17 20:26:52 -05:00
libui_mode = get_option ( 'default_library' )
if libui_mode == 'both'
error ( 'sorry, but libui does not support building both shared and static libraries at the same time, because Windows resource file rules differ between the two' )
endif
2019-03-25 09:46:41 -05:00
libui_is_debug = get_option ( 'buildtype' ) . startswith ( 'debug' )
2019-03-23 14:42:42 -05:00
2019-03-26 20:53:00 -05:00
libui_project_compile_args = [ ]
libui_project_link_args = [ ]
2019-03-23 21:28:17 -05:00
if libui_OS == 'darwin'
2019-03-23 14:42:42 -05:00
libui_macosx_version_min = '-mmacosx-version-min=10.8'
2019-03-26 20:53:00 -05:00
libui_project_compile_args + = [ libui_macosx_version_min ]
libui_project_link_args + = [ libui_macosx_version_min ]
2019-03-17 20:26:52 -05:00
endif
2019-03-21 10:23:30 -05:00
if libui_MSVC
# TODO subsystem version
2019-03-26 20:53:00 -05:00
libui_project_compile_args + = [
2019-03-23 14:42:42 -05:00
'/wd4100' ,
2019-03-25 19:17:42 -05:00
'/bigobj' ,
2019-03-26 20:53:00 -05:00
]
2019-03-23 14:42:42 -05:00
if libui_is_debug
2019-03-26 20:53:00 -05:00
libui_project_compile_args + = [ '/RTC1' , '/RTCs' , '/RTCu' ]
2019-03-23 14:42:42 -05:00
endif
2019-03-21 10:23:30 -05:00
2019-03-26 20:53:00 -05:00
libui_project_link_args + = [
2019-03-23 14:42:42 -05:00
'/LARGEADDRESSAWARE' ,
'/INCREMENTAL:NO' ,
2019-03-23 15:18:13 -05:00
'/MANIFEST:NO' ,
2019-03-26 20:53:00 -05:00
]
2019-03-26 23:46:34 -05:00
# TODO autogenerate a .def file?
2019-03-21 10:23:30 -05:00
else
2019-03-26 20:53:00 -05:00
libui_project_compile_args + = [
2019-03-23 14:42:42 -05:00
'-Wno-unused-parameter' ,
2019-03-23 15:18:13 -05:00
'-Wno-switch' ,
2019-03-26 20:53:00 -05:00
]
2019-03-21 10:23:30 -05:00
if libui_OS == 'windows'
# don't require shipping the MinGW-w64 DLLs
2019-03-26 20:53:00 -05:00
libui_project_link_args + = [
2019-03-23 14:42:42 -05:00
'-static' ,
'-static-libgcc' ,
2019-03-23 15:18:13 -05:00
'-static-libstdc++' ,
2019-03-26 20:53:00 -05:00
]
2019-03-21 10:23:30 -05:00
endif
endif
2019-03-30 13:17:13 -05:00
# TODO come up with a better way to do this, both for libui (the compiler define, used by winapi.hpp, and the manifest args) and for the binaries (the manifest args)
# TODO (after the above TODO is resolved) move that below the part below that actually adds these arguments
2019-03-24 13:11:02 -05:00
libui_manifest_args = [ ]
if libui_mode == 'static'
2019-04-08 22:39:27 -05:00
libui_project_compile_args + = [ '-DuiStatic' ]
libui_manifest_args = [ '-DuiStatic' ]
2019-03-24 13:11:02 -05:00
endif
2019-03-26 20:53:00 -05:00
add_project_arguments ( libui_project_compile_args ,
language : [ 'c' , 'cpp' , 'objc' ] )
add_project_link_arguments ( libui_project_link_args ,
language : [ 'c' , 'cpp' , 'objc' ] )
2019-03-28 19:18:05 -05:00
# TODO:
# meson determins whether -Wl,--no-undefined is provided via
# built-in option b_lundef, and it's true by default, which is what
# we want (so I don't make mistakes like asking for unknown
# functions in my dependencies). However, meson also is smart
# about specifying this properly on systems that don't support it, like
# FreeBSD (where I had the comment "figure out why FreeBSD
# follows linked libraries here" when I was on cmake) and OpenBSD
# (according to someone on freenode #mesonbuild), but it isn't clear
# whether it's just ignored or if the value is forced to false.
# Therefore, once this is determined, we can uncomment the
# following.
libui_libui_link_args = [ ]
#if not libui_MSVC and get_option("b_lundef")
# TODO what should this be on MSVC?
# libui_libui_link_args += ['-Wl,--no-allow-shlib-undefined']
#endif
2019-03-17 20:26:52 -05:00
libui_sources = [ ]
2019-03-23 21:28:17 -05:00
libui_deps = [ ]
libui_soversion = ''
libui_rpath = ''
2019-04-19 11:32:13 -05:00
subdir ( 'common' )
2019-03-17 20:26:52 -05:00
if libui_OS == 'windows'
2019-04-21 14:08:09 -05:00
subdir ( 'windows' )
2019-03-17 20:26:52 -05:00
install_headers ( 'ui_windows.h' )
elif libui_OS == 'darwin'
2019-04-20 20:38:26 -05:00
subdir ( 'darwin' )
2019-03-17 20:26:52 -05:00
install_headers ( 'ui_darwin.h' )
else
2019-04-21 11:24:19 -05:00
subdir ( 'unix' )
2019-03-17 20:26:52 -05:00
install_headers ( 'ui_unix.h' )
endif
libui_libui = library ( 'ui' , libui_sources ,
dependencies : libui_deps ,
build_rpath : libui_rpath ,
install_rpath : libui_rpath ,
2019-03-25 09:29:18 -05:00
name_prefix : 'lib' , # always call it libui, even in Windows DLLs
2019-03-17 20:26:52 -05:00
install : true ,
2019-03-21 10:23:30 -05:00
gnu_symbol_visibility : 'hidden' ,
2019-04-08 19:55:06 -05:00
c_args : [ '-DuiprivBuildingLibui' ] ,
cpp_args : [ '-DuiprivBuildingLibui' ] ,
objc_args : [ '-DuiprivBuildingLibui' ] ,
2019-03-28 19:18:05 -05:00
link_args : libui_libui_link_args ,
2019-03-23 17:12:33 -05:00
soversion : libui_soversion ,
darwin_versions : [ ] ) # TODO
2019-03-17 20:26:52 -05:00
install_headers ( 'ui.h' )
2019-03-25 19:52:49 -05:00
# TODO when the API is stable enough to be versioned, create a pkg-config file (https://mesonbuild.com/Pkgconfig-module.html) and a declare_dependency() section too
2019-03-23 17:12:33 -05:00
libui_binary_deps = [ ]
if libui_mode == 'static'
libui_binary_deps = libui_deps
endif
subdir ( 'test' )
2019-04-10 19:11:44 -05:00
#subdir('examples')