From c879308ad65712a6415d544e11d1cb585b372cf4 Mon Sep 17 00:00:00 2001 From: s0600204 Date: Wed, 3 Mar 2021 16:11:41 +0000 Subject: [PATCH] Use pkgconfig to find libpng Should hopefully resolve an issue raised on IRC by @spcman and @Xavi92 Reviewed By: wraitii Differential Revision: https://code.wildfiregames.com/D3610 This was SVN commit r24998. --- build/premake/extern_libs5.lua | 23 +++++++++++------------ build/workspaces/update-workspaces.sh | 1 + 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/build/premake/extern_libs5.lua b/build/premake/extern_libs5.lua index 275438bd39..51820b70cc 100644 --- a/build/premake/extern_libs5.lua +++ b/build/premake/extern_libs5.lua @@ -411,24 +411,23 @@ extern_lib_defs = { }, libpng = { compile_settings = function() - if os.istarget("windows") or os.istarget("macosx") then + if os.istarget("windows") then add_default_include_paths("libpng") - end - if os.getversion().description == "OpenBSD" then - sysincludedirs { "/usr/local/include/libpng" } + else + -- Support LIBPNG_CONFIG for overriding the default (pkg-config --cflags libpng) + -- i.e. on OSX where it gets set in update-workspaces.sh + pkgconfig.add_includes("libpng", os.getenv("LIBPNG_CONFIG")) end end, link_settings = function() - if os.istarget("windows") or os.istarget("macosx") then + if os.istarget("windows") then add_default_lib_paths("libpng") + add_default_links({ + win_names = { "libpng16" }, + }) + else + pkgconfig.add_links("libpng", os.getenv("LIBPNG_CONFIG"), "--ldflags") end - add_default_links({ - win_names = { "libpng16" }, - unix_names = { "png" }, - -- Otherwise ld will sometimes pull in ancient 1.2 from the SDK, which breaks the build :/ - -- TODO: Figure out why that happens - osx_names = { "png16" }, - }) end, }, libsodium = { diff --git a/build/workspaces/update-workspaces.sh b/build/workspaces/update-workspaces.sh index 36848e0c19..e266660077 100755 --- a/build/workspaces/update-workspaces.sh +++ b/build/workspaces/update-workspaces.sh @@ -73,6 +73,7 @@ if [ "`uname -s`" = "Darwin" ]; then # Set *_CONFIG variables on OS X, to override the path to e.g. sdl2-config export GLOOX_CONFIG=${GLOOX_CONFIG:="$(pwd)/../../libraries/osx/gloox/bin/gloox-config"} export ICU_CONFIG=${ICU_CONFIG:="$(pwd)/../../libraries/osx/icu/bin/icu-config"} + export LIBPNG_CONFIG=${PNG_CONFIG:="$(pwd)/../../libraries/osx/libpng/bin/libpng-config"} export SDL2_CONFIG=${SDL2_CONFIG:="$(pwd)/../../libraries/osx/sdl2/bin/sdl2-config"} export WX_CONFIG=${WX_CONFIG:="$(pwd)/../../libraries/osx/wxwidgets/bin/wx-config"} export XML2_CONFIG=${XML2_CONFIG:="$(pwd)/../../libraries/osx/libxml2/bin/xml2-config"}