From 0784472a58374c7559c5dc74344c56df49ddeb18 Mon Sep 17 00:00:00 2001 From: Biswapriyo Nath Date: Wed, 29 Dec 2021 18:40:37 +0530 Subject: build: Fix static library imports in mingw This defines LERC_STATIC while creating libtiff static library in Win32 platform in presence of lerc library. Otherwise, the static library import lerc APIs with dllimport attribute and thus linked with shared lerc library. --- configure.ac | 8 ++++++++ libtiff/CMakeLists.txt | 3 +++ libtiff/Makefile.am | 8 +++++++- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index bfa395a1..248c14fa 100644 --- a/configure.ac +++ b/configure.ac @@ -649,6 +649,14 @@ dnl Check for liblerc. dnl --------------------------------------------------------------------------- HAVE_LERC=no +STATIC_LERC=no + +if test "$enable_static" = "no"; then + static_lerc=no +else + static_lerc=yes +fi +AM_CONDITIONAL([STATIC_LERC], [ test "$static_lerc" = yes ]) AC_ARG_ENABLE(lerc, AS_HELP_STRING([--disable-lerc], diff --git a/libtiff/CMakeLists.txt b/libtiff/CMakeLists.txt index 905f52ca..cf9d80c3 100755 --- a/libtiff/CMakeLists.txt +++ b/libtiff/CMakeLists.txt @@ -132,6 +132,9 @@ endif() if(LERC_SUPPORT) target_link_libraries(tiff PRIVATE LERC::LERC) list(APPEND tiff_libs_private_list "${LERC_LIBRARY}") + if(NOT BUILD_SHARED_LIBS) + set_target_properties(tiff PROPERTIES COMPILE_DEFINITIONS LERC_STATIC) + endif() endif() if(LZMA_SUPPORT) target_link_libraries(tiff PRIVATE LibLZMA::LibLZMA) diff --git a/libtiff/Makefile.am b/libtiff/Makefile.am index 44522b62..3988da76 100644 --- a/libtiff/Makefile.am +++ b/libtiff/Makefile.am @@ -147,4 +147,10 @@ mkg3states_LDADD = $(LIBPORT) faxtable: mkg3states (rm -f tif_fax3sm.c && ./mkg3states -b -c const tif_fax3sm.c) -AM_CPPFLAGS = -I$(top_srcdir)/libtiff -I$(top_srcdir)/port +if STATIC_LERC +extra_CPPFLAGS = -DLERC_STATIC +else +extra_CPPFLAGS = +endif + +AM_CPPFLAGS = -I$(top_srcdir)/libtiff -I$(top_srcdir)/port $(extra_CPPFLAGS) -- cgit v1.2.1