builds: Fix and clean up MSVC DLL builds
Instead of passing a CFLAG/CXXFLAG to define HB_EXTERN, define it directly in src/hb.hh as __declspec(dllexport) extern when we are building HarfBuzz as DLLs on Visual Studio. Define HB_INTERNAL as nothing without defining HB_NO_VISIBILITY when building HarfBuzz as DLLs to avoid linker errors on Visual Studio builds. Also "install" harfbuzz-subset.dll into $(PREFIX)\bin as the hb-subset utility will depend on that DLL at runtime, when HarfBuzz is built as DLLs. Since it consists of private APIs that are subject to change, we do not install its headers nor .lib file.
This commit is contained in:
parent
e640f3a6b1
commit
8e4ad1d7a0
|
@ -574,7 +574,7 @@ if (HB_HAVE_GOBJECT)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
if (BUILD_SHARED_LIBS AND WIN32 AND NOT MINGW)
|
if (BUILD_SHARED_LIBS AND WIN32 AND NOT MINGW)
|
||||||
add_definitions("-DHB_EXTERN=__declspec(dllexport) extern")
|
add_definitions("-DHB_DLL_EXPORT")
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
# On Windows, g-ir-scanner requires a DLL build in order for it to work
|
# On Windows, g-ir-scanner requires a DLL build in order for it to work
|
||||||
|
@ -772,6 +772,11 @@ if (NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL)
|
||||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/harfbuzz
|
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/harfbuzz
|
||||||
)
|
)
|
||||||
if (HB_BUILD_UTILS)
|
if (HB_BUILD_UTILS)
|
||||||
|
if (WIN32 AND BUILD_SHARED_LIBS)
|
||||||
|
install(TARGETS harfbuzz-subset
|
||||||
|
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||||
|
)
|
||||||
|
endif ()
|
||||||
install(TARGETS hb-view
|
install(TARGETS hb-view
|
||||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||||
)
|
)
|
||||||
|
|
10
src/hb.hh
10
src/hb.hh
|
@ -39,6 +39,10 @@
|
||||||
#define _POSIX_C_SOURCE 200809L
|
#define _POSIX_C_SOURCE 200809L
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined (_MSC_VER) && defined (HB_DLL_EXPORT)
|
||||||
|
#define HB_EXTERN __declspec (dllexport) extern
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "hb.h"
|
#include "hb.h"
|
||||||
#define HB_H_IN
|
#define HB_H_IN
|
||||||
#ifdef HAVE_OT
|
#ifdef HAVE_OT
|
||||||
|
@ -178,8 +182,10 @@ struct _hb_alignof
|
||||||
# if !defined(HB_NO_VISIBILITY) && !defined(__MINGW32__) && !defined(__CYGWIN__) && !defined(_MSC_VER) && !defined(__SUNPRO_CC)
|
# if !defined(HB_NO_VISIBILITY) && !defined(__MINGW32__) && !defined(__CYGWIN__) && !defined(_MSC_VER) && !defined(__SUNPRO_CC)
|
||||||
# define HB_INTERNAL __attribute__((__visibility__("hidden")))
|
# define HB_INTERNAL __attribute__((__visibility__("hidden")))
|
||||||
# elif defined(__MINGW32__)
|
# elif defined(__MINGW32__)
|
||||||
/* We use -export-symbols on mingw32, since it does not support visibility
|
/* We use -export-symbols on mingw32, since it does not support visibility attributes. */
|
||||||
* attribute. */
|
# define HB_INTERNAL
|
||||||
|
# elif defined (_MSC_VER) && defined (HB_DLL_EXPORT)
|
||||||
|
/* We do not try to export internal symbols on Visual Studio */
|
||||||
# define HB_INTERNAL
|
# define HB_INTERNAL
|
||||||
#else
|
#else
|
||||||
# define HB_INTERNAL
|
# define HB_INTERNAL
|
||||||
|
|
Loading…
Reference in New Issue