Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 # Boilerplate. | |
| 2 cmake_minimum_required (VERSION 3.3) # The latest version as I write this. Ma y be too strict. | |
| 3 project (skimake) | |
| 4 set (CMAKE_CXX_STANDARD 11) | |
| 5 | |
| 6 # Default to Release mode. We're mainly targeting Skia users, not Skia develope rs. | |
| 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) | |
| 15 file (GLOB_RECURSE headers ${ARGV}) | |
|
jcgregorio
2015/08/30 13:25:24
Doesn't ARGV also include the 'out' passed in as t
mtklein
2015/08/30 14:19:09
Hmm, reading the docs, it may be I was looking for
| |
| 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 i nclude/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. | |
| 29 | |
| 30 # 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) | |
| 32 list (APPEND private_includes ../third_party/etc1 ../third_party/ktx) | |
| 33 | |
| 34 function (remove_srcs) | |
| 35 file (GLOB_RECURSE to_remove ${ARGV}) | |
| 36 list (REMOVE_ITEM srcs ${to_remove}) | |
| 37 set (srcs ${srcs} PARENT_SCOPE) | |
| 38 endfunction() | |
| 39 | |
| 40 # This file is empty and is only used to trick GYP. | |
| 41 remove_srcs (../src/core/SkForceCPlusPlusLinking.cpp) | |
| 42 # This file forces linking for all our supported image decoders. We're more fin e-grained. | |
| 43 remove_srcs (../src/images/SkForceLinking.cpp) | |
| 44 | |
| 45 # Skia sure ships a lot of code no one uses. | |
| 46 remove_srcs (../src/animator/* ../src/*nacl* ../src/svg/* ../src/views/* ../src/ xml/*) | |
| 47 | |
| 48 # Some files only contain code in Debug mode. This quiets down some linker warn ings. | |
| 49 if (NOT CMAKE_BUILD_TYPE EQUAL Debug) | |
| 50 remove_srcs (../src/core/SkDebug.cpp ../src/utils/SkDumpCanvas.cpp) | |
| 51 endif() | |
| 52 | |
| 53 # Remove OS-specific source files. | |
| 54 if (NOT WIN32) | |
| 55 remove_srcs(../src/utils/win/* ../src/*_win*.cpp ../src/*xps* ../src/gpu/gl/ angle/* ../src/*WIC* ../src/*DWRITE*) | |
| 56 endif() | |
| 57 if (NOT LINUX) | |
| 58 remove_srcs(../src/*linux* ../src/*FreeType* ../src/*FontConfig* ../src/*Fon tMgr_custom*) | |
| 59 endif() | |
| 60 if (NOT ANDROID) | |
| 61 remove_srcs(../src/*android* ../src/*hwui*) | |
| 62 endif() | |
| 63 | |
| 64 # Remove processor-specific source files. | |
| 65 if (NOT CMAKE_SYSTEM_PROCESSOR EQUAL ARM) | |
| 66 remove_srcs(../src/*arm* ../src/*ARM* ../src/*neon* ../src/*NEON*) | |
| 67 endif() | |
| 68 if (NOT CMAKE_SYSTEM_PROCESSOR EQUAL MIPS) | |
| 69 remove_srcs(../src/*mips* ../src/*MIPS*) | |
| 70 endif() | |
| 71 | |
| 72 # Make our ports choices. | |
| 73 remove_srcs( | |
| 74 ../src/*moz* # We're probably not Mozilla. | |
| 75 ../src/gpu/GrContextFactory.cpp # For internal testing only . | |
| 76 ../src/gpu/gl/GrGLCreateNativeInterface_none.cpp | |
| 77 ../src/gpu/gl/GrGLDefaultInterface_none.cpp | |
| 78 ../src/gpu/gl/SkCreatePlatformGLContext*.cpp # For internal testing only . | |
| 79 ../src/gpu/gl/command_buffer/* | |
| 80 ../src/gpu/gl/egl/* | |
| 81 ../src/gpu/gl/glx/* | |
| 82 ../src/gpu/gl/iOS/* | |
| 83 ../src/gpu/gl/mesa/* | |
| 84 ../src/images/SkImageDecoder_FactoryDefault.cpp | |
| 85 ../src/opts/SkBitmapProcState_opts_none.cpp | |
| 86 ../src/opts/SkBlitMask_opts_none.cpp | |
| 87 ../src/opts/SkBlitRow_opts_none.cpp | |
| 88 ../src/ports/SkFontMgr_empty_factory.cpp | |
| 89 ../src/ports/SkGlobalInitialization_chromium.cpp | |
| 90 ../src/ports/SkImageDecoder_empty.cpp | |
| 91 ../src/ports/SkImageGenerator_none.cpp | |
| 92 ../src/ports/SkTLS_none.cpp | |
| 93 ../src/utils/SkThreadUtils_pthread_other.cpp | |
| 94 ) | |
| 95 | |
| 96 remove_srcs(../src/codec/*) # TODO: Requires Chromium's libjpeg-turbo, and inco mpatible giflib. | |
| 97 | |
| 98 # Certain files must be compiled with support for SSSE3 or SSE4.1 intrinsics. | |
| 99 file (GLOB_RECURSE ssse3_srcs ../src/*ssse3*.cpp ../src/*SSSE3*.cpp) | |
| 100 file (GLOB_RECURSE sse41_srcs ../src/*sse4*.cpp ../src/*SSE4*.cpp) | |
| 101 set_source_files_properties(${ssse3_srcs} PROPERTIES COMPILE_FLAGS -mssse3) | |
| 102 set_source_files_properties(${sse41_srcs} PROPERTIES COMPILE_FLAGS -msse4.1) | |
| 103 | |
| 104 # Detect our optional dependencies. | |
| 105 # If we can't find them, don't build the parts of Skia that use them. | |
| 106 | |
| 107 find_package (GIF) | |
| 108 find_package (JPEG) | |
| 109 find_package (LUA) | |
| 110 find_package (PNG) | |
| 111 find_package (ZLIB) | |
| 112 # No find_package for libwebp as far as I can tell, so simulate it here. | |
| 113 find_path (WEBP_INCLUDE_DIRS "webp/decode.h") | |
| 114 find_library (WEBP_LIBRARIES webp) | |
| 115 | |
| 116 if (NOT GIF_FOUND) | |
| 117 remove_srcs(../src/images/*gif*) | |
| 118 endif() | |
| 119 if (NOT JPEG_FOUND) | |
| 120 remove_srcs(../src/images/*jpeg*) | |
| 121 endif() | |
| 122 if (NOT LUA_FOUND) | |
| 123 remove_srcs(../src/utils/*lua*) | |
| 124 endif() | |
| 125 if (NOT PNG_FOUND) | |
| 126 remove_srcs(../src/images/*png*) | |
| 127 endif() | |
| 128 if (NOT ZLIB_FOUND) | |
| 129 remove_srcs(../src/pdf/*.cpp ../src/doc/SkDocument_PDF.cpp) | |
| 130 else() | |
| 131 remove_srcs(../src/doc/SkDocument_PDF_None.cpp) | |
| 132 endif() | |
| 133 if (NOT WEBP_INCLUDE_DIRS OR NOT WEBP_LIBRARIES) | |
| 134 remove_srcs(../src/images/*webp*) | |
| 135 endif() | |
| 136 | |
| 137 if (APPLE) | |
| 138 find_library(APPLICATION_SERVICES_FRAMEWORK ApplicationServices) | |
| 139 endif() | |
| 140 | |
| 141 # This is our main output, libskia.so. | |
| 142 # We mostly build an .so here because it helps test we've linked everything, | |
| 143 # not so much that we think Skia is a good candidate to ship as a shared library . | |
| 144 add_library (skia SHARED ${srcs}) | |
| 145 | |
| 146 target_compile_definitions(skia | |
| 147 PUBLIC | |
| 148 PRIVATE -DSKIA_DLL) | |
| 149 | |
| 150 target_include_directories(skia | |
| 151 PUBLIC ${public_includes} | |
| 152 PRIVATE ${private_includes} | |
| 153 ${GIF_INCLUDE_DIRS} | |
| 154 ${JPEG_INCLUDE_DIRS} | |
| 155 ${LUA_INCLUDE_DIRS} | |
| 156 ${PNG_INCLUDE_DIRS} | |
| 157 ${WEBP_INCLUDE_DIRS} | |
| 158 ${ZLIB_INCLUDE_DIRS}) | |
| 159 | |
| 160 target_link_libraries(skia | |
| 161 PUBLIC | |
| 162 PRIVATE ${APPLICATION_SERVICES_FRAMEWORK} | |
| 163 ${GIF_LIBRARIES} | |
| 164 ${JPEG_LIBRARIES} | |
| 165 ${LUA_LIBRARIES} | |
| 166 ${PNG_LIBRARIES} | |
| 167 ${WEBP_LIBRARIES} | |
| 168 ${ZLIB_LIBRARIES}) | |
| 169 | |
| 170 set_target_properties(skia PROPERTIES | |
| 171 COMPILE_FLAGS "-fno-exceptions -fno-rtti -Wno-deprecated-declarations" | |
| 172 CXX_VISIBILITY_PRESET hidden | |
| 173 VISIBILITY_INLINES_HIDDEN true) | |
| 174 | |
| 175 # Now build a simple example app that uses Skia via libskia.so. | |
| 176 find_package(OpenGL REQUIRED) | |
| 177 add_executable(example example.cpp) | |
| 178 target_link_libraries(example skia ${OPENGL_LIBRARIES}) | |
| OLD | NEW |