-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCMakeLists.txt
204 lines (164 loc) · 6.48 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
202
203
204
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12 FATAL_ERROR)
PROJECT(Skia-C)
OPTION(TREAT_WARNINGS_AS_ERRORS "Treat compiler warnings as errors. We use the highest warnings levels for compilers." OFF)
IF(MSVC)
SET(MSVC_INSTALL_PATH "${PROJECT_SOURCE_DIR}/Windows")
SET(CMAKE_PREFIX_PATH "${CMAKE_PREFIX_PATH};${MSVC_INSTALL_PATH}")
IF(MSVC10)
SET(MSVC_VERSION_STRING vc100)
ELSEIF(MSVC11)
SET(MSVC_VERSION_STRING vc110)
ELSEIF(MSVC90)
SET(MSVC_VERSION_STRING vc90)
ELSEIF(MSVC80)
SET(MSVC_VERSION_STRING vc80)
ENDIF()
# !FIXME! Actually detect compiler architecture version....
IF( CMAKE_SIZEOF_VOID_P EQUAL 8 )
SET(MSVC_ARCHITECTURE_STRING x64)
ELSE()
SET(MSVC_ARCHITECTURE_STRING x86)
ENDIF()
SET(MSVC_LIB_DIR "${MSVC_INSTALL_PATH}/lib/${MSVC_ARCHITECTURE_STRING}/${MSVC_VERSION_STRING}")
SET(CMAKE_LIBRARY_PATH "${CMAKE_LIBRARY_PATH};${MSVC_LIB_DIR}")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
ELSEIF(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -fms-extensions")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -fms-extensions")
ENDIF(MSVC)
IF(TREAT_WARNINGS_AS_ERRORS)
IF(MSVC)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /WX")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /WX")
ELSEIF(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
ENDIF(MSVC)
ENDIF(TREAT_WARNINGS_AS_ERRORS)
FIND_PACKAGE(OpenGL)
IF(NOT OPENGL_FOUND)
MESSAGE("OpenGL not found... skipping GPU build")
ENDIF()
FIND_PACKAGE(Freetype)
IF(NOT FREETYPE_FOUND)
MESSAGE(FATAL_ERROR "FreeType library not found...")
ENDIF()
FIND_PACKAGE(PNG)
IF(NOT PNG_FOUND)
MESSAGE(FATAL_ERROR "PNG library not found...")
ENDIF()
FIND_PACKAGE(GIF)
IF(NOT GIF_FOUND)
MESSAGE(FATAL_ERROR "GIF library not found...")
ENDIF()
#######
## FontConfig
find_path(FONTCONFIG_INCLUDE_DIR fontconfig/fontconfig.h)
find_library(FONTCONFIG_LIBRARY NAMES fontconfig)
# handle the QUIETLY and REQUIRED arguments and set FONTCONFIG_FOUND to TRUE if
# all listed variables are TRUE
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(FontConfig DEFAULT_MSG
FONTCONFIG_LIBRARY FONTCONFIG_INCLUDE_DIR)
if(FONTCONFIG_FOUND)
set( FONTCONFIG_LIBRARIES ${FONTCONFIG_LIBRARY} )
endif()
mark_as_advanced(FONTCONFIG_INCLUDE_DIR FONTCONFIG_LIBRARY FONTCONFIG_LIBRARIES)
IF(NOT FONTCONFIG_FOUND)
MESSAGE(FATAL_ERROR "FontConfig library not found...")
ENDIF()
########
SET(SKIA_DIRECTORY "" CACHE PATH "Path containing skia source code")
IF("${SKIA_DIRECTORY}" STREQUAL "")
MESSAGE(FATAL_ERROR "Must specify path for skia directory")
ENDIF()
IF(NOT EXISTS "${SKIA_DIRECTORY}/")
MESSAGE(FATAL_ERROR "Skia directory not found")
ENDIF()
SET(BUILD_SHARED_LIB OFF CACHE BOOL "Builds a shared library that links to the generated skia libs")
IF(BUILD_SHARED_LIB)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
ENDIF()
SET(ENV{SKIA_OUT} ${Skia-C_SOURCE_DIR})
SET(ENV{GYP_GENERATORS} cmake)
EXECUTE_PROCESS(COMMAND ${SKIA_DIRECTORY}/gyp_skia WORKING_DIRECTORY ${Skia-C_SOURCE_DIR})
SET(OLD_CMAKE_SOURCE_DIR ${CMAKE_SOURCE_DIR})
SET(CMAKE_SOURCE_DIR ${CMAKE_SOURCE_DIR}/${CMAKE_BUILD_TYPE})
ADD_SUBDIRECTORY(${CMAKE_SOURCE_DIR})
SET(CMAKE_SOURCE_DIR ${OLD_CMAKE_SOURCE_DIR})
SET(BUILD_SKIA_DEBUGGER OFF CACHE BOOL "Builds the Qt based Skia debugger")
IF(NOT BUILD_SKIA_DEBUGGER)
set_target_properties(debugger PROPERTIES EXCLUDE_FROM_ALL ON)
set_target_properties(debugger_qt_mocs PROPERTIES EXCLUDE_FROM_ALL ON)
set_target_properties(debugger_qt_mocs__generate_moc PROPERTIES EXCLUDE_FROM_ALL ON)
ENDIF()
GET_TARGET_PROPERTY(SKIA_COMPILE_DEFS core COMPILE_DEFINITIONS)
GET_TARGET_PROPERTY(SKIA_COMPILE_FLAGS core COMPILE_FLAGS)
GET_TARGET_PROPERTY(SKIA_LINK_FLAGS core LINK_FLAGS)
IF(BUILD_SHARED_LIB)
ADD_LIBRARY(cskia SHARED src/skia.cpp)
ELSE()
ADD_LIBRARY(cskia STATIC src/skia.cpp)
ENDIF()
INCLUDE_DIRECTORIES(${Skia-C_SOURCE_DIR}/include)
INCLUDE_DIRECTORIES(${SKIA_DIRECTORY}/include/config)
INCLUDE_DIRECTORIES(${SKIA_DIRECTORY}/include/core)
INCLUDE_DIRECTORIES(${SKIA_DIRECTORY}/include/effects)
INCLUDE_DIRECTORIES(${SKIA_DIRECTORY}/src/core)
INCLUDE_DIRECTORIES(${SKIA_DIRECTORY}/include/images)
INCLUDE_DIRECTORIES(${SKIA_DIRECTORY}/include/gpu)
INCLUDE_DIRECTORIES(${SKIA_DIRECTORY}/include/utils)
SET_TARGET_PROPERTIES(cskia PROPERTIES COMPILE_DEFINITIONS "${SKIA_COMPILE_DEFS}")
SET_TARGET_PROPERTIES(cskia PROPERTIES COMPILE_FLAGS "${SKIA_COMPILE_FLAGS}")
IF(NOT APPLE)
SET_TARGET_PROPERTIES(cskia PROPERTIES LINK_FLAGS "${SKIA_LINK_FLAGS}")
ENDIF()
SET(SKIA_LIBS ${SKIA_LIBS} core)
SET(SKIA_LIBS ${SKIA_LIBS} opts)
SET(SKIA_LIBS ${SKIA_LIBS} opts_sse4)
SET(SKIA_LIBS ${SKIA_LIBS} opts_ssse3)
SET(SKIA_LIBS ${SKIA_LIBS} images)
SET(SKIA_LIBS ${SKIA_LIBS} animator)
SET(SKIA_LIBS ${SKIA_LIBS} effects)
SET(SKIA_LIBS ${SKIA_LIBS} pdf)
SET(SKIA_LIBS ${SKIA_LIBS} ports)
SET(SKIA_LIBS ${SKIA_LIBS} sfnt)
SET(SKIA_LIBS ${SKIA_LIBS} views)
SET(SKIA_LIBS ${SKIA_LIBS} skgpu)
SET(SKIA_LIBS ${SKIA_LIBS} utils)
SET(SKIA_LIBS ${SKIA_LIBS} libetc1)
SET(SKIA_LIBS ${SKIA_LIBS} libSkKTX)
SET(SKIA_LIBS ${SKIA_LIBS} libwebp_enc)
SET(SKIA_LIBS ${SKIA_LIBS} libwebp_dec)
SET(SKIA_LIBS ${SKIA_LIBS} libwebp_demux)
SET(SKIA_LIBS ${SKIA_LIBS} libwebp_utils)
SET(SKIA_LIBS ${SKIA_LIBS} libwebp_dsp)
SET(SKIA_LIBS ${SKIA_LIBS} libjpeg)
FOREACH(TGT ${SKIA_LIBS})
IF(TARGET ${TGT})
ELSE()
MESSAGE(FATAL_ERROR "Could not find target: " ${TGT})
ENDIF()
ENDFOREACH()
SET(SKIA_LIBS ${SKIA_LIBS} ${FREETYPE_LIBRARIES})
SET(SKIA_LIBS ${SKIA_LIBS} ${FONTCONFIG_LIBRARIES})
SET(SKIA_LIBS ${SKIA_LIBS} ${PNG_LIBRARIES})
SET(SKIA_LIBS ${SKIA_LIBS} ${GIF_LIBRARIES})
SET(SKIA_LIBS ${SKIA_LIBS} ${OPENGL_LIBRARIES})
IF(APPLE)
FIND_LIBRARY(CORE_FOUNDATION_LIBRARY CoreFoundation)
FIND_LIBRARY(CORE_GRAPHICS_LIBRARY CoreGraphics)
FIND_LIBRARY(CORE_TEXT_LIBRARY CoreText)
FIND_LIBRARY(APPLICATION_SERVICES_LIBRARY ApplicationServices)
TARGET_LINK_LIBRARIES(cskia ${SKIA_LIBS} ${CORE_FOUNDATION_LIBRARY} ${CORE_TEXT_LIBRARY} ${CORE_GRAPHICS_LIBRARY} ${APPLICATION_SERVICES_LIBRARY})
ELSE()
TARGET_LINK_LIBRARIES(cskia -Wl,--start-group ${SKIA_LIBS} -Wl,--end-group)
ENDIF()
ADD_EXECUTABLE(cskia_test tests/test_libskia.c include/skia.h)
TARGET_LINK_LIBRARIES(cskia_test cskia)
SET_TARGET_PROPERTIES(cskia_test PROPERTIES COMPILE_DEFINITIONS "${SKIA_COMPILE_DEFS}")
IF(NOT APPLE)
SET_TARGET_PROPERTIES(cskia_test PROPERTIES LINK_FLAGS "${SKIA_LINK_FLAGS}")
ENDIF()