extern/libpng: Use find_library

This commit is contained in:
Luke Street 2020-06-13 17:18:57 -04:00
parent b817b2624b
commit 7b1500da2a
1 changed files with 8 additions and 7 deletions

View File

@ -1,7 +1,8 @@
find_package(PNG)
if(NOT PNG_FOUND)
if(NOT WIN32) # remove when specter/freetype is gone
find_library(PNG_LIB NAMES png libpng)
endif()
if(NOT PNG_LIB)
message(STATUS "Using HECL's built-in libpng")
include_directories(${ZLIB_INCLUDE_DIR})
add_library(png
png.h
pngconf.h
@ -26,11 +27,11 @@ add_library(png
pngwrite.c
pngwtran.c
pngwutil.c)
set(PNG_LIBRARIES png CACHE PATH "PNG library" FORCE)
target_link_libraries(png PUBLIC ${ZLIB_LIBRARIES})
target_include_directories(png PUBLIC ${ZLIB_INCLUDE_DIR})
set(PNG_LIBRARIES png CACHE PATH "PNG libraries" FORCE)
set(PNG_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR} CACHE PATH "PNG include path" FORCE)
else()
set(PNG_LIBRARIES ${PNG_LIB} CACHE PATH "PNG libraries" FORCE)
find_path(PNG_INCLUDE_DIR png.h)
set(PNG_LIBRARIES ${PNG_LIBRARIES} CACHE PATH "PNG library" FORCE)
endif()