• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# cmake file for libpng
2
3if (NOT DE_DEFS)
4	message(FATAL_ERROR "Include Defs.cmake")
5endif ()
6
7if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/src/png.h")
8	set(DEFAULT_PNG_SRC_PATH ${CMAKE_CURRENT_SOURCE_DIR}/src)
9else ()
10	# Assume build inside Android source tree
11	set(DEFAULT_PNG_SRC_PATH "../libpng")
12endif ()
13
14set(PNG_SRC_PATH ${DEFAULT_PNG_SRC_PATH} CACHE STRING "Path to libpng source tree")
15
16if (IS_ABSOLUTE ${PNG_SRC_PATH})
17	set(PNG_ABS_PATH ${PNG_SRC_PATH})
18else ()
19	set(PNG_ABS_PATH "${CMAKE_SOURCE_DIR}/${PNG_SRC_PATH}")
20endif ()
21
22set(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
43if(DE_CPU_IS_ARM AND NOT DEFINED DE_CPU_IS_ARM_NEON)
44    set(DE_CPU_IS_ARM_NEON 1)
45    message(STATUS "DE_CPU_IS_ARM_NEON is not defined: Assuming ARM NEON is supported.")
46else ()
47    set(DE_CPU_IS_ARM_NEON 0)
48endif()
49
50if (DE_CPU_IS_ARM_64 OR (DE_CPU_IS_ARM AND DE_CPU_IS_ARM_NEON))
51	# armv8-a has always neon
52	set(PNG_SRCS
53		${PNG_SRCS}
54		${PNG_ABS_PATH}/arm/arm_init.c
55		${PNG_ABS_PATH}/arm/filter_neon_intrinsics.c
56		${PNG_ABS_PATH}/arm/filter_neon.S
57		)
58else ()
59    message(STATUS "Disabling ARM NEON optimizations.")
60    add_definitions(-DPNG_ARM_NEON_OPT=0)
61endif ()
62
63
64if (DE_DEBUG EQUAL 1)
65	add_definitions(-DPNG_DEBUG)
66endif ()
67
68if (DE_OS_IS_UNIX OR DE_OS_IS_QNX)
69	# for snprintf()
70	add_definitions(-D_XOPEN_SOURCE=600)
71endif ()
72
73set(CMAKE_C_FLAGS ${DE_3RD_PARTY_C_FLAGS})
74
75add_library(png STATIC ${PNG_SRCS})
76target_link_libraries(png ${ZLIB_LIBRARY})
77
78set(PNG_INCLUDE_PATH	${PNG_ABS_PATH}	PARENT_SCOPE)
79set(PNG_LIBRARY			png				PARENT_SCOPE)
80