Home | History | Annotate | Download | only in libpng
      1 # cmake file for libpng
      2 
      3 if (NOT DE_DEFS)
      4 	message(FATAL_ERROR "Include Defs.cmake")
      5 endif ()
      6 
      7 if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/png.h")
      8 	set(DEFAULT_PNG_SRC_PATH ${CMAKE_CURRENT_SOURCE_DIR})
      9 else ()
     10 	# Assume build inside Android source tree
     11 	set(DEFAULT_PNG_SRC_PATH "../libpng")
     12 endif ()
     13 
     14 set(PNG_SRC_PATH ${DEFAULT_PNG_SRC_PATH} CACHE STRING "Path to libpng source tree")
     15 
     16 if (IS_ABSOLUTE ${PNG_SRC_PATH})
     17 	set(PNG_ABS_PATH ${PNG_SRC_PATH})
     18 else ()
     19 	set(PNG_ABS_PATH "${CMAKE_SOURCE_DIR}/${PNG_SRC_PATH}")
     20 endif ()
     21 
     22 set(PNG_SRCS
     23 	${PNG_ABS_PATH}/png.h
     24 	${PNG_ABS_PATH}/pngconf.h
     25 	${PNG_ABS_PATH}/png.c
     26 	${PNG_ABS_PATH}/pngset.c
     27 	${PNG_ABS_PATH}/pngget.c
     28 	${PNG_ABS_PATH}/pngrutil.c
     29 	${PNG_ABS_PATH}/pngtrans.c
     30 	${PNG_ABS_PATH}/pngwutil.c
     31 	${PNG_ABS_PATH}/pngread.c
     32 	${PNG_ABS_PATH}/pngrio.c
     33 	${PNG_ABS_PATH}/pngwio.c
     34 	${PNG_ABS_PATH}/pngwrite.c
     35 	${PNG_ABS_PATH}/pngrtran.c
     36 	${PNG_ABS_PATH}/pngwtran.c
     37 	${PNG_ABS_PATH}/pngmem.c
     38 	${PNG_ABS_PATH}/pngerror.c
     39 	${PNG_ABS_PATH}/pngpread.c
     40 	)
     41 
     42 if (DE_CPU_IS_ARM_64)
     43 	# armv8-a has always neon
     44 	set(PNG_SRCS
     45 		${PNG_SRCS}
     46 		${PNG_ABS_PATH}/arm/arm_init.c
     47 		${PNG_ABS_PATH}/arm/filter_neon_intrinsics.c
     48 		${PNG_ABS_PATH}/arm/filter_neon.S
     49 		)
     50 endif ()
     51 
     52 if (DE_DEBUG EQUAL 1)
     53 	add_definitions(-DPNG_DEBUG)
     54 endif ()
     55 
     56 if (DE_OS_IS_UNIX)
     57 	# for snprintf()
     58 	add_definitions(-D_XOPEN_SOURCE=600)
     59 endif ()
     60 
     61 set(CMAKE_C_FLAGS ${DE_3RD_PARTY_C_FLAGS})
     62 
     63 add_library(png STATIC ${PNG_SRCS})
     64 target_link_libraries(png ${ZLIB_LIBRARY})
     65 
     66 set(PNG_INCLUDE_PATH	${PNG_ABS_PATH}	PARENT_SCOPE)
     67 set(PNG_LIBRARY			png				PARENT_SCOPE)
     68