OSX: cmake finding older libpng library even though brew installs latest

I have a Github workflow that requires version 1.16 of libpng. However, on osx,
cmake Find finds an older version 1.14 of the library

Run brew install libpng 
Warning: libpng 1.6.37 is already installed and up-to-date.
To reinstall 1.6.37, run:

...

-- Found PNG: /usr/local/lib/libpng.dylib (found version "1.4.12") 
-- The system seems to have a libpnb available, it will be used to support PNG files

Any ideas on how to make cmake find the brew version ?

You should be able to add /usr/local to CMAKE_PREFIX_PATH. I suspect /usr/local is just “behind” in the search path. Alternatively, it could be finding the library from brew and the headers (where the version number is extracted from) from the SDK. I’d look at the cache variables associated with PNG and see that they all “agree” that they found the same installation.

1 Like