mtklein | e0f06a4 | 2015-08-28 11:51:06 -0700 | [diff] [blame] | 1 | # Boilerplate. |
mtklein | 0ce744e | 2015-09-01 09:22:31 -0700 | [diff] [blame] | 2 | cmake_minimum_required (VERSION 3.1) # First version with CMAKE_CXX_STANDARD. |
mtklein | e0f06a4 | 2015-08-28 11:51:06 -0700 | [diff] [blame] | 3 | project (skimake) |
| 4 | set (CMAKE_CXX_STANDARD 11) |
| 5 | |
| 6 | # Default to Release mode. We're mainly targeting Skia users, not Skia developers. |
| 7 | if (NOT CMAKE_BUILD_TYPE) |
| 8 | set (CMAKE_BUILD_TYPE Release) |
| 9 | endif () |
| 10 | |
| 11 | # To first approximation, the Skia library comprises all .cpp files under src/. |
| 12 | file (GLOB_RECURSE srcs ../src/*.cpp) |
| 13 | |
| 14 | function (find_include_dirs out) |
mtklein | 2409abb | 2015-08-31 06:59:21 -0700 | [diff] [blame] | 15 | file (GLOB_RECURSE headers ${ARGN}) |
mtklein | e0f06a4 | 2015-08-28 11:51:06 -0700 | [diff] [blame] | 16 | foreach (path ${headers}) |
| 17 | get_filename_component (dir ${path} PATH) |
| 18 | list (APPEND include_dirs ${dir}) |
| 19 | endforeach() |
| 20 | list (REMOVE_DUPLICATES include_dirs) |
| 21 | set (${out} ${include_dirs} PARENT_SCOPE) |
| 22 | endfunction() |
| 23 | |
| 24 | # 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 include/private. |
| 26 | find_include_dirs(private_includes ../src/*.h ../include/private/*.h) |
| 27 | find_include_dirs(public_includes ../include/*.h) |
| 28 | list (REMOVE_ITEM public_includes ${private_includes}) # Easiest way to exclude private. |
halcanary | 0cf5ecb | 2015-11-30 10:29:25 -0800 | [diff] [blame] | 29 | file (GLOB default_include_config "../include/config") |
| 30 | list (REMOVE_ITEM public_includes ${default_include_config}) |
halcanary | d1c94a4 | 2015-11-30 12:42:58 -0800 | [diff] [blame] | 31 | set (userconfig_directory ${CMAKE_BINARY_DIR}/include) |
halcanary | 0cf5ecb | 2015-11-30 10:29:25 -0800 | [diff] [blame] | 32 | list (APPEND public_includes ${userconfig_directory}) |
mtklein | e0f06a4 | 2015-08-28 11:51:06 -0700 | [diff] [blame] | 33 | |
| 34 | # These guys are third_party but provided by a Skia checkout. |
| 35 | list (APPEND srcs ../third_party/etc1/etc1.cpp ../third_party/ktx/ktx.cpp) |
| 36 | list (APPEND private_includes ../third_party/etc1 ../third_party/ktx) |
| 37 | |
scroggo | 3965825 | 2016-06-02 12:59:59 -0700 | [diff] [blame] | 38 | list (APPEND private_includes ../third_party/libpng) |
| 39 | file (GLOB libpng_srcs ../third_party/libpng/*.c) |
| 40 | foreach (src ${libpng_srcs}) |
| 41 | list (APPEND srcs ${src}) |
| 42 | endforeach() |
| 43 | |
| 44 | |
mtklein | e0f06a4 | 2015-08-28 11:51:06 -0700 | [diff] [blame] | 45 | function (remove_srcs) |
mtklein | 2409abb | 2015-08-31 06:59:21 -0700 | [diff] [blame] | 46 | file (GLOB_RECURSE to_remove ${ARGN}) |
mtklein | e0f06a4 | 2015-08-28 11:51:06 -0700 | [diff] [blame] | 47 | list (REMOVE_ITEM srcs ${to_remove}) |
| 48 | set (srcs ${srcs} PARENT_SCOPE) |
| 49 | endfunction() |
| 50 | |
| 51 | # This file is empty and is only used to trick GYP. |
| 52 | remove_srcs (../src/core/SkForceCPlusPlusLinking.cpp) |
mtklein | 2409abb | 2015-08-31 06:59:21 -0700 | [diff] [blame] | 53 | # Chrome only? |
bungeman | 1ae0e01 | 2016-09-19 12:13:16 -0700 | [diff] [blame] | 54 | remove_srcs (../src/ports/SkFontConfigInterface.cpp |
| 55 | ../src/ports/SkFontConfigInterface_direct.cpp |
bungeman | c1da4d0 | 2015-12-01 14:26:28 -0500 | [diff] [blame] | 56 | ../src/ports/SkFontConfigInterface_direct_factory.cpp |
| 57 | ../src/ports/SkFontConfigInterface_direct_google3.cpp |
bungeman | 7d0e3bc | 2016-08-02 07:07:33 -0700 | [diff] [blame] | 58 | ../src/ports/SkFontConfigInterface_direct_google3_factory.cpp |
| 59 | ../src/ports/SkFontMgr_FontConfigInterface.cpp |
| 60 | ../src/ports/SkFontMgr_FontConfigInterface_factory.cpp) |
mtklein | 2409abb | 2015-08-31 06:59:21 -0700 | [diff] [blame] | 61 | # Alternative font managers. |
| 62 | remove_srcs (../src/ports/SkFontMgr_custom*.cpp) |
ethannicholas | b3058bd | 2016-07-01 08:22:01 -0700 | [diff] [blame] | 63 | # skslc main() |
| 64 | remove_srcs (../src/sksl/SkSLMain.cpp) |
| 65 | |
mtklein | e0f06a4 | 2015-08-28 11:51:06 -0700 | [diff] [blame] | 66 | |
| 67 | # Skia sure ships a lot of code no one uses. |
| 68 | remove_srcs (../src/animator/* ../src/*nacl* ../src/svg/* ../src/views/* ../src/xml/*) |
fmalita | 01c9723 | 2016-07-19 06:12:54 -0700 | [diff] [blame] | 69 | foreach (include animator svg views xml gpu/vk) |
halcanary | 0cbe7ee | 2015-12-01 09:02:49 -0800 | [diff] [blame] | 70 | file (GLOB globed_include ../include/${include}) |
| 71 | list (REMOVE_ITEM public_includes ${globed_include}) |
| 72 | endforeach() |
mtklein | e0f06a4 | 2015-08-28 11:51:06 -0700 | [diff] [blame] | 73 | |
mtklein | e0f06a4 | 2015-08-28 11:51:06 -0700 | [diff] [blame] | 74 | # Remove OS-specific source files. |
mtklein | 56c6a11 | 2015-09-30 11:06:53 -0700 | [diff] [blame] | 75 | if (NOT UNIX) |
mtklein | 1ee7651 | 2015-11-02 10:20:27 -0800 | [diff] [blame] | 76 | remove_srcs(../src/ports/*_posix.cpp |
mtklein | 56c6a11 | 2015-09-30 11:06:53 -0700 | [diff] [blame] | 77 | ../src/ports/SkTLS_pthread.cpp |
| 78 | ../src/ports/SkTime_Unix.cpp |
mtklein | a1bde7d | 2015-10-20 11:05:06 -0700 | [diff] [blame] | 79 | ../src/utils/SkThreadUtils_pthread.cpp) |
mtklein | 56c6a11 | 2015-09-30 11:06:53 -0700 | [diff] [blame] | 80 | endif() |
mtklein | 2409abb | 2015-08-31 06:59:21 -0700 | [diff] [blame] | 81 | if (APPLE OR NOT UNIX) |
| 82 | remove_srcs(../src/gpu/gl/glx/* |
mtklein | 2409abb | 2015-08-31 06:59:21 -0700 | [diff] [blame] | 83 | ../src/ports/SkFontMgr_fontconfig*.cpp |
Ben Wagner | a182b80 | 2016-01-21 17:38:13 -0500 | [diff] [blame] | 84 | ../src/ports/SkFontMgr_android*.cpp |
mtklein | 2409abb | 2015-08-31 06:59:21 -0700 | [diff] [blame] | 85 | ../src/*FreeType*) |
mtklein | e0f06a4 | 2015-08-28 11:51:06 -0700 | [diff] [blame] | 86 | endif() |
mtklein | e0f06a4 | 2015-08-28 11:51:06 -0700 | [diff] [blame] | 87 | |
| 88 | # Remove processor-specific source files. |
mtklein | 0faed58 | 2015-09-14 12:02:32 -0700 | [diff] [blame] | 89 | if (NOT CMAKE_SYSTEM_PROCESSOR STREQUAL ARM) |
mtklein | e0f06a4 | 2015-08-28 11:51:06 -0700 | [diff] [blame] | 90 | remove_srcs(../src/*arm* ../src/*ARM* ../src/*neon* ../src/*NEON*) |
| 91 | endif() |
mtklein | 0faed58 | 2015-09-14 12:02:32 -0700 | [diff] [blame] | 92 | if (NOT CMAKE_SYSTEM_PROCESSOR STREQUAL MIPS) |
mtklein | e0f06a4 | 2015-08-28 11:51:06 -0700 | [diff] [blame] | 93 | remove_srcs(../src/*mips* ../src/*MIPS*) |
| 94 | endif() |
| 95 | |
| 96 | # Make our ports choices. |
| 97 | remove_srcs( |
| 98 | ../src/*moz* # We're probably not Mozilla. |
| 99 | ../src/gpu/GrContextFactory.cpp # For internal testing only. |
| 100 | ../src/gpu/gl/GrGLCreateNativeInterface_none.cpp |
| 101 | ../src/gpu/gl/GrGLDefaultInterface_none.cpp |
mtklein | e0f06a4 | 2015-08-28 11:51:06 -0700 | [diff] [blame] | 102 | ../src/gpu/gl/command_buffer/* |
| 103 | ../src/gpu/gl/egl/* |
abarth | 7fb19bc | 2016-03-28 11:34:27 -0700 | [diff] [blame] | 104 | ../src/gpu/gl/glfw/* |
mtklein | e0f06a4 | 2015-08-28 11:51:06 -0700 | [diff] [blame] | 105 | ../src/gpu/gl/iOS/* |
egdaniel | b6ce10a | 2016-02-22 07:19:10 -0800 | [diff] [blame] | 106 | ../src/gpu/vk/* |
mtklein | e0f06a4 | 2015-08-28 11:51:06 -0700 | [diff] [blame] | 107 | ../src/opts/SkBitmapProcState_opts_none.cpp |
| 108 | ../src/opts/SkBlitMask_opts_none.cpp |
| 109 | ../src/opts/SkBlitRow_opts_none.cpp |
| 110 | ../src/ports/SkFontMgr_empty_factory.cpp |
| 111 | ../src/ports/SkGlobalInitialization_chromium.cpp |
msarett | c1d0312 | 2016-03-25 08:58:55 -0700 | [diff] [blame] | 112 | ../src/ports/SkImageEncoder_none.cpp |
mtklein | e0f06a4 | 2015-08-28 11:51:06 -0700 | [diff] [blame] | 113 | ../src/ports/SkImageGenerator_none.cpp |
mtklein | 2409abb | 2015-08-31 06:59:21 -0700 | [diff] [blame] | 114 | ../src/ports/SkTLS_none.cpp) |
mtklein | e0f06a4 | 2015-08-28 11:51:06 -0700 | [diff] [blame] | 115 | |
msarett | fdd52c4 | 2016-03-09 15:12:31 -0800 | [diff] [blame] | 116 | if (NOT APPLE) |
| 117 | remove_srcs(../src/ports/SkImageGeneratorCG.cpp) |
| 118 | endif() |
| 119 | |
msarett | fc0b6d1 | 2016-03-17 13:50:17 -0700 | [diff] [blame] | 120 | if (NOT WIN32) |
| 121 | remove_srcs(../src/ports/SkImageGeneratorWIC.cpp) |
| 122 | endif() |
| 123 | |
mtklein | 56c6a11 | 2015-09-30 11:06:53 -0700 | [diff] [blame] | 124 | if (WIN32) |
| 125 | if(SKIA_GDI) |
| 126 | remove_srcs(../src/ports/SkFontMgr_win_dw_factory.cpp) |
| 127 | else() |
| 128 | remove_srcs(../src/ports/SkFontMgr_win_gdi_factory.cpp) |
| 129 | endif() |
| 130 | endif() |
| 131 | |
mtklein | f6d8d28 | 2015-12-17 10:18:04 -0800 | [diff] [blame] | 132 | # Certain files must be compiled with support for SSSE3, SSE4.1, AVX, or AVX2 intrinsics. |
mtklein | e0f06a4 | 2015-08-28 11:51:06 -0700 | [diff] [blame] | 133 | file (GLOB_RECURSE ssse3_srcs ../src/*ssse3*.cpp ../src/*SSSE3*.cpp) |
mtklein | 4e97607 | 2016-08-08 09:06:27 -0700 | [diff] [blame] | 134 | file (GLOB_RECURSE sse41_srcs ../src/*sse41*.cpp ../src/*SSE41*.cpp) |
| 135 | file (GLOB_RECURSE sse42_srcs ../src/*sse42*.cpp ../src/*SSE42*.cpp) |
mtklein | f6d8d28 | 2015-12-17 10:18:04 -0800 | [diff] [blame] | 136 | file (GLOB_RECURSE avx_srcs ../src/*_avx.cpp) |
Mike Klein | 78d5a3b | 2016-09-30 10:48:01 -0400 | [diff] [blame] | 137 | file (GLOB_RECURSE hsw_srcs ../src/*_hsw.cpp) |
halcanary | dd4fcd4 | 2016-05-12 11:25:00 -0700 | [diff] [blame] | 138 | if (NOT WIN32) |
| 139 | set_source_files_properties(${ssse3_srcs} PROPERTIES COMPILE_FLAGS -mssse3) |
| 140 | set_source_files_properties(${sse41_srcs} PROPERTIES COMPILE_FLAGS -msse4.1) |
mtklein | 4e97607 | 2016-08-08 09:06:27 -0700 | [diff] [blame] | 141 | set_source_files_properties(${sse42_srcs} PROPERTIES COMPILE_FLAGS -msse4.2) |
halcanary | dd4fcd4 | 2016-05-12 11:25:00 -0700 | [diff] [blame] | 142 | set_source_files_properties(${avx_srcs} PROPERTIES COMPILE_FLAGS -mavx) |
Mike Klein | 78d5a3b | 2016-09-30 10:48:01 -0400 | [diff] [blame] | 143 | set_source_files_properties(${hsw_srcs} PROPERTIES COMPILE_FLAGS |
| 144 | -mavx2 -mbmi -mbmi2 -mf16c -mfma) |
halcanary | dd4fcd4 | 2016-05-12 11:25:00 -0700 | [diff] [blame] | 145 | endif() |
mtklein | e0f06a4 | 2015-08-28 11:51:06 -0700 | [diff] [blame] | 146 | |
| 147 | # Detect our optional dependencies. |
| 148 | # If we can't find them, don't build the parts of Skia that use them. |
mtklein | 1ee7651 | 2015-11-02 10:20:27 -0800 | [diff] [blame] | 149 | find_package (EXPAT) |
mtklein | 2409abb | 2015-08-31 06:59:21 -0700 | [diff] [blame] | 150 | find_package (Lua) |
mtklein | e0f06a4 | 2015-08-28 11:51:06 -0700 | [diff] [blame] | 151 | find_package (ZLIB) |
mtklein | d805f20 | 2016-08-23 11:01:33 -0700 | [diff] [blame] | 152 | |
| 153 | # For libraries that don't have find_package() scripts, we do it ourselves: |
mtklein | e0f06a4 | 2015-08-28 11:51:06 -0700 | [diff] [blame] | 154 | find_path (WEBP_INCLUDE_DIRS "webp/decode.h") |
mtklein | d805f20 | 2016-08-23 11:01:33 -0700 | [diff] [blame] | 155 | find_library (WEBP_LIBRARIES "webp") |
| 156 | |
halcanary | 4ae2625 | 2015-09-21 09:42:23 -0700 | [diff] [blame] | 157 | find_path (OSMESA_INCLUDE_DIRS "GL/osmesa.h") |
| 158 | find_library(OSMESA_LIBRARIES "OSMesa") |
mtklein | e0f06a4 | 2015-08-28 11:51:06 -0700 | [diff] [blame] | 159 | |
mtklein | 2409abb | 2015-08-31 06:59:21 -0700 | [diff] [blame] | 160 | if (UNIX AND NOT APPLE) |
| 161 | find_package (Freetype) |
mtklein | d805f20 | 2016-08-23 11:01:33 -0700 | [diff] [blame] | 162 | find_package (GIF) |
| 163 | |
mtklein | 2409abb | 2015-08-31 06:59:21 -0700 | [diff] [blame] | 164 | find_path (FONTCONFIG_INCLUDE_DIRS "fontconfig/fontconfig.h") |
| 165 | find_library (FONTCONFIG_LIBRARIES fontconfig) |
mtklein | d805f20 | 2016-08-23 11:01:33 -0700 | [diff] [blame] | 166 | |
| 167 | # We require libjpeg-turbo >= 1.5.0. |
| 168 | find_package(PkgConfig) |
| 169 | pkg_check_modules(JPEG_TURBO libjpeg>=1.5.0) |
mtklein | 2409abb | 2015-08-31 06:59:21 -0700 | [diff] [blame] | 170 | endif() |
| 171 | |
msarett | 4691d99 | 2016-02-16 13:16:39 -0800 | [diff] [blame] | 172 | # Do not compile SkRawCodec. |
| 173 | remove_srcs(../src/codec/*Raw*.cpp) |
| 174 | |
mtklein | 2409abb | 2015-08-31 06:59:21 -0700 | [diff] [blame] | 175 | # TODO: macro away this if (found) ... else() ... endif() stuff. |
| 176 | |
mtklein | 1ee7651 | 2015-11-02 10:20:27 -0800 | [diff] [blame] | 177 | if (EXPAT_FOUND) |
| 178 | list (APPEND private_includes ${EXPAT_INCLUDE_DIRS}) |
| 179 | list (APPEND libs ${EXPAT_LIBRARIES}) |
| 180 | else() |
| 181 | remove_srcs (../src/ports/SkFontMgr_android_parser.cpp) |
| 182 | endif() |
| 183 | |
mtklein | 2409abb | 2015-08-31 06:59:21 -0700 | [diff] [blame] | 184 | if (GIF_FOUND) |
| 185 | list (APPEND private_includes ${GIF_INCLUDE_DIRS}) |
| 186 | list (APPEND libs ${GIF_LIBRARIES}) |
msarett | ad3a5c6 | 2016-05-06 07:21:26 -0700 | [diff] [blame] | 187 | add_definitions(-DSK_HAS_GIF_LIBRARY) |
mtklein | 2409abb | 2015-08-31 06:59:21 -0700 | [diff] [blame] | 188 | else() |
msarett | c1d0312 | 2016-03-25 08:58:55 -0700 | [diff] [blame] | 189 | remove_srcs(../src/images/*GIF*) |
msarett | 39b2d5a | 2016-02-17 08:26:31 -0800 | [diff] [blame] | 190 | remove_srcs(../src/codec/*Gif*) |
mtklein | e0f06a4 | 2015-08-28 11:51:06 -0700 | [diff] [blame] | 191 | endif() |
mtklein | 2409abb | 2015-08-31 06:59:21 -0700 | [diff] [blame] | 192 | |
mtklein | d805f20 | 2016-08-23 11:01:33 -0700 | [diff] [blame] | 193 | if (JPEG_TURBO_FOUND) |
| 194 | list (APPEND private_includes ${JPEG_TURBO_INCLUDE_DIRS}) |
| 195 | list (APPEND libs ${JPEG_TURBO_LIBRARIES}) |
msarett | ad3a5c6 | 2016-05-06 07:21:26 -0700 | [diff] [blame] | 196 | add_definitions(-DSK_HAS_JPEG_LIBRARY) |
mtklein | 2409abb | 2015-08-31 06:59:21 -0700 | [diff] [blame] | 197 | else() |
msarett | c1d0312 | 2016-03-25 08:58:55 -0700 | [diff] [blame] | 198 | remove_srcs(../src/images/*JPEG*) |
msarett | 39b2d5a | 2016-02-17 08:26:31 -0800 | [diff] [blame] | 199 | remove_srcs(../src/codec/*Jpeg*) |
mtklein | e0f06a4 | 2015-08-28 11:51:06 -0700 | [diff] [blame] | 200 | endif() |
mtklein | 2409abb | 2015-08-31 06:59:21 -0700 | [diff] [blame] | 201 | |
| 202 | if (LUA_FOUND) |
| 203 | list (APPEND private_includes ${LUA_INCLUDE_DIR}) |
| 204 | list (APPEND libs ${LUA_LIBRARIES}) |
| 205 | else() |
| 206 | remove_srcs(../src/utils/*Lua*) |
mtklein | e0f06a4 | 2015-08-28 11:51:06 -0700 | [diff] [blame] | 207 | endif() |
mtklein | 2409abb | 2015-08-31 06:59:21 -0700 | [diff] [blame] | 208 | |
scroggo | 3965825 | 2016-06-02 12:59:59 -0700 | [diff] [blame] | 209 | # PNG |
| 210 | add_definitions(-DSK_HAS_PNG_LIBRARY) |
| 211 | add_definitions(-DPNG_ARM_NEON_OPT=0) |
mtklein | 2409abb | 2015-08-31 06:59:21 -0700 | [diff] [blame] | 212 | |
| 213 | if (ZLIB_FOUND) |
| 214 | list (APPEND private_includes ${ZLIB_INCLUDE_DIRS}) |
| 215 | list (APPEND libs ${ZLIB_LIBRARIES}) |
halcanary | 23f4d4d | 2016-03-12 05:59:39 -0800 | [diff] [blame] | 216 | remove_srcs(../src/pdf/SkDocument_PDF_None.cpp) |
mtklein | 2409abb | 2015-08-31 06:59:21 -0700 | [diff] [blame] | 217 | else() |
halcanary | 23f4d4d | 2016-03-12 05:59:39 -0800 | [diff] [blame] | 218 | remove_srcs(../src/pdf/*.cpp) |
| 219 | set (srcs ${srcs} ../src/pdf/SkDocument_PDF_None.cpp) |
mtklein | e0f06a4 | 2015-08-28 11:51:06 -0700 | [diff] [blame] | 220 | endif() |
mtklein | 2409abb | 2015-08-31 06:59:21 -0700 | [diff] [blame] | 221 | |
| 222 | if (WEBP_INCLUDE_DIRS AND WEBP_LIBRARIES) |
| 223 | list (APPEND private_includes ${WEBP_INCLUDE_DIRS}) |
| 224 | list (APPEND libs ${WEBP_LIBRARIES}) |
msarett | ad3a5c6 | 2016-05-06 07:21:26 -0700 | [diff] [blame] | 225 | add_definitions(-DSK_HAS_WEBP_LIBRARY) |
mtklein | 2409abb | 2015-08-31 06:59:21 -0700 | [diff] [blame] | 226 | else() |
msarett | c1d0312 | 2016-03-25 08:58:55 -0700 | [diff] [blame] | 227 | remove_srcs(../src/images/*WEBP*) |
msarett | 39b2d5a | 2016-02-17 08:26:31 -0800 | [diff] [blame] | 228 | remove_srcs(../src/codec/*Webp*) |
mtklein | e0f06a4 | 2015-08-28 11:51:06 -0700 | [diff] [blame] | 229 | endif() |
| 230 | |
mtklein | 2409abb | 2015-08-31 06:59:21 -0700 | [diff] [blame] | 231 | if (FREETYPE_FOUND) |
| 232 | list (APPEND private_includes ${FREETYPE_INCLUDE_DIRS}) |
| 233 | list (APPEND libs ${FREETYPE_LIBRARIES}) |
| 234 | endif() |
| 235 | |
| 236 | if (FONTCONFIG_INCLUDE_DIRS AND FONTCONFIG_LIBRARIES) |
| 237 | list (APPEND private_includes ${FONTCONFIG_INCLUDE_DIRS}) |
| 238 | list (APPEND libs ${FONTCONFIG_LIBRARIES}) |
| 239 | endif() |
| 240 | |
mtklein | e0f06a4 | 2015-08-28 11:51:06 -0700 | [diff] [blame] | 241 | if (APPLE) |
mtklein | 2409abb | 2015-08-31 06:59:21 -0700 | [diff] [blame] | 242 | find_library(APPLICATION_SERVICES_FRAMEWORK ApplicationServices REQUIRED) |
| 243 | list (APPEND libs ${APPLICATION_SERVICES_FRAMEWORK}) |
mtklein | e0f06a4 | 2015-08-28 11:51:06 -0700 | [diff] [blame] | 244 | endif() |
| 245 | |
halcanary | 4ae2625 | 2015-09-21 09:42:23 -0700 | [diff] [blame] | 246 | if (OSMESA_LIBRARIES AND OSMESA_INCLUDE_DIRS) |
| 247 | list (APPEND libs ${OSMESA_LIBRARIES}) |
| 248 | list (APPEND private_includes ${OSMESA_INCLUDE_DIRS}) |
| 249 | list (APPEND public_defines "-DSK_MESA=1") |
mtklein | 014f06b | 2016-01-05 08:32:32 -0800 | [diff] [blame] | 250 | set (SK_MESA 1) |
halcanary | 4ae2625 | 2015-09-21 09:42:23 -0700 | [diff] [blame] | 251 | else() |
| 252 | remove_srcs(../src/gpu/gl/mesa/*) |
halcanary | 4ae2625 | 2015-09-21 09:42:23 -0700 | [diff] [blame] | 253 | endif() |
| 254 | |
mtklein | 56c6a11 | 2015-09-30 11:06:53 -0700 | [diff] [blame] | 255 | if (WIN32) |
| 256 | list (APPEND libs FontSub.lib Usp10.lib) |
mtklein | 7dd4467 | 2016-05-24 09:44:05 -0700 | [diff] [blame] | 257 | else() |
| 258 | list (APPEND libs pthread) |
mtklein | 56c6a11 | 2015-09-30 11:06:53 -0700 | [diff] [blame] | 259 | endif() |
| 260 | |
halcanary | 2a4a421 | 2015-09-01 10:11:44 -0700 | [diff] [blame] | 261 | find_package(OpenGL REQUIRED) |
| 262 | list (APPEND libs ${OPENGL_LIBRARIES}) |
| 263 | |
mtklein | 7dd4467 | 2016-05-24 09:44:05 -0700 | [diff] [blame] | 264 | # This is our main output, libskia.{a,so,dll,dylib,etc...} |
| 265 | # You can control whether this is static or shared with BUILD_SHARED_LIBS. |
| 266 | add_library (skia ${srcs}) |
mtklein | e0f06a4 | 2015-08-28 11:51:06 -0700 | [diff] [blame] | 267 | |
| 268 | target_compile_definitions(skia |
halcanary | 4ae2625 | 2015-09-21 09:42:23 -0700 | [diff] [blame] | 269 | PUBLIC ${public_defines} |
mtklein | 56c6a11 | 2015-09-30 11:06:53 -0700 | [diff] [blame] | 270 | PRIVATE -DSKIA_DLL -DSKIA_IMPLEMENTATION=1) |
mtklein | e0f06a4 | 2015-08-28 11:51:06 -0700 | [diff] [blame] | 271 | |
| 272 | target_include_directories(skia |
| 273 | PUBLIC ${public_includes} |
mtklein | 2409abb | 2015-08-31 06:59:21 -0700 | [diff] [blame] | 274 | PRIVATE ${private_includes}) |
mtklein | e0f06a4 | 2015-08-28 11:51:06 -0700 | [diff] [blame] | 275 | |
| 276 | target_link_libraries(skia |
| 277 | PUBLIC |
mtklein | 2409abb | 2015-08-31 06:59:21 -0700 | [diff] [blame] | 278 | PRIVATE ${libs}) |
| 279 | |
mtklein | 56c6a11 | 2015-09-30 11:06:53 -0700 | [diff] [blame] | 280 | if (MSVC) |
halcanary | dd4fcd4 | 2016-05-12 11:25:00 -0700 | [diff] [blame] | 281 | string(REGEX REPLACE " /W3 " " " CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") |
mtklein | 56c6a11 | 2015-09-30 11:06:53 -0700 | [diff] [blame] | 282 | set(cc_flags "/w /GR-") |
| 283 | else() |
| 284 | set(cc_flags "-w -fno-rtti -fno-exceptions") |
| 285 | endif() |
mtklein | e0f06a4 | 2015-08-28 11:51:06 -0700 | [diff] [blame] | 286 | |
| 287 | set_target_properties(skia PROPERTIES |
mtklein | 7dd4467 | 2016-05-24 09:44:05 -0700 | [diff] [blame] | 288 | COMPILE_FLAGS ${cc_flags}) |
| 289 | if (BUILD_SHARED_LIBS) |
| 290 | set_target_properties(skia PROPERTIES |
| 291 | CXX_VISIBILITY_PRESET hidden |
| 292 | VISIBILITY_INLINES_HIDDEN true) |
| 293 | endif() |
mtklein | e0f06a4 | 2015-08-28 11:51:06 -0700 | [diff] [blame] | 294 | |
halcanary | 5a9a5b3 | 2015-09-03 14:23:17 -0700 | [diff] [blame] | 295 | # Experimental C API install: |
mtklein | a5b0f03 | 2015-09-29 13:16:33 -0700 | [diff] [blame] | 296 | file(GLOB c_headers "../include/c/*.h") |
| 297 | install(FILES ${c_headers} DESTINATION include) |
halcanary | 5a9a5b3 | 2015-09-03 14:23:17 -0700 | [diff] [blame] | 298 | install(TARGETS skia DESTINATION lib) |
| 299 | |
halcanary | d1c94a4 | 2015-11-30 12:42:58 -0800 | [diff] [blame] | 300 | # SkUserConfig.h |
halcanary | d1c94a4 | 2015-11-30 12:42:58 -0800 | [diff] [blame] | 301 | if (CMAKE_BUILD_TYPE STREQUAL Release) |
mtklein | 014f06b | 2016-01-05 08:32:32 -0800 | [diff] [blame] | 302 | set (SK_RELEASE 1) |
mtklein | 95bc09b | 2016-01-07 06:56:11 -0800 | [diff] [blame] | 303 | else() |
| 304 | set (SK_RELEASE 0) |
halcanary | d1c94a4 | 2015-11-30 12:42:58 -0800 | [diff] [blame] | 305 | endif() |
marco.diiga | cce4927 | 2016-03-25 09:01:26 -0700 | [diff] [blame] | 306 | if (UNIX AND NOT APPLE) |
| 307 | set (SK_SAMPLES_FOR_X 1) |
| 308 | else() |
| 309 | set (SK_SAMPLES_FOR_X 0) |
| 310 | endif() |
mtklein | 014f06b | 2016-01-05 08:32:32 -0800 | [diff] [blame] | 311 | configure_file ("SkUserConfig.h.in" "${userconfig_directory}/SkUserConfig.h") |
halcanary | d1c94a4 | 2015-11-30 12:42:58 -0800 | [diff] [blame] | 312 | |
| 313 | # skia_link_arguments.txt |
| 314 | set (link_arguments ${CMAKE_BINARY_DIR}/skia_link_arguments.txt) |
halcanary | 5d04fda | 2016-05-24 11:23:23 -0700 | [diff] [blame] | 315 | if (BUILD_SHARED_LIBS) |
| 316 | file (WRITE ${link_arguments} "-L${CMAKE_BINARY_DIR}\n") |
| 317 | file (APPEND ${link_arguments} "-lskia\n") |
| 318 | file (APPEND ${link_arguments} "-Wl,-rpath,${CMAKE_BINARY_DIR}\n") |
| 319 | else() |
| 320 | file (WRITE ${link_arguments} "${CMAKE_BINARY_DIR}/libskia.a\n") |
| 321 | foreach (lib ${libs}) |
| 322 | if (EXISTS ${lib}) |
| 323 | get_filename_component(lib_path ${lib} ABSOLUTE) |
| 324 | file (APPEND ${link_arguments} "${lib_path}\n") |
| 325 | else() |
| 326 | file (APPEND ${link_arguments} "-l${lib}\n") |
| 327 | endif() |
| 328 | endforeach() |
| 329 | endif() |
halcanary | d1c94a4 | 2015-11-30 12:42:58 -0800 | [diff] [blame] | 330 | |
| 331 | # skia_compile_arguments.txt |
| 332 | set (compile_arguments ${CMAKE_BINARY_DIR}/skia_compile_arguments.txt) |
| 333 | file (WRITE ${compile_arguments} "--std=c++11\n") |
| 334 | foreach (include ${public_includes}) |
| 335 | get_filename_component (abs_include ${include} ABSOLUTE) |
| 336 | file (APPEND ${compile_arguments} "-I${abs_include}\n") |
| 337 | endforeach() |
| 338 | |
| 339 | # cmake . |
| 340 | # cmake --build . --target skia |
| 341 | # c++ -c @skia_compile_arguments.txt example.cpp |
| 342 | # c++ example.o @skia_link_arguments.txt |
| 343 | |
| 344 | # skia.h |
mtklein | 1b51e0e | 2016-07-26 12:41:27 -0700 | [diff] [blame] | 345 | set (bad_files GrGLConfig_chrome.h) |
halcanary | 0cbe7ee | 2015-12-01 09:02:49 -0800 | [diff] [blame] | 346 | # make `c++ @skia_compile_arguments.txt include/skia.h` work. |
halcanary | d1c94a4 | 2015-11-30 12:42:58 -0800 | [diff] [blame] | 347 | set (skia_h_path ${userconfig_directory}/skia.h) |
| 348 | file (WRITE ${skia_h_path} "// skia.h generated by CMake.\n") |
| 349 | file(APPEND ${skia_h_path} "#ifndef skia_DEFINED\n") |
| 350 | file(APPEND ${skia_h_path} "#define skia_DEFINED\n") |
| 351 | foreach (include ${public_includes}) |
| 352 | if (NOT include STREQUAL userconfig_directory) |
| 353 | file (APPEND ${skia_h_path} "\n") |
| 354 | file (GLOB all_public_headers ${include}/*.h) |
| 355 | foreach (public_header ${all_public_headers}) |
| 356 | get_filename_component (filename_component ${public_header} NAME) |
halcanary | 0cbe7ee | 2015-12-01 09:02:49 -0800 | [diff] [blame] | 357 | if (NOT ";${bad_files};" MATCHES ";${filename_component};") |
| 358 | file (APPEND ${skia_h_path} "#include \"${filename_component}\"\n") |
| 359 | endif () |
halcanary | d1c94a4 | 2015-11-30 12:42:58 -0800 | [diff] [blame] | 360 | endforeach() |
| 361 | endif() |
| 362 | endforeach() |
| 363 | file(APPEND ${skia_h_path} "\n#endif // skia_DEFINED\n") |
| 364 | |
mtklein | e0f06a4 | 2015-08-28 11:51:06 -0700 | [diff] [blame] | 365 | # Now build a simple example app that uses Skia via libskia.so. |
mtklein | e0f06a4 | 2015-08-28 11:51:06 -0700 | [diff] [blame] | 366 | add_executable(example example.cpp) |
| 367 | target_link_libraries(example skia ${OPENGL_LIBRARIES}) |