comparison Resources/CMake/PixmanConfiguration.cmake @ 0:351ab0da0150

initial commit
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 14 Oct 2016 15:34:11 +0200
parents
children 490347621f42
comparison
equal deleted inserted replaced
-1:000000000000 0:351ab0da0150
1 if (STATIC_BUILD OR NOT USE_SYSTEM_PIXMAN)
2 SET(PIXMAN_SOURCES_DIR ${CMAKE_BINARY_DIR}/pixman-0.34.0)
3 SET(PIXMAN_URL "http://www.montefiore.ulg.ac.be/~jodogne/Orthanc/ThirdPartyDownloads/Stone/pixman-0.34.0.tar.gz")
4 SET(PIXMAN_MD5 "e80ebae4da01e77f68744319f01d52a3")
5
6 if (IS_DIRECTORY "${PIXMAN_SOURCES_DIR}")
7 set(FirstRun OFF)
8 else()
9 set(FirstRun ON)
10 endif()
11
12 DownloadPackage(${PIXMAN_MD5} ${PIXMAN_URL} "${PIXMAN_SOURCES_DIR}")
13
14 # Apply a patch for NaCl32: This bypasses the custom implementation of
15 # "cpuid" that makes use of assembly code leading to "unrecognized
16 # instruction" when validating ".nexe" files using "ncval"
17 execute_process(
18 COMMAND ${PATCH_EXECUTABLE} -p0 -N -i ${CMAKE_CURRENT_LIST_DIR}/PixmanConfiguration.patch
19 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
20 RESULT_VARIABLE Failure
21 )
22
23 if (Failure AND FirstRun)
24 message(FATAL_ERROR "Error while patching a file")
25 endif()
26
27 set(PIXMAN_VERSION_MAJOR 0)
28 set(PIXMAN_VERSION_MINOR 34)
29 set(PIXMAN_VERSION_MICRO 0)
30 configure_file(
31 ${PIXMAN_SOURCES_DIR}/pixman/pixman-version.h.in
32 ${PIXMAN_SOURCES_DIR}/pixman/pixman-version.h)
33
34 list(APPEND PIXMAN_SOURCES
35 ${PIXMAN_SOURCES_DIR}/pixman/pixman-access-accessors.c
36 ${PIXMAN_SOURCES_DIR}/pixman/pixman-access.c
37 ${PIXMAN_SOURCES_DIR}/pixman/pixman-arm.c
38 #${PIXMAN_SOURCES_DIR}/pixman/pixman-arm-neon.c
39 #${PIXMAN_SOURCES_DIR}/pixman/pixman-arm-simd.c
40 ${PIXMAN_SOURCES_DIR}/pixman/pixman-bits-image.c
41 ${PIXMAN_SOURCES_DIR}/pixman/pixman.c
42 ${PIXMAN_SOURCES_DIR}/pixman/pixman-combine32.c
43 ${PIXMAN_SOURCES_DIR}/pixman/pixman-combine-float.c
44 ${PIXMAN_SOURCES_DIR}/pixman/pixman-conical-gradient.c
45 ${PIXMAN_SOURCES_DIR}/pixman/pixman-edge-accessors.c
46 ${PIXMAN_SOURCES_DIR}/pixman/pixman-edge.c
47 ${PIXMAN_SOURCES_DIR}/pixman/pixman-fast-path.c
48 ${PIXMAN_SOURCES_DIR}/pixman/pixman-filter.c
49 ${PIXMAN_SOURCES_DIR}/pixman/pixman-general.c
50 ${PIXMAN_SOURCES_DIR}/pixman/pixman-glyph.c
51 ${PIXMAN_SOURCES_DIR}/pixman/pixman-gradient-walker.c
52 ${PIXMAN_SOURCES_DIR}/pixman/pixman-image.c
53 ${PIXMAN_SOURCES_DIR}/pixman/pixman-implementation.c
54 ${PIXMAN_SOURCES_DIR}/pixman/pixman-linear-gradient.c
55 ${PIXMAN_SOURCES_DIR}/pixman/pixman-matrix.c
56 ${PIXMAN_SOURCES_DIR}/pixman/pixman-mips.c
57 #${PIXMAN_SOURCES_DIR}/pixman/pixman-mips-dspr2.c
58 ${PIXMAN_SOURCES_DIR}/pixman/pixman-mmx.c
59 ${PIXMAN_SOURCES_DIR}/pixman/pixman-noop.c
60 ${PIXMAN_SOURCES_DIR}/pixman/pixman-ppc.c
61 ${PIXMAN_SOURCES_DIR}/pixman/pixman-radial-gradient.c
62 ${PIXMAN_SOURCES_DIR}/pixman/pixman-region16.c
63 ${PIXMAN_SOURCES_DIR}/pixman/pixman-region32.c
64 #${PIXMAN_SOURCES_DIR}/pixman/pixman-region.c
65 ${PIXMAN_SOURCES_DIR}/pixman/pixman-solid-fill.c
66 #${PIXMAN_SOURCES_DIR}/pixman/pixman-sse2.c
67 #${PIXMAN_SOURCES_DIR}/pixman/pixman-ssse3.c
68 ${PIXMAN_SOURCES_DIR}/pixman/pixman-timer.c
69 ${PIXMAN_SOURCES_DIR}/pixman/pixman-trap.c
70 ${PIXMAN_SOURCES_DIR}/pixman/pixman-utils.c
71 #${PIXMAN_SOURCES_DIR}/pixman/pixman-vmx.c
72 ${PIXMAN_SOURCES_DIR}/pixman/pixman-x86.c
73 )
74
75 set(PIXMAN_DEFINITIONS "PACKAGE=\"pixman\"")
76
77 if (CMAKE_SYSTEM_PROCESSOR)
78 message("Processor: ${CMAKE_SYSTEM_PROCESSOR}")
79 else()
80 message("Processor: Not applicable")
81 endif()
82
83
84 if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
85
86 ##########################
87 ## Windows 32 or 64
88 ##########################
89
90 if (CMAKE_COMPILER_IS_GNUCXX)
91 set(PIXMAN_DEFINITIONS "${PIXMAN_DEFINITIONS};TLS=__thread;HAVE_GCC_VECTOR_EXTENSIONS;HAVE_BUILTIN_CLZ;HAVE_FEDIVBYZERO=1;HAVE_FENV_H=1;HAVE_MPROTECT=1;HAVE_FLOAT128;HAVE_POSIX_MEMALIGN;USE_GCC_INLINE_ASM=1;HAVE_GETPAGESIZE=1")
92
93 # The option "-mstackrealign" is necessary to avoid a crash on
94 # Windows if enabling SSE2. As an alternative, it is possible to
95 # fully disable hardware acceleration.
96 # https://bugs.freedesktop.org/show_bug.cgi?id=68300#c4
97 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse2 -mssse3 -mstackrealign")
98 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse2 -mssse3 -mstackrealign")
99 endif()
100
101 list(APPEND PIXMAN_SOURCES
102 ${PIXMAN_SOURCES_DIR}/pixman/pixman-sse2.c
103 ${PIXMAN_SOURCES_DIR}/pixman/pixman-ssse3.c
104 )
105 add_definitions(
106 -DUSE_X86_MMX=1
107 -DUSE_SSE2=1
108 -DUSE_SSSE3=1
109 )
110
111
112 ##########################
113 ## Generic x86 processor
114 ##########################
115
116 elseif (CMAKE_SYSTEM_PROCESSOR STREQUAL "x86" OR
117 CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" OR
118 CMAKE_SYSTEM_NAME STREQUAL "NaCl32" OR
119 CMAKE_SYSTEM_NAME STREQUAL "NaCl64")
120
121 set(PIXMAN_DEFINITIONS "${PIXMAN_DEFINITIONS};TLS=__thread;HAVE_GCC_VECTOR_EXTENSIONS;HAVE_BUILTIN_CLZ;HAVE_MPROTECT=1;HAVE_FLOAT128;HAVE_POSIX_MEMALIGN;USE_GCC_INLINE_ASM;HAVE_GETPAGESIZE=1")
122
123 if (${CMAKE_SYSTEM_NAME} STREQUAL "NaCl32" OR
124 ${CMAKE_SYSTEM_NAME} STREQUAL "NaCl64")
125 # The MMX instructions lead to "unrecognized instruction" when
126 # validating ".nexe" files using "ncval", disable them
127 else()
128 #add_definitions(-DUSE_X86_MMX=1)
129 endif()
130
131 list(APPEND PIXMAN_SOURCES
132 ${PIXMAN_SOURCES_DIR}/pixman/pixman-sse2.c
133 ${PIXMAN_SOURCES_DIR}/pixman/pixman-ssse3.c
134 )
135 add_definitions(
136 -DUSE_SSE2=1
137 -DUSE_SSSE3=1
138 )
139 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse2 -mssse3")
140 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse2 -mssse3")
141
142
143 ##########################
144 ## ARM processor
145 ##########################
146
147 elseif (CMAKE_SYSTEM_PROCESSOR STREQUAL "armv5te" OR
148 CMAKE_SYSTEM_PROCESSOR STREQUAL "armv6" OR
149 CMAKE_SYSTEM_PROCESSOR STREQUAL "armv7-a" OR
150 CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64")
151
152 set(PIXMAN_DEFINITIONS "${PIXMAN_DEFINITIONS};TLS=__thread")
153
154 if (NEON)
155 message("Processor with NEON instructions")
156 list(APPEND PIXMAN_SOURCES
157 ${PIXMAN_SOURCES_DIR}/pixman/pixman-arm-neon.c
158 ${PIXMAN_SOURCES_DIR}/pixman/pixman-arm-neon-asm.S
159 ${PIXMAN_SOURCES_DIR}/pixman/pixman-arm-neon-asm-bilinear.S
160 )
161 add_definitions(
162 -DUSE_ARM_NEON=1
163 )
164 elseif()
165 message("Processor without NEON instructions")
166 endif()
167
168 add_definitions(
169 -DUSE_ARM_SIMD=1
170 )
171 list(APPEND PIXMAN_SOURCES
172 ${PIXMAN_SOURCES_DIR}/pixman/pixman-arm.c
173 ${PIXMAN_SOURCES_DIR}/pixman/pixman-arm-simd-asm.S
174 ${PIXMAN_SOURCES_DIR}/pixman/pixman-arm-simd-asm-scaled.S
175 ${PIXMAN_SOURCES_DIR}/pixman/pixman-arm-simd.c
176 )
177
178 ##########################
179 ## Portable Google NaCl
180 ##########################
181
182 elseif (CMAKE_SYSTEM_NAME STREQUAL "PNaCl")
183 # No hardware acceleration
184 set(PIXMAN_DEFINITIONS "${PIXMAN_DEFINITIONS};TLS=__thread")
185
186 else()
187 message(FATAL_ERROR "Support your platform here")
188 endif()
189
190
191 include_directories(
192 ${PIXMAN_SOURCES_DIR}/pixman
193 )
194
195 set_property(
196 SOURCE ${PIXMAN_SOURCES}
197 PROPERTY COMPILE_DEFINITIONS ${PIXMAN_DEFINITIONS}
198 )
199
200 else()
201
202 pkg_search_module(PIXMAN REQUIRED pixman-1)
203 include_directories(${PIXMAN_INCLUDE_DIRS})
204 link_libraries(${PIXMAN_LIBRARIES})
205
206 endif()