mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-07 21:23:32 +00:00
portability: fix usage of TVG_API
Rule of thumb on Windows: * for a DLL: * if the library is built, set TVG_API to __declspec(dllexport) * if the library is used, set TVG_API to __declspec(dllimport) * for a static library, set TVG_API to nothing To set TVG_API for a static library, TVG_STATIC is defined when the stataic library is built. Otherwise, TVG_API is correctly set for a DLL. Also sun and intel compilers are handled @issue: https://github.com/thorvg/thorvg/issues/1446
This commit is contained in:
parent
41c41b538d
commit
be2de28312
8 changed files with 57 additions and 33 deletions
34
inc/thorvg.h
34
inc/thorvg.h
|
@ -23,28 +23,36 @@
|
||||||
#undef TVG_API
|
#undef TVG_API
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(_WIN32) && !defined(__clang__)
|
#ifndef TVG_STATIC
|
||||||
#if TVG_BUILD
|
#ifdef _WIN32
|
||||||
#if TVG_EXPORT
|
#if TVG_BUILD
|
||||||
#define TVG_API __declspec(dllexport)
|
#define TVG_API __declspec(dllexport)
|
||||||
#else
|
#else
|
||||||
#define TVG_API
|
#define TVG_API __declspec(dllimport)
|
||||||
#endif
|
#endif
|
||||||
|
#elif (defined(__SUNPRO_C) || defined(__SUNPRO_CC))
|
||||||
|
#define TVG_API __global
|
||||||
#else
|
#else
|
||||||
#define TVG_API __declspec(dllimport)
|
#if (defined(__GNUC__) && __GNUC__ >= 4) || defined(__INTEL_COMPILER)
|
||||||
#endif
|
#define TVG_API __attribute__ ((visibility("default")))
|
||||||
#define TVG_DEPRECATED __declspec(deprecated)
|
|
||||||
#else
|
|
||||||
#if TVG_BUILD
|
|
||||||
#if TVG_EXPORT
|
|
||||||
#define TVG_API __attribute__ ((visibility ("default")))
|
|
||||||
#else
|
#else
|
||||||
#define TVG_API
|
#define TVG_API
|
||||||
#endif
|
#endif
|
||||||
#else
|
|
||||||
#define TVG_API
|
|
||||||
#endif
|
#endif
|
||||||
|
#else
|
||||||
|
#define TVG_API
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef TVG_DEPRECATED
|
||||||
|
#undef TVG_DEPRECATED
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
#define TVG_DEPRECATED __declspec(deprecated)
|
||||||
|
#elif __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)
|
||||||
#define TVG_DEPRECATED __attribute__ ((__deprecated__))
|
#define TVG_DEPRECATED __attribute__ ((__deprecated__))
|
||||||
|
#else
|
||||||
|
#define TVG_DEPRECATED
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define _TVG_DECLARE_PRIVATE(A) \
|
#define _TVG_DECLARE_PRIVATE(A) \
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
compiler_flags = ['-DTVG_BUILD']
|
if (lib_type == 'static')
|
||||||
|
compiler_flags += ['-DTVG_STATIC']
|
||||||
|
endif
|
||||||
|
|
||||||
if all_tools or get_option('tools').contains('svg2png') == true
|
if all_tools or get_option('tools').contains('svg2png') == true
|
||||||
subdir('svg2png')
|
subdir('svg2png')
|
||||||
|
|
|
@ -3,5 +3,5 @@ svg2png_src = files('svg2png.cpp', 'lodepng.cpp')
|
||||||
executable('svg2png',
|
executable('svg2png',
|
||||||
svg2png_src,
|
svg2png_src,
|
||||||
include_directories : headers,
|
include_directories : headers,
|
||||||
cpp_args: compiler_flags,
|
cpp_args : compiler_flags,
|
||||||
link_with : thorvg_lib)
|
link_with : thorvg_lib)
|
||||||
|
|
|
@ -3,5 +3,5 @@ svg2tvg_src = files('svg2tvg.cpp')
|
||||||
executable('svg2tvg',
|
executable('svg2tvg',
|
||||||
svg2tvg_src,
|
svg2tvg_src,
|
||||||
include_directories : headers,
|
include_directories : headers,
|
||||||
cpp_args: compiler_flags,
|
cpp_args : compiler_flags,
|
||||||
link_with : thorvg_lib)
|
link_with : thorvg_lib)
|
||||||
|
|
|
@ -25,28 +25,36 @@
|
||||||
#undef TVG_API
|
#undef TVG_API
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(_WIN32) && !defined(__clang__)
|
#ifndef TVG_STATIC
|
||||||
#if TVG_BUILD
|
#ifdef _WIN32
|
||||||
#if TVG_EXPORT
|
#if TVG_BUILD
|
||||||
#define TVG_API __declspec(dllexport)
|
#define TVG_API __declspec(dllexport)
|
||||||
#else
|
#else
|
||||||
#define TVG_API
|
#define TVG_API __declspec(dllimport)
|
||||||
#endif
|
#endif
|
||||||
|
#elif (defined(__SUNPRO_C) || defined(__SUNPRO_CC))
|
||||||
|
#define TVG_API __global
|
||||||
#else
|
#else
|
||||||
#define TVG_API __declspec(dllimport)
|
#if (defined(__GNUC__) && __GNUC__ >= 4) || defined(__INTEL_COMPILER)
|
||||||
#endif
|
#define TVG_API __attribute__ ((visibility("default")))
|
||||||
#define TVG_DEPRECATED __declspec(deprecated)
|
|
||||||
#else
|
|
||||||
#if TVG_BUILD
|
|
||||||
#if TVG_EXPORT
|
|
||||||
#define TVG_API __attribute__ ((visibility ("default")))
|
|
||||||
#else
|
#else
|
||||||
#define TVG_API
|
#define TVG_API
|
||||||
#endif
|
#endif
|
||||||
#else
|
|
||||||
#define TVG_API
|
|
||||||
#endif
|
#endif
|
||||||
|
#else
|
||||||
|
#define TVG_API
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef TVG_DEPRECATED
|
||||||
|
#undef TVG_DEPRECATED
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
#define TVG_DEPRECATED __declspec(deprecated)
|
||||||
|
#elif __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)
|
||||||
#define TVG_DEPRECATED __attribute__ ((__deprecated__))
|
#define TVG_DEPRECATED __attribute__ ((__deprecated__))
|
||||||
|
#else
|
||||||
|
#define TVG_DEPRECATED
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
compiler_flags = ['-DTVG_BUILD']
|
if (lib_type == 'static')
|
||||||
|
compiler_flags += ['-DTVG_STATIC']
|
||||||
|
endif
|
||||||
|
|
||||||
examples_dep = dependency('elementary', required : true)
|
examples_dep = dependency('elementary', required : true)
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
compiler_flags = ['-DTVG_BUILD']
|
compiler_flags = []
|
||||||
override_options = []
|
override_options = []
|
||||||
|
|
||||||
lib_type = get_option('default_library')
|
lib_type = get_option('default_library')
|
||||||
|
|
||||||
if (lib_type == 'shared')
|
if (lib_type == 'shared')
|
||||||
compiler_flags += ['-DTVG_EXPORT']
|
compiler_flags += ['-DTVG_EXPORT', '-DTVG_BUILD']
|
||||||
|
else
|
||||||
|
compiler_flags += ['-DTVG_STATIC']
|
||||||
endif
|
endif
|
||||||
|
|
||||||
cc = meson.get_compiler('cpp')
|
cc = meson.get_compiler('cpp')
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
compiler_flags = ['-DTVG_BUILD']
|
if (lib_type == 'static')
|
||||||
|
compiler_flags += ['-DTVG_STATIC']
|
||||||
|
endif
|
||||||
|
|
||||||
test_file = [
|
test_file = [
|
||||||
'testAccessor.cpp',
|
'testAccessor.cpp',
|
||||||
|
|
Loading…
Add table
Reference in a new issue