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 | |
| 38 | function (remove_srcs) |
mtklein | 2409abb | 2015-08-31 06:59:21 -0700 | [diff] [blame] | 39 | file (GLOB_RECURSE to_remove ${ARGN}) |
mtklein | e0f06a4 | 2015-08-28 11:51:06 -0700 | [diff] [blame] | 40 | list (REMOVE_ITEM srcs ${to_remove}) |
| 41 | set (srcs ${srcs} PARENT_SCOPE) |
| 42 | endfunction() |
| 43 | |
| 44 | # This file is empty and is only used to trick GYP. |
| 45 | remove_srcs (../src/core/SkForceCPlusPlusLinking.cpp) |
| 46 | # This file forces linking for all our supported image decoders. We're more fine-grained. |
| 47 | remove_srcs (../src/images/SkForceLinking.cpp) |
mtklein | 2409abb | 2015-08-31 06:59:21 -0700 | [diff] [blame] | 48 | # Chrome only? |
| 49 | remove_srcs (../src/ports/SkFontHost_fontconfig.cpp |
| 50 | ../src/fonts/SkFontMgr_fontconfig.cpp |
bungeman | c1da4d0 | 2015-12-01 14:26:28 -0500 | [diff] [blame] | 51 | ../src/ports/SkFontConfigInterface_direct.cpp |
| 52 | ../src/ports/SkFontConfigInterface_direct_factory.cpp |
| 53 | ../src/ports/SkFontConfigInterface_direct_google3.cpp |
| 54 | ../src/ports/SkFontConfigInterface_direct_google3_factory.cpp) |
mtklein | 2409abb | 2015-08-31 06:59:21 -0700 | [diff] [blame] | 55 | # Alternative font managers. |
| 56 | remove_srcs (../src/ports/SkFontMgr_custom*.cpp) |
mtklein | e0f06a4 | 2015-08-28 11:51:06 -0700 | [diff] [blame] | 57 | |
| 58 | # Skia sure ships a lot of code no one uses. |
| 59 | remove_srcs (../src/animator/* ../src/*nacl* ../src/svg/* ../src/views/* ../src/xml/*) |
halcanary | 0cbe7ee | 2015-12-01 09:02:49 -0800 | [diff] [blame] | 60 | foreach (include animator svg svg/parser views views/animated xml) |
| 61 | file (GLOB globed_include ../include/${include}) |
| 62 | list (REMOVE_ITEM public_includes ${globed_include}) |
| 63 | endforeach() |
mtklein | e0f06a4 | 2015-08-28 11:51:06 -0700 | [diff] [blame] | 64 | |
mtklein | e0f06a4 | 2015-08-28 11:51:06 -0700 | [diff] [blame] | 65 | # Remove OS-specific source files. |
mtklein | 56c6a11 | 2015-09-30 11:06:53 -0700 | [diff] [blame] | 66 | if (NOT UNIX) |
mtklein | 1ee7651 | 2015-11-02 10:20:27 -0800 | [diff] [blame] | 67 | remove_srcs(../src/ports/*_posix.cpp |
mtklein | 56c6a11 | 2015-09-30 11:06:53 -0700 | [diff] [blame] | 68 | ../src/ports/SkTLS_pthread.cpp |
| 69 | ../src/ports/SkTime_Unix.cpp |
mtklein | a1bde7d | 2015-10-20 11:05:06 -0700 | [diff] [blame] | 70 | ../src/utils/SkThreadUtils_pthread.cpp) |
mtklein | 56c6a11 | 2015-09-30 11:06:53 -0700 | [diff] [blame] | 71 | endif() |
mtklein | 2409abb | 2015-08-31 06:59:21 -0700 | [diff] [blame] | 72 | if (APPLE OR NOT UNIX) |
| 73 | remove_srcs(../src/gpu/gl/glx/* |
| 74 | ../src/images/SkImageDecoder_FactoryDefault.cpp |
| 75 | ../src/ports/SkFontMgr_fontconfig*.cpp |
Ben Wagner | a182b80 | 2016-01-21 17:38:13 -0500 | [diff] [blame] | 76 | ../src/ports/SkFontMgr_android*.cpp |
mtklein | 2409abb | 2015-08-31 06:59:21 -0700 | [diff] [blame] | 77 | ../src/*FreeType*) |
mtklein | e0f06a4 | 2015-08-28 11:51:06 -0700 | [diff] [blame] | 78 | endif() |
mtklein | e0f06a4 | 2015-08-28 11:51:06 -0700 | [diff] [blame] | 79 | |
| 80 | # Remove processor-specific source files. |
mtklein | 0faed58 | 2015-09-14 12:02:32 -0700 | [diff] [blame] | 81 | if (NOT CMAKE_SYSTEM_PROCESSOR STREQUAL ARM) |
mtklein | e0f06a4 | 2015-08-28 11:51:06 -0700 | [diff] [blame] | 82 | remove_srcs(../src/*arm* ../src/*ARM* ../src/*neon* ../src/*NEON*) |
| 83 | endif() |
mtklein | 0faed58 | 2015-09-14 12:02:32 -0700 | [diff] [blame] | 84 | if (NOT CMAKE_SYSTEM_PROCESSOR STREQUAL MIPS) |
mtklein | e0f06a4 | 2015-08-28 11:51:06 -0700 | [diff] [blame] | 85 | remove_srcs(../src/*mips* ../src/*MIPS*) |
| 86 | endif() |
| 87 | |
| 88 | # Make our ports choices. |
| 89 | remove_srcs( |
| 90 | ../src/*moz* # We're probably not Mozilla. |
| 91 | ../src/gpu/GrContextFactory.cpp # For internal testing only. |
| 92 | ../src/gpu/gl/GrGLCreateNativeInterface_none.cpp |
| 93 | ../src/gpu/gl/GrGLDefaultInterface_none.cpp |
| 94 | ../src/gpu/gl/SkCreatePlatformGLContext*.cpp # For internal testing only. |
| 95 | ../src/gpu/gl/command_buffer/* |
| 96 | ../src/gpu/gl/egl/* |
mtklein | e0f06a4 | 2015-08-28 11:51:06 -0700 | [diff] [blame] | 97 | ../src/gpu/gl/iOS/* |
mtklein | e0f06a4 | 2015-08-28 11:51:06 -0700 | [diff] [blame] | 98 | ../src/opts/SkBitmapProcState_opts_none.cpp |
| 99 | ../src/opts/SkBlitMask_opts_none.cpp |
| 100 | ../src/opts/SkBlitRow_opts_none.cpp |
| 101 | ../src/ports/SkFontMgr_empty_factory.cpp |
| 102 | ../src/ports/SkGlobalInitialization_chromium.cpp |
| 103 | ../src/ports/SkImageDecoder_empty.cpp |
| 104 | ../src/ports/SkImageGenerator_none.cpp |
mtklein | 2409abb | 2015-08-31 06:59:21 -0700 | [diff] [blame] | 105 | ../src/ports/SkTLS_none.cpp) |
mtklein | e0f06a4 | 2015-08-28 11:51:06 -0700 | [diff] [blame] | 106 | |
mtklein | 56c6a11 | 2015-09-30 11:06:53 -0700 | [diff] [blame] | 107 | if (WIN32) |
| 108 | if(SKIA_GDI) |
| 109 | remove_srcs(../src/ports/SkFontMgr_win_dw_factory.cpp) |
| 110 | else() |
| 111 | remove_srcs(../src/ports/SkFontMgr_win_gdi_factory.cpp) |
| 112 | endif() |
| 113 | endif() |
| 114 | |
| 115 | remove_srcs(../src/gpu/gl/angle/*) # TODO |
mtklein | 0b47d4b | 2015-11-13 07:42:26 -0800 | [diff] [blame] | 116 | remove_srcs(../src/codec/* ../src/android/*) # TODO: Requires Chromium's libjpeg-turbo, and incompatible giflib. |
mtklein | e0f06a4 | 2015-08-28 11:51:06 -0700 | [diff] [blame] | 117 | |
mtklein | f6d8d28 | 2015-12-17 10:18:04 -0800 | [diff] [blame] | 118 | # 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] | 119 | file (GLOB_RECURSE ssse3_srcs ../src/*ssse3*.cpp ../src/*SSSE3*.cpp) |
| 120 | file (GLOB_RECURSE sse41_srcs ../src/*sse4*.cpp ../src/*SSE4*.cpp) |
mtklein | f6d8d28 | 2015-12-17 10:18:04 -0800 | [diff] [blame] | 121 | file (GLOB_RECURSE avx_srcs ../src/*_avx.cpp) |
| 122 | file (GLOB_RECURSE avx2_srcs ../src/*_avx2.cpp) |
mtklein | e0f06a4 | 2015-08-28 11:51:06 -0700 | [diff] [blame] | 123 | set_source_files_properties(${ssse3_srcs} PROPERTIES COMPILE_FLAGS -mssse3) |
| 124 | set_source_files_properties(${sse41_srcs} PROPERTIES COMPILE_FLAGS -msse4.1) |
mtklein | f6d8d28 | 2015-12-17 10:18:04 -0800 | [diff] [blame] | 125 | set_source_files_properties(${avx_srcs} PROPERTIES COMPILE_FLAGS -mavx) |
| 126 | set_source_files_properties(${avx2_srcs} PROPERTIES COMPILE_FLAGS -mavx2) |
mtklein | e0f06a4 | 2015-08-28 11:51:06 -0700 | [diff] [blame] | 127 | |
| 128 | # Detect our optional dependencies. |
| 129 | # 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] | 130 | find_package (EXPAT) |
mtklein | 2409abb | 2015-08-31 06:59:21 -0700 | [diff] [blame] | 131 | find_package (Lua) |
mtklein | e0f06a4 | 2015-08-28 11:51:06 -0700 | [diff] [blame] | 132 | find_package (ZLIB) |
| 133 | # No find_package for libwebp as far as I can tell, so simulate it here. |
| 134 | find_path (WEBP_INCLUDE_DIRS "webp/decode.h") |
| 135 | find_library (WEBP_LIBRARIES webp) |
halcanary | 4ae2625 | 2015-09-21 09:42:23 -0700 | [diff] [blame] | 136 | find_path (OSMESA_INCLUDE_DIRS "GL/osmesa.h") |
| 137 | find_library(OSMESA_LIBRARIES "OSMesa") |
mtklein | e0f06a4 | 2015-08-28 11:51:06 -0700 | [diff] [blame] | 138 | |
mtklein | 2409abb | 2015-08-31 06:59:21 -0700 | [diff] [blame] | 139 | if (UNIX AND NOT APPLE) |
| 140 | find_package (Freetype) |
| 141 | # Same deal for fontconfig. |
| 142 | find_path (FONTCONFIG_INCLUDE_DIRS "fontconfig/fontconfig.h") |
| 143 | find_library (FONTCONFIG_LIBRARIES fontconfig) |
| 144 | find_package (GIF) |
| 145 | find_package (JPEG) |
| 146 | find_package (PNG) |
| 147 | endif() |
| 148 | |
| 149 | # TODO: macro away this if (found) ... else() ... endif() stuff. |
| 150 | |
mtklein | 1ee7651 | 2015-11-02 10:20:27 -0800 | [diff] [blame] | 151 | if (EXPAT_FOUND) |
| 152 | list (APPEND private_includes ${EXPAT_INCLUDE_DIRS}) |
| 153 | list (APPEND libs ${EXPAT_LIBRARIES}) |
| 154 | else() |
| 155 | remove_srcs (../src/ports/SkFontMgr_android_parser.cpp) |
| 156 | endif() |
| 157 | |
mtklein | 2409abb | 2015-08-31 06:59:21 -0700 | [diff] [blame] | 158 | if (GIF_FOUND) |
| 159 | list (APPEND private_includes ${GIF_INCLUDE_DIRS}) |
| 160 | list (APPEND libs ${GIF_LIBRARIES}) |
| 161 | else() |
mtklein | e0f06a4 | 2015-08-28 11:51:06 -0700 | [diff] [blame] | 162 | remove_srcs(../src/images/*gif*) |
| 163 | endif() |
mtklein | 2409abb | 2015-08-31 06:59:21 -0700 | [diff] [blame] | 164 | |
| 165 | if (JPEG_FOUND) |
| 166 | list (APPEND private_includes ${JPEG_INCLUDE_DIRS}) |
| 167 | list (APPEND libs ${JPEG_LIBRARIES}) |
| 168 | else() |
mtklein | e0f06a4 | 2015-08-28 11:51:06 -0700 | [diff] [blame] | 169 | remove_srcs(../src/images/*jpeg*) |
| 170 | endif() |
mtklein | 2409abb | 2015-08-31 06:59:21 -0700 | [diff] [blame] | 171 | |
| 172 | if (LUA_FOUND) |
| 173 | list (APPEND private_includes ${LUA_INCLUDE_DIR}) |
| 174 | list (APPEND libs ${LUA_LIBRARIES}) |
| 175 | else() |
| 176 | remove_srcs(../src/utils/*Lua*) |
mtklein | e0f06a4 | 2015-08-28 11:51:06 -0700 | [diff] [blame] | 177 | endif() |
mtklein | 2409abb | 2015-08-31 06:59:21 -0700 | [diff] [blame] | 178 | |
| 179 | if (PNG_FOUND) |
| 180 | list (APPEND private_includes ${PNG_INCLUDE_DIRS}) |
| 181 | list (APPEND libs ${PNG_LIBRARIES}) |
| 182 | else() |
mtklein | e0f06a4 | 2015-08-28 11:51:06 -0700 | [diff] [blame] | 183 | remove_srcs(../src/images/*png*) |
| 184 | endif() |
mtklein | 2409abb | 2015-08-31 06:59:21 -0700 | [diff] [blame] | 185 | |
| 186 | if (ZLIB_FOUND) |
| 187 | list (APPEND private_includes ${ZLIB_INCLUDE_DIRS}) |
| 188 | list (APPEND libs ${ZLIB_LIBRARIES}) |
mtklein | e0f06a4 | 2015-08-28 11:51:06 -0700 | [diff] [blame] | 189 | remove_srcs(../src/doc/SkDocument_PDF_None.cpp) |
mtklein | 2409abb | 2015-08-31 06:59:21 -0700 | [diff] [blame] | 190 | else() |
| 191 | remove_srcs(../src/pdf/*.cpp ../src/doc/SkDocument_PDF.cpp) |
mtklein | e0f06a4 | 2015-08-28 11:51:06 -0700 | [diff] [blame] | 192 | endif() |
mtklein | 2409abb | 2015-08-31 06:59:21 -0700 | [diff] [blame] | 193 | |
| 194 | if (WEBP_INCLUDE_DIRS AND WEBP_LIBRARIES) |
| 195 | list (APPEND private_includes ${WEBP_INCLUDE_DIRS}) |
| 196 | list (APPEND libs ${WEBP_LIBRARIES}) |
| 197 | else() |
mtklein | e0f06a4 | 2015-08-28 11:51:06 -0700 | [diff] [blame] | 198 | remove_srcs(../src/images/*webp*) |
| 199 | endif() |
| 200 | |
mtklein | 2409abb | 2015-08-31 06:59:21 -0700 | [diff] [blame] | 201 | if (FREETYPE_FOUND) |
| 202 | list (APPEND private_includes ${FREETYPE_INCLUDE_DIRS}) |
| 203 | list (APPEND libs ${FREETYPE_LIBRARIES}) |
| 204 | endif() |
| 205 | |
| 206 | if (FONTCONFIG_INCLUDE_DIRS AND FONTCONFIG_LIBRARIES) |
| 207 | list (APPEND private_includes ${FONTCONFIG_INCLUDE_DIRS}) |
| 208 | list (APPEND libs ${FONTCONFIG_LIBRARIES}) |
| 209 | endif() |
| 210 | |
mtklein | e0f06a4 | 2015-08-28 11:51:06 -0700 | [diff] [blame] | 211 | if (APPLE) |
mtklein | 2409abb | 2015-08-31 06:59:21 -0700 | [diff] [blame] | 212 | find_library(APPLICATION_SERVICES_FRAMEWORK ApplicationServices REQUIRED) |
| 213 | list (APPEND libs ${APPLICATION_SERVICES_FRAMEWORK}) |
mtklein | e0f06a4 | 2015-08-28 11:51:06 -0700 | [diff] [blame] | 214 | endif() |
| 215 | |
halcanary | 4ae2625 | 2015-09-21 09:42:23 -0700 | [diff] [blame] | 216 | if (OSMESA_LIBRARIES AND OSMESA_INCLUDE_DIRS) |
| 217 | list (APPEND libs ${OSMESA_LIBRARIES}) |
| 218 | list (APPEND private_includes ${OSMESA_INCLUDE_DIRS}) |
| 219 | list (APPEND public_defines "-DSK_MESA=1") |
mtklein | 014f06b | 2016-01-05 08:32:32 -0800 | [diff] [blame] | 220 | set (SK_MESA 1) |
halcanary | 4ae2625 | 2015-09-21 09:42:23 -0700 | [diff] [blame] | 221 | else() |
| 222 | remove_srcs(../src/gpu/gl/mesa/*) |
halcanary | 4ae2625 | 2015-09-21 09:42:23 -0700 | [diff] [blame] | 223 | endif() |
| 224 | |
mtklein | 56c6a11 | 2015-09-30 11:06:53 -0700 | [diff] [blame] | 225 | if (WIN32) |
| 226 | list (APPEND libs FontSub.lib Usp10.lib) |
| 227 | endif() |
| 228 | |
halcanary | 2a4a421 | 2015-09-01 10:11:44 -0700 | [diff] [blame] | 229 | find_package(OpenGL REQUIRED) |
| 230 | list (APPEND libs ${OPENGL_LIBRARIES}) |
| 231 | |
mtklein | e0f06a4 | 2015-08-28 11:51:06 -0700 | [diff] [blame] | 232 | # This is our main output, libskia.so. |
| 233 | # We mostly build an .so here because it helps test we've linked everything, |
| 234 | # not so much that we think Skia is a good candidate to ship as a shared library. |
| 235 | add_library (skia SHARED ${srcs}) |
| 236 | |
| 237 | target_compile_definitions(skia |
halcanary | 4ae2625 | 2015-09-21 09:42:23 -0700 | [diff] [blame] | 238 | PUBLIC ${public_defines} |
mtklein | 56c6a11 | 2015-09-30 11:06:53 -0700 | [diff] [blame] | 239 | PRIVATE -DSKIA_DLL -DSKIA_IMPLEMENTATION=1) |
mtklein | e0f06a4 | 2015-08-28 11:51:06 -0700 | [diff] [blame] | 240 | |
| 241 | target_include_directories(skia |
| 242 | PUBLIC ${public_includes} |
mtklein | 2409abb | 2015-08-31 06:59:21 -0700 | [diff] [blame] | 243 | PRIVATE ${private_includes}) |
mtklein | e0f06a4 | 2015-08-28 11:51:06 -0700 | [diff] [blame] | 244 | |
| 245 | target_link_libraries(skia |
| 246 | PUBLIC |
mtklein | 2409abb | 2015-08-31 06:59:21 -0700 | [diff] [blame] | 247 | PRIVATE ${libs}) |
| 248 | |
mtklein | 56c6a11 | 2015-09-30 11:06:53 -0700 | [diff] [blame] | 249 | if (MSVC) |
| 250 | set(cc_flags "/w /GR-") |
| 251 | else() |
| 252 | set(cc_flags "-w -fno-rtti -fno-exceptions") |
| 253 | endif() |
mtklein | e0f06a4 | 2015-08-28 11:51:06 -0700 | [diff] [blame] | 254 | |
| 255 | set_target_properties(skia PROPERTIES |
mtklein | 56c6a11 | 2015-09-30 11:06:53 -0700 | [diff] [blame] | 256 | COMPILE_FLAGS ${cc_flags} |
mtklein | e0f06a4 | 2015-08-28 11:51:06 -0700 | [diff] [blame] | 257 | CXX_VISIBILITY_PRESET hidden |
| 258 | VISIBILITY_INLINES_HIDDEN true) |
| 259 | |
halcanary | 5a9a5b3 | 2015-09-03 14:23:17 -0700 | [diff] [blame] | 260 | # Experimental C API install: |
mtklein | a5b0f03 | 2015-09-29 13:16:33 -0700 | [diff] [blame] | 261 | file(GLOB c_headers "../include/c/*.h") |
| 262 | install(FILES ${c_headers} DESTINATION include) |
halcanary | 5a9a5b3 | 2015-09-03 14:23:17 -0700 | [diff] [blame] | 263 | install(TARGETS skia DESTINATION lib) |
| 264 | |
halcanary | d1c94a4 | 2015-11-30 12:42:58 -0800 | [diff] [blame] | 265 | # SkUserConfig.h |
halcanary | d1c94a4 | 2015-11-30 12:42:58 -0800 | [diff] [blame] | 266 | if (CMAKE_BUILD_TYPE STREQUAL Release) |
mtklein | 014f06b | 2016-01-05 08:32:32 -0800 | [diff] [blame] | 267 | set (SK_RELEASE 1) |
mtklein | 95bc09b | 2016-01-07 06:56:11 -0800 | [diff] [blame] | 268 | else() |
| 269 | set (SK_RELEASE 0) |
halcanary | d1c94a4 | 2015-11-30 12:42:58 -0800 | [diff] [blame] | 270 | endif() |
mtklein | 014f06b | 2016-01-05 08:32:32 -0800 | [diff] [blame] | 271 | configure_file ("SkUserConfig.h.in" "${userconfig_directory}/SkUserConfig.h") |
halcanary | d1c94a4 | 2015-11-30 12:42:58 -0800 | [diff] [blame] | 272 | |
| 273 | # skia_link_arguments.txt |
| 274 | set (link_arguments ${CMAKE_BINARY_DIR}/skia_link_arguments.txt) |
| 275 | file (WRITE ${link_arguments} "-L${CMAKE_BINARY_DIR}\n") |
| 276 | file (APPEND ${link_arguments} "-lskia\n") |
| 277 | file (APPEND ${link_arguments} "-Wl,-rpath,${CMAKE_BINARY_DIR}\n") |
| 278 | |
| 279 | # skia_compile_arguments.txt |
| 280 | set (compile_arguments ${CMAKE_BINARY_DIR}/skia_compile_arguments.txt) |
| 281 | file (WRITE ${compile_arguments} "--std=c++11\n") |
| 282 | foreach (include ${public_includes}) |
| 283 | get_filename_component (abs_include ${include} ABSOLUTE) |
| 284 | file (APPEND ${compile_arguments} "-I${abs_include}\n") |
| 285 | endforeach() |
| 286 | |
| 287 | # cmake . |
| 288 | # cmake --build . --target skia |
| 289 | # c++ -c @skia_compile_arguments.txt example.cpp |
| 290 | # c++ example.o @skia_link_arguments.txt |
| 291 | |
| 292 | # skia.h |
halcanary | 0cbe7ee | 2015-12-01 09:02:49 -0800 | [diff] [blame] | 293 | set (bad_files GrGLConfig_chrome.h SkJSONCPP.h SkParsePaint.h) |
| 294 | # make `c++ @skia_compile_arguments.txt include/skia.h` work. |
halcanary | d1c94a4 | 2015-11-30 12:42:58 -0800 | [diff] [blame] | 295 | set (skia_h_path ${userconfig_directory}/skia.h) |
| 296 | file (WRITE ${skia_h_path} "// skia.h generated by CMake.\n") |
| 297 | file(APPEND ${skia_h_path} "#ifndef skia_DEFINED\n") |
| 298 | file(APPEND ${skia_h_path} "#define skia_DEFINED\n") |
| 299 | foreach (include ${public_includes}) |
| 300 | if (NOT include STREQUAL userconfig_directory) |
| 301 | file (APPEND ${skia_h_path} "\n") |
| 302 | file (GLOB all_public_headers ${include}/*.h) |
| 303 | foreach (public_header ${all_public_headers}) |
| 304 | get_filename_component (filename_component ${public_header} NAME) |
halcanary | 0cbe7ee | 2015-12-01 09:02:49 -0800 | [diff] [blame] | 305 | if (NOT ";${bad_files};" MATCHES ";${filename_component};") |
| 306 | file (APPEND ${skia_h_path} "#include \"${filename_component}\"\n") |
| 307 | endif () |
halcanary | d1c94a4 | 2015-11-30 12:42:58 -0800 | [diff] [blame] | 308 | endforeach() |
| 309 | endif() |
| 310 | endforeach() |
| 311 | file(APPEND ${skia_h_path} "\n#endif // skia_DEFINED\n") |
| 312 | |
mtklein | e0f06a4 | 2015-08-28 11:51:06 -0700 | [diff] [blame] | 313 | # Now build a simple example app that uses Skia via libskia.so. |
mtklein | e0f06a4 | 2015-08-28 11:51:06 -0700 | [diff] [blame] | 314 | add_executable(example example.cpp) |
| 315 | target_link_libraries(example skia ${OPENGL_LIBRARIES}) |