support -Ddefault_library=both for windows

master
Daniel Kolesa 2021-04-07 01:58:58 +02:00
parent c09613c5ea
commit 34959f44f3
1 changed files with 36 additions and 14 deletions

View File

@ -28,23 +28,45 @@ libcubescript_src = [
'lib_str.cc' 'lib_str.cc'
] ]
lib_cxxflags = [ '-DLIBCUBESCRIPT_BUILD' ] lib_cxxflags = extra_cxxflags + [ '-DLIBCUBESCRIPT_BUILD' ]
host_system = host_machine.system() dyn_cxxflags = lib_cxxflags
if host_system == 'windows' or host_system == 'cygwin' lib_incdirs = libcubescript_includes + [include_directories('.')]
if get_option('default_library') != 'static'
lib_cxxflags += '-DLIBCUBESCRIPT_DLL' host_system = host_machine.system()
endif os_uses_dlls = (host_system == 'windows' or host_system == 'cygwin')
if os_uses_dlls
dyn_cxxflags += '-DLIBCUBESCRIPT_DLL'
endif endif
libcubescript_target = library('cubescript', if os_uses_dlls and get_option('default_library') == 'both'
libcubescript_src, # we need a bunch of this nonsense on windows as both_libraries()
include_directories: libcubescript_includes + [include_directories('.')], # does not work reliably there; since DLLs work like they do, we
cpp_args: extra_cxxflags + lib_cxxflags, # need to compile one set of object files with dllexport and the
install: true, # other set without that, and there is no way to tell meson to
pic: true, # do that other than making two different targets...
version: meson.project_version() libcubescript_static = static_library('cubescript',
) libcubescript_src, include_directories: lib_incdirs,
cpp_args: lib_cxxflags,
install: true
)
libcubescript_dynamic = shared_library('cubescript',
libcubescript_src, include_directories: lib_incdirs,
cpp_args: dyn_cxxflags,
install: true,
version: meson.project_version()
)
libcubescript_target = libcubescript_dynamic
else
libcubescript_target = library('cubescript',
libcubescript_src, include_directories: lib_incdirs,
cpp_args: dyn_cxxflags,
install: true,
pic: true,
version: meson.project_version()
)
endif
libcubescript = declare_dependency( libcubescript = declare_dependency(
include_directories: libcubescript_includes, include_directories: libcubescript_includes,