Pull in external libpng dependencies properly (#770)

PNG_LIBRARY set by libpng's FindPNG.cmake does not contain zlib dependancy.  This causes the CHECK_FUNCTION_EXISTS(png_create_read_struct LIBPNG_IS_GOOD) to fail with liner errors, and for dlib to use it's internal copy of PNG.

Updated to use libpng's PNG_LIBRARIES variable.  This also sets both PNG and ZLib libraries in dlib_needed_libraries.
This commit is contained in:
ipeterson 2017-08-23 18:33:52 -07:00 committed by Davis E. King
parent 9ba7889f0f
commit faa75fa9f7
1 changed files with 2 additions and 2 deletions

View File

@ -343,12 +343,12 @@ if (NOT TARGET dlib)
# Make sure there isn't something wrong with the version of LIBPNG # Make sure there isn't something wrong with the version of LIBPNG
# installed on this system. # installed on this system.
if (PNG_FOUND) if (PNG_FOUND)
set(CMAKE_REQUIRED_LIBRARIES ${PNG_LIBRARY}) set(CMAKE_REQUIRED_LIBRARIES ${PNG_LIBRARIES})
CHECK_FUNCTION_EXISTS(png_create_read_struct LIBPNG_IS_GOOD) CHECK_FUNCTION_EXISTS(png_create_read_struct LIBPNG_IS_GOOD)
endif() endif()
if (PNG_FOUND AND LIBPNG_IS_GOOD) if (PNG_FOUND AND LIBPNG_IS_GOOD)
include_directories(${PNG_INCLUDE_DIR}) include_directories(${PNG_INCLUDE_DIR})
set (dlib_needed_libraries ${dlib_needed_libraries} ${PNG_LIBRARY}) set (dlib_needed_libraries ${dlib_needed_libraries} ${PNG_LIBRARIES})
set(REQUIRES_LIBS " libpng") set(REQUIRES_LIBS " libpng")
else() else()
# If we can't find libpng then statically compile it in. # If we can't find libpng then statically compile it in.