FindPNG: add 'm' dependencies to static lib on Linux

This commit is contained in:
David Callu 2019-11-28 12:15:20 +01:00
parent 7fe99b813c
commit ad41c98cbb

View File

@ -94,6 +94,10 @@ if(ZLIB_FOUND)
set(PNG_INCLUDE_DIRS ${PNG_PNG_INCLUDE_DIR} ${ZLIB_INCLUDE_DIR} )
set(PNG_INCLUDE_DIR ${PNG_INCLUDE_DIRS} ) # for backward compatibility
set(PNG_LIBRARIES ${PNG_LIBRARY} ${ZLIB_LIBRARY})
if((CMAKE_SYSTEM_NAME STREQUAL "Linux") AND
("${PNG_LIBRARY}" MATCHES "\\${CMAKE_STATIC_LIBRARY_SUFFIX}$"))
list(APPEND PNG_LIBRARIES m)
endif()
if (CYGWIN)
if(BUILD_SHARED_LIBS)
@ -110,6 +114,12 @@ if(ZLIB_FOUND)
INTERFACE_COMPILE_DEFINITIONS "${_PNG_COMPILE_DEFINITIONS}"
INTERFACE_INCLUDE_DIRECTORIES "${PNG_INCLUDE_DIRS}"
INTERFACE_LINK_LIBRARIES ZLIB::ZLIB)
if((CMAKE_SYSTEM_NAME STREQUAL "Linux") AND
("${PNG_LIBRARY}" MATCHES "\\${CMAKE_STATIC_LIBRARY_SUFFIX}$"))
set_property(TARGET PNG::PNG APPEND PROPERTY
INTERFACE_LINK_LIBRARIES m)
endif()
if(EXISTS "${PNG_LIBRARY}")
set_target_properties(PNG::PNG PROPERTIES
IMPORTED_LINK_INTERFACE_LANGUAGES "C"