1From 38f50c7d9ad3ba06b64583045665203afb53cbd9 Mon Sep 17 00:00:00 2001
2From: Samuel Martin <s.martin49@gmail.com>
3Date: Sun, 6 Nov 2016 16:29:08 +0100
4Subject: [PATCH] thirdparty: tiff: append flags found by pkg-config if
5 available
6
7This change allows to get all required CFLAGS/LDFLAGS in case of static only
8build.
9
10This build issue [1] was triggered by the Buildroot farms.
11
12[1] http://autobuild.buildroot.net/results/d0d/d0d22727311d6300e0e400728126170407bfd699/build-end.log
13
14Signed-off-by: Samuel Martin <s.martin49@gmail.com>
15---
16 thirdparty/CMakeLists.txt | 23 +++++++++++++++++++++--
17 1 file changed, 21 insertions(+), 2 deletions(-)
18
19diff --git a/thirdparty/CMakeLists.txt b/thirdparty/CMakeLists.txt
20index cb24b43b58e2..cd6a5e1391b0 100644
21--- a/thirdparty/CMakeLists.txt
22+++ b/thirdparty/CMakeLists.txt
23@@ -1,5 +1,9 @@
24 # 3rd party libs
25
26+if(NOT BUILD_THIRDPARTY)
27+  include(FindPkgConfig)
28+endif(NOT BUILD_THIRDPARTY)
29+
30 #------------
31 # Try to find lib Z
32 if(BUILD_THIRDPARTY)
33@@ -36,6 +40,9 @@ if(BUILD_THIRDPARTY)
34 else(BUILD_THIRDPARTY)
35   if(ZLIB_FOUND)
36     find_package(PNG)
37+    # Static only build:
38+    #   it is not necessary to invoke pkg_check_module on libpng, because libpng
39+    #   only depends on zlib, which is already checked.
40     if(PNG_FOUND)
41       message(STATUS "Your system seems to have a PNG lib available, we will use it")
42       set(OPJ_HAVE_PNG_H 1 PARENT_SCOPE)
43@@ -66,12 +73,24 @@ if(BUILD_THIRDPARTY)
44   set(OPJ_HAVE_LIBTIFF 1 PARENT_SCOPE)
45 else(BUILD_THIRDPARTY)
46   find_package(TIFF)
47+  # Static only build:
48+  #   it is necessary to invoke pkg_check_module on libtiff since it may have
49+  #   several other dependencies not declared by its cmake module, but they are
50+  #   in the its pkgconfig module.
51+  if(PKG_CONFIG_FOUND)
52+    foreach(pc_tiff_module tiff tiff3 tiff4 tiff-3 tiff-4 libtiff libtiff3 libtiff4 libtiff-3 libtiff-4)
53+      pkg_check_modules(PC_TIFF QUIET ${pc_tiff_module})
54+      if(PC_TIFF_FOUND)
55+        break()
56+      endif(PC_TIFF_FOUND)
57+    endforeach()
58+  endif(PKG_CONFIG_FOUND)
59   if(TIFF_FOUND)
60     message(STATUS "Your system seems to have a TIFF lib available, we will use it")
61     set(OPJ_HAVE_TIFF_H 1 PARENT_SCOPE)
62     set(OPJ_HAVE_LIBTIFF 1 PARENT_SCOPE)
63-    set(TIFF_LIBNAME ${TIFF_LIBRARIES} PARENT_SCOPE)
64-    set(TIFF_INCLUDE_DIRNAME ${TIFF_INCLUDE_DIR} PARENT_SCOPE)
65+    set(TIFF_LIBNAME ${TIFF_LIBRARIES} ${PC_TIFF_STATIC_LIBRARIES} PARENT_SCOPE)
66+    set(TIFF_INCLUDE_DIRNAME ${TIFF_INCLUDE_DIR} ${PC_TIFF_STATIC_INCLUDE_DIRS} PARENT_SCOPE)
67   else(TIFF_FOUND) # not found
68     set(OPJ_HAVE_TIFF_H 0 PARENT_SCOPE)
69     set(OPJ_HAVE_LIBTIFF 0 PARENT_SCOPE)
70--
712.10.2
72
73