[cmake-developers] FindPNG.cmake doesn't return a LIBRARY_DIR variable

René J. V. Bertin rjvbertin at gmail.com
Wed Jul 12 12:21:04 EDT 2017


Rolf Eike Beer wrote:


> First, FindPNG.cmake doesn't care about pkg-config files, if that is bug

Yes, I noticed that after I wrote the remark about the pkg-config files, and 
didn't think to remove it (= I diagnosed the issue while writing the message).

> or feature depends on your personal things. CMake will detect the
> library using the full path (as it has done), and construct proper -L
> and -l from that. It doesn't happen here, which makes me suspect that
> you don't even link to ${PNG_LIBRARIES} or PNG::PNG (the latter being

>From the CMake file (digikam-5.6.0/core/app/CMakeLists.txt):

target_link_libraries(digikamcore
                      PUBLIC

                      Qt5::Core
                      Qt5::Gui
                      Qt5::Xml
                      Qt5::Widgets
                      Qt5::Sql
                      Qt5::WebKitWidgets
                      Qt5::PrintSupport
                      Qt5::Concurrent

                      KF5::Solid
                      KF5::WindowSystem
                      KF5::ConfigGui
                      KF5::CoreAddons
                      KF5::Service
                      KF5::XmlGui
                      KF5::I18n

                      # Required by CImg which use pthread internally.

                      ${CMAKE_THREAD_LIBS_INIT}

                      ${LCMS2_LIBRARIES} # filters

                      ${TIFF_LIBRARIES}
                      ${PNG_LIBRARIES}
                      ${EXIV2_LIBRARIES}

                      libdng
                      libraw
)


> the better version). It seems to me like the -lpng you see comes from
> QtWebkitWidgets, which would also need to be linked against your library

It does and is, but I don't find a reference to libpng in its cmake modules (nor 
in any other of Qt5's modules, for that matter).
So while your hypothesis seems reasonable I don't see where the -lpng would be 
added by Qt's modules. (FWIW, QtWebKit also has a .pc file, but it doesn't add -
lz after -lpng so unless someone reorders the link library order that file cannot 
be the source of the issue either.)

I've asked a more generic question about fully-qualified path conversion to -lfoo 
on the general ML ("/path/to/libpng.so automatic conversion to -lpng").

R.




More information about the cmake-developers mailing list