This repository has been archived by the owner on Jun 8, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 59
/
CMakeLists.txt
201 lines (180 loc) · 5.46 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
project(azure)
cmake_minimum_required(VERSION 2.8)
function(set_prefix var prefix)
string(REGEX REPLACE "(^|;)([^;]+)" "\\1${prefix}\\2" tmp "${ARGN}")
set(${var} "${tmp}" PARENT_SCOPE)
endfunction()
# Use ccache if we're told to.
if(DEFINED ENV{CCACHE})
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE $ENV{CCACHE})
endif()
if(MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Zi")
# TODO(vlad): we need to update our copy of Moz2D!
# VS2015/VC 14.0 needs this -- we should be using unordered_set instead of hash_set
add_definitions(-D_SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS)
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g")
endif()
if("$ENV{CFG_ENABLE_DEBUG_SKIA}" STREQUAL "1")
add_definitions(
-DDSK_DEBUG
-DGR_DEBUG=1
-DGR_GL_LOG_CALLS=1
-DGR_GL_LOG_CALLS_START=1
)
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2")
add_definitions(
-DSK_RELEASE
-DGR_RELEASE=1
)
endif()
file(GLOB MOZ2D_H libazure/*.h)
file(GLOB MOZ2D_INTERNAL_H libazure/mozilla/*.h)
set(LIBAZURE_H ${MOZ2D_H} ${MOZ2D_INTERNAL_H})
# Pull in Skia headers
include_directories(
$ENV{DEP_SKIA_OUTDIR}/include
$ENV{DEP_SKIA_OUTDIR}/include/core
$ENV{DEP_SKIA_OUTDIR}/include/config
$ENV{DEP_SKIA_OUTDIR}/include/effects
$ENV{DEP_SKIA_OUTDIR}/include/ports
$ENV{DEP_SKIA_OUTDIR}/include/utils
$ENV{DEP_SKIA_OUTDIR}/include/gpu
$ENV{DEP_SKIA_OUTDIR}/include/gpu/gl
$ENV{DEP_SKIA_OUTDIR}/src
)
if(NOT APPLE AND NOT WIN32)
if(NOT "$ENV{DEP_FREETYPE_OUTDIR}" STREQUAL "")
include_directories($ENV{DEP_FREETYPE_OUTDIR}/include/freetype2)
message(STATUS "Using DEP_FREETYPE_OUTDIR/include/freetype2: " $ENV{DEP_FREETYPE_OUTDIR})
else()
# We need to work with older cmake -- pkg_check_modules was added in
# a version of cmake newer than what Ubuntu 14.04 LTS ships with.
#pkg_check_modules(FREETYPE REQUIRED freetype2)
EXEC_PROGRAM(pkg-config ARGS --cflags freetype2 OUTPUT_VARIABLE FREETYPE_CFLAGS RESULT_VARIABLE FREETYPE_NOT_FOUND)
if(FREETYPE_NOT_FOUND)
message(FATAL_ERROR "Freetype is required by rust-azure for this build, but it was not built by the freetype crate nor found by pkg-config")
endif()
EXEC_PROGRAM(pkg-config ARGS --libs freetype2 OUTPUT_VARIABLE FREETYPE_CLDFLAGS)
message(STATUS "Using FREETYPE_CFLAGS: " ${FREETYPE_CFLAGS})
message(STATUS "Using FREETYPE_CLDFLAGS: " ${FREETYPE_CLDFLAGS})
add_definitions(${FREETYPE_CFLAGS})
link_libraries(${FREETYPE_CLDFLAGS})
endif()
endif()
add_definitions(-DUSE_SKIA -DUSE_SKIA_GPU)
add_definitions(-DMOZ_WARN_UNUSED_RESULT="")
# Azure bindings
set_prefix(BINDINGS_SRC src/
azure-c.cpp
azure-c.h
)
# Core azure library
set_prefix(LIBAZURE_SRC libazure/
Blur.cpp
convolver.cpp
DataSourceSurface.cpp
DataSurfaceHelpers.cpp
DrawEventRecorder.cpp
DrawTargetCapture.cpp
DrawTarget.cpp
DrawTargetDual.cpp
DrawTargetRecording.cpp
DrawTargetSkia.cpp
DrawTargetTiled.cpp
Factory.cpp
FilterNodeSoftware.cpp
FilterProcessing.cpp
FilterProcessingScalar.cpp
ImageScaling.cpp
Matrix.cpp
Path.cpp
PathHelpers.cpp
PathRecording.cpp
PathSkia.cpp
RecordedEvent.cpp
ScaledFontBase.cpp
ScaledFontSkia.cpp
SourceSurfaceRawData.cpp
SourceSurfaceSkia.cpp
)
set_prefix(LIBAZURE_X86_SRC libazure/
BlurSSE2.cpp
FilterProcessingSSE2.cpp
ImageScalingSSE2.cpp
convolverSSE2.cpp
)
if(APPLE)
add_definitions(-DXP_MACOSX -DXP_UNIX -Dtypeof=__typeof__)
set_prefix(LIBAZURE_PLATFORM_SRC libazure/
DrawTargetCG.cpp
MacIOSurface.cpp
PathCG.cpp
ScaledFontMac.cpp
SourceSurfaceCG.cpp
)
endif() # MacOS X
if(WIN32)
add_definitions(-DWIN32 -DXP_WIN -D_WIN32_WINNT=0x0600 -DSK_BUILD_FOR_WIN32)
if(MSVC)
# Enable C++ exceptions; extern "c" defaults to nothrow
add_definitions(-EHsc)
endif()
set_prefix(LIBAZURE_PLATFORM_SRC libazure/
DrawTargetD2D.cpp
SourceSurfaceD2D.cpp
SourceSurfaceD2DTarget.cpp
ScaledFontWin.cpp
ScaledFontDWrite.cpp
PathD2D.cpp
)
endif()
if($ENV{TARGET} MATCHES ".*android.*")
add_definitions(-DXP_UNIX -DSK_BUILD_FOR_ANDROID -DMOZ_ENABLE_FREETYPE)
elseif($ENV{TARGET} MATCHES linux)
add_definitions(-DXP_UNIX -DSK_BUILD_FOR_UNIX -DMOZ_ENABLE_FREETYPE)
endif()
set(ALL_SRC
${BINDINGS_SRC}
${LIBAZURE_SRC}
${LIBAZURE_PLATFORM_SRC}
${LIBAZURE_H}
)
if(NOT WIN32)
# Should we use -fPIE instead?
add_definitions(-fPIC)
endif()
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_definitions(-std=gnu++11)
endif()
if($ENV{TARGET} MATCHES "(i386|x86_64)-.*")
set(ALL_SRC ${ALL_SRC} ${LIBAZURE_X86_SRC})
add_definitions(-DUSE_SSE2)
if(NOT MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse2 -mfpmath=sse")
else()
# /arch:SSE2 is invalid on x86-64 (SSE2 always present)
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /arch:SSE2")
endif()
endif()
elseif($ENV{TARGET} MATCHES "arm-.*")
add_definitions(-mfpu=neon -D__ARM_HAVE_OPTIONAL_NEON_SUPPORT)
# FIXME: Need more advanced detection of FP support
if($ENV{TARGET} MATCHES "eabihf")
add_definitions(-mfloat-abi=hard)
else()
add_definitions(-mfloat-abi=softfp)
endif()
if(NOT "$ENV{TARGET}" STREQUAL "$ENV{HOST}")
# FIXME: Assumes armv7 for cross compile
add_definitions(-march=armv7-a -mthumb)
endif()
elseif($ENV{TARGET} MATCHES "aarch64-.*")
add_definitions(-D__ARM_HAVE_NEON)
endif()
include_directories(libazure)
add_library(azure STATIC ${ALL_SRC})
install(TARGETS azure ARCHIVE DESTINATION lib)