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