ref: 3f2bb0d9222aaf836bea6abd35d803a24bc47446
parent: ad8d21741a0239121a4bbfd5e48ee8f919869357
author: Martin Storsjö <martin@martin.st>
date: Sun Mar 24 18:05:28 EDT 2019
Only define DAV1D_API to dllexport when building dav1d itself As meson still doesn't allow specifying different cflags between static and dynamic libraries, this still includes the dllexport in the static library when built with default_library=both, but it at least is avoided in static-only builds, and avoids defining these symbols as dllexport in the callers' translation units.
--- a/include/dav1d/common.h
+++ b/include/dav1d/common.h
@@ -33,7 +33,11 @@
#ifndef DAV1D_API
#if defined _WIN32
- #define DAV1D_API __declspec(dllexport)
+ #if defined DAV1D_BUILDING_DLL
+ #define DAV1D_API __declspec(dllexport)
+ #else
+ #define DAV1D_API
+ #endif
#else
#if __GNUC__ >= 4
#define DAV1D_API __attribute__ ((visibility ("default")))
--- a/src/meson.build
+++ b/src/meson.build
@@ -139,8 +139,10 @@
+api_export_flags = []
+
#
-# Windows .rc file
+# Windows .rc file and API export flags
#
if host_machine.system() == 'windows' and get_option('default_library') != 'static'
@@ -162,6 +164,8 @@
)
libdav1d_rc_obj = winmod.compile_resources(rc_file)
+
+ api_export_flags = ['-DDAV1D_BUILDING_DLL']
else
libdav1d_rc_obj = []
endif
@@ -180,7 +184,7 @@
include_directories : dav1d_inc_dirs,
dependencies: [stdatomic_dependency],
- c_args : [stackalign_flag, stackrealign_flag],
+ c_args : [stackalign_flag, stackrealign_flag, api_export_flags],
install : false,
build_by_default : false,
).extract_all_objects()
@@ -222,7 +226,7 @@
thread_dependency,
thread_compat_dep,
],
- c_args : [stackalign_flag],
+ c_args : [stackalign_flag, api_export_flags],
version : dav1d_soname_version,
soversion : dav1d_soversion,
install : true,