[gdk-pixbuf/ebassi/for-master: 5/5] build: Reorganise the libjpeg checks




commit 993e75a9d3165512a3f472c3a154f975d7193f18
Author: Emmanuele Bassi <ebassi gnome org>
Date:   Fri Apr 16 23:37:48 2021 +0100

    build: Reorganise the libjpeg checks
    
    Follow the same pattern as the libpng checks:
    
     1. look for libjpeg via pkg-config
     2. if pkg-config fails, and we're using the MSVC toolchain, look
        for header and library
     3. if that fails, fall back to the libjpeg subproject

 meson.build | 19 +++++++------------
 1 file changed, 7 insertions(+), 12 deletions(-)
---
diff --git a/meson.build b/meson.build
index 06c0d27dc..8328fcbc3 100644
--- a/meson.build
+++ b/meson.build
@@ -324,33 +324,28 @@ endif
 
 # Don't check and build the jpeg loader if native_windows_loaders is true
 if get_option('jpeg') and not native_windows_loaders
-  if cc.has_header('jpeglib.h')
+  jpeg_dep = dependency('libjpeg', required: false)
+
+  if not jpeg_dep.found() and cc.has_header('jpeglib.h')
     jpeg_dep = cc.find_library('jpeg', required: false)
     if cc.get_id() == 'msvc' and not jpeg_dep.found()
       # The IJG JPEG library builds the .lib file as libjpeg.lib in its MSVC build system,
       # so look for it as well when jpeg.lib cannot be found
       jpeg_dep = cc.find_library('libjpeg', required: false)
     endif
-
-    if jpeg_dep.found()
-      enabled_loaders += 'jpeg'
-      loaders_deps += jpeg_dep
-    endif
   endif
 
   # If we couldn't find libjpeg in our include/linker paths,
   # then use pkg-config, and if that fails, fall back to the
   # wrap
-  if not enabled_loaders.contains('jpeg')
+  if not jpeg_dep.found()
     jpeg_dep = dependency('libjpeg', required: false, fallback: ['libjpeg', 'jpeg_dep'])
-
-    if jpeg_dep.found()
-      enabled_loaders += 'jpeg'
-      loaders_deps += jpeg_dep
-    endif
   endif
 
   if jpeg_dep.found()
+    enabled_loaders += 'jpeg'
+    loaders_deps += jpeg_dep
+
     if jpeg_dep.type_name() == 'internal'
       has_destroy_decompress = true
       has_simple_progression = true


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]