OLD | NEW |
1 # Boilerplate. | 1 # Boilerplate. |
2 cmake_minimum_required (VERSION 3.1) # First version with CMAKE_CXX_STANDARD. | 2 cmake_minimum_required (VERSION 3.1) # First version with CMAKE_CXX_STANDARD. |
3 project (skimake) | 3 project (skimake) |
4 set (CMAKE_CXX_STANDARD 11) | 4 set (CMAKE_CXX_STANDARD 11) |
5 | 5 |
6 # Default to Release mode. We're mainly targeting Skia users, not Skia develope
rs. | 6 # Default to Release mode. We're mainly targeting Skia users, not Skia develope
rs. |
7 if (NOT CMAKE_BUILD_TYPE) | 7 if (NOT CMAKE_BUILD_TYPE) |
8 set (CMAKE_BUILD_TYPE Release) | 8 set (CMAKE_BUILD_TYPE Release) |
9 endif () | 9 endif () |
10 | 10 |
| 11 set (userconfig_directory ${CMAKE_BINARY_DIR}/include) |
| 12 set (userconfig_path ${userconfig_directory}/SkUserConfig.h) |
| 13 file(WRITE ${userconfig_path} "// SkUserConfig generated by CMake.\n") |
| 14 if (CMAKE_BUILD_TYPE STREQUAL Release) |
| 15 file(APPEND ${userconfig_path} "#define SK_RELEASE\n") |
| 16 file(APPEND ${userconfig_path} "#undef SK_DEBUG\n") |
| 17 else () |
| 18 file(APPEND ${userconfig_path} "#define SK_DEBUG\n") |
| 19 file(APPEND ${userconfig_path} "#undef SK_RELEASE\n") |
| 20 endif () |
| 21 |
11 # To first approximation, the Skia library comprises all .cpp files under src/. | 22 # To first approximation, the Skia library comprises all .cpp files under src/. |
12 file (GLOB_RECURSE srcs ../src/*.cpp) | 23 file (GLOB_RECURSE srcs ../src/*.cpp) |
13 | 24 |
14 function (find_include_dirs out) | 25 function (find_include_dirs out) |
15 file (GLOB_RECURSE headers ${ARGN}) | 26 file (GLOB_RECURSE headers ${ARGN}) |
16 foreach (path ${headers}) | 27 foreach (path ${headers}) |
17 get_filename_component (dir ${path} PATH) | 28 get_filename_component (dir ${path} PATH) |
18 list (APPEND include_dirs ${dir}) | 29 list (APPEND include_dirs ${dir}) |
19 endforeach() | 30 endforeach() |
20 list (REMOVE_DUPLICATES include_dirs) | 31 list (REMOVE_DUPLICATES include_dirs) |
21 set (${out} ${include_dirs} PARENT_SCOPE) | 32 set (${out} ${include_dirs} PARENT_SCOPE) |
22 endfunction() | 33 endfunction() |
23 | 34 |
24 # We need src/ directories and include/private on our path when building Skia. | 35 # We need src/ directories and include/private on our path when building Skia. |
25 # Users should be able to use Skia with only include/ directories that are not i
nclude/private. | 36 # Users should be able to use Skia with only include/ directories that are not i
nclude/private. |
26 find_include_dirs(private_includes ../src/*.h ../include/private/*.h) | 37 find_include_dirs(private_includes ../src/*.h ../include/private/*.h) |
27 find_include_dirs(public_includes ../include/*.h) | 38 find_include_dirs(public_includes ../include/*.h) |
28 list (REMOVE_ITEM public_includes ${private_includes}) # Easiest way to exclude
private. | 39 list (REMOVE_ITEM public_includes ${private_includes}) # Easiest way to exclude
private. |
| 40 file (GLOB default_include_config "../include/config") |
| 41 list (REMOVE_ITEM public_includes ${default_include_config}) |
| 42 list (APPEND public_includes ${userconfig_directory}) |
29 | 43 |
30 # These guys are third_party but provided by a Skia checkout. | 44 # These guys are third_party but provided by a Skia checkout. |
31 list (APPEND srcs ../third_party/etc1/etc1.cpp ../third_party/ktx/kt
x.cpp) | 45 list (APPEND srcs ../third_party/etc1/etc1.cpp ../third_party/ktx/kt
x.cpp) |
32 list (APPEND private_includes ../third_party/etc1 ../third_party/ktx) | 46 list (APPEND private_includes ../third_party/etc1 ../third_party/ktx) |
33 | 47 |
34 function (remove_srcs) | 48 function (remove_srcs) |
35 file (GLOB_RECURSE to_remove ${ARGN}) | 49 file (GLOB_RECURSE to_remove ${ARGN}) |
36 list (REMOVE_ITEM srcs ${to_remove}) | 50 list (REMOVE_ITEM srcs ${to_remove}) |
37 set (srcs ${srcs} PARENT_SCOPE) | 51 set (srcs ${srcs} PARENT_SCOPE) |
38 endfunction() | 52 endfunction() |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 | 208 |
195 if (APPLE) | 209 if (APPLE) |
196 find_library(APPLICATION_SERVICES_FRAMEWORK ApplicationServices REQUIRED) | 210 find_library(APPLICATION_SERVICES_FRAMEWORK ApplicationServices REQUIRED) |
197 list (APPEND libs ${APPLICATION_SERVICES_FRAMEWORK}) | 211 list (APPEND libs ${APPLICATION_SERVICES_FRAMEWORK}) |
198 endif() | 212 endif() |
199 | 213 |
200 if (OSMESA_LIBRARIES AND OSMESA_INCLUDE_DIRS) | 214 if (OSMESA_LIBRARIES AND OSMESA_INCLUDE_DIRS) |
201 list (APPEND libs ${OSMESA_LIBRARIES}) | 215 list (APPEND libs ${OSMESA_LIBRARIES}) |
202 list (APPEND private_includes ${OSMESA_INCLUDE_DIRS}) | 216 list (APPEND private_includes ${OSMESA_INCLUDE_DIRS}) |
203 list (APPEND public_defines "-DSK_MESA=1") | 217 list (APPEND public_defines "-DSK_MESA=1") |
| 218 file (APPEND ${userconfig_path} "#define SK_MESA 1\n") |
204 else() | 219 else() |
205 remove_srcs(../src/gpu/gl/mesa/*) | 220 remove_srcs(../src/gpu/gl/mesa/*) |
206 endif() | 221 endif() |
207 | 222 |
208 if (WIN32) | 223 if (WIN32) |
209 list (APPEND libs FontSub.lib Usp10.lib) | 224 list (APPEND libs FontSub.lib Usp10.lib) |
210 endif() | 225 endif() |
211 | 226 |
212 find_package(OpenGL REQUIRED) | 227 find_package(OpenGL REQUIRED) |
213 list (APPEND libs ${OPENGL_LIBRARIES}) | 228 list (APPEND libs ${OPENGL_LIBRARIES}) |
(...skipping 27 matching lines...) Expand all Loading... |
241 VISIBILITY_INLINES_HIDDEN true) | 256 VISIBILITY_INLINES_HIDDEN true) |
242 | 257 |
243 # Experimental C API install: | 258 # Experimental C API install: |
244 file(GLOB c_headers "../include/c/*.h") | 259 file(GLOB c_headers "../include/c/*.h") |
245 install(FILES ${c_headers} DESTINATION include) | 260 install(FILES ${c_headers} DESTINATION include) |
246 install(TARGETS skia DESTINATION lib) | 261 install(TARGETS skia DESTINATION lib) |
247 | 262 |
248 # Now build a simple example app that uses Skia via libskia.so. | 263 # Now build a simple example app that uses Skia via libskia.so. |
249 add_executable(example example.cpp) | 264 add_executable(example example.cpp) |
250 target_link_libraries(example skia ${OPENGL_LIBRARIES}) | 265 target_link_libraries(example skia ${OPENGL_LIBRARIES}) |
OLD | NEW |