Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(41)

Side by Side Diff: cmake/CMakeLists.txt

Issue 1315753009: CMake builds on Ubuntu now too. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: ARGV -> ARGN Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cmake/.gitignore ('k') | cmake/example.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Boilerplate. 1 # Boilerplate.
2 cmake_minimum_required (VERSION 3.3) # The latest version as I write this. Ma y be too strict. 2 cmake_minimum_required (VERSION 3.3) # The latest version as I write this. Ma y be too strict.
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 # To first approximation, the Skia library comprises all .cpp files under src/. 11 # To first approximation, the Skia library comprises all .cpp files under src/.
12 file (GLOB_RECURSE srcs ../src/*.cpp) 12 file (GLOB_RECURSE srcs ../src/*.cpp)
13 13
14 function (find_include_dirs out) 14 function (find_include_dirs out)
15 file (GLOB_RECURSE headers ${ARGV}) 15 file (GLOB_RECURSE headers ${ARGN})
16 foreach (path ${headers}) 16 foreach (path ${headers})
17 get_filename_component (dir ${path} PATH) 17 get_filename_component (dir ${path} PATH)
18 list (APPEND include_dirs ${dir}) 18 list (APPEND include_dirs ${dir})
19 endforeach() 19 endforeach()
20 list (REMOVE_DUPLICATES include_dirs) 20 list (REMOVE_DUPLICATES include_dirs)
21 set (${out} ${include_dirs} PARENT_SCOPE) 21 set (${out} ${include_dirs} PARENT_SCOPE)
22 endfunction() 22 endfunction()
23 23
24 # We need src/ directories and include/private on our path when building Skia. 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. 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) 26 find_include_dirs(private_includes ../src/*.h ../include/private/*.h)
27 find_include_dirs(public_includes ../include/*.h) 27 find_include_dirs(public_includes ../include/*.h)
28 list (REMOVE_ITEM public_includes ${private_includes}) # Easiest way to exclude private. 28 list (REMOVE_ITEM public_includes ${private_includes}) # Easiest way to exclude private.
29 29
30 # These guys are third_party but provided by a Skia checkout. 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) 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) 32 list (APPEND private_includes ../third_party/etc1 ../third_party/ktx)
33 33
34 function (remove_srcs) 34 function (remove_srcs)
35 file (GLOB_RECURSE to_remove ${ARGV}) 35 file (GLOB_RECURSE to_remove ${ARGN})
36 list (REMOVE_ITEM srcs ${to_remove}) 36 list (REMOVE_ITEM srcs ${to_remove})
37 set (srcs ${srcs} PARENT_SCOPE) 37 set (srcs ${srcs} PARENT_SCOPE)
38 endfunction() 38 endfunction()
39 39
40 # This file is empty and is only used to trick GYP. 40 # This file is empty and is only used to trick GYP.
41 remove_srcs (../src/core/SkForceCPlusPlusLinking.cpp) 41 remove_srcs (../src/core/SkForceCPlusPlusLinking.cpp)
42 # This file forces linking for all our supported image decoders. We're more fin e-grained. 42 # This file forces linking for all our supported image decoders. We're more fin e-grained.
43 remove_srcs (../src/images/SkForceLinking.cpp) 43 remove_srcs (../src/images/SkForceLinking.cpp)
44 # Chrome only?
45 remove_srcs (../src/ports/SkFontHost_fontconfig.cpp
46 ../src/fonts/SkFontMgr_fontconfig.cpp
47 ../src/ports/SkFontConfigInterface_direct.cpp)
48 # Alternative font managers.
49 remove_srcs (../src/ports/SkFontMgr_custom*.cpp)
50 # Not actually used by Skia.
51 remove_srcs (../src/utils/SkThreadUtils_pthread_*.cpp)
44 52
45 # Skia sure ships a lot of code no one uses. 53 # Skia sure ships a lot of code no one uses.
46 remove_srcs (../src/animator/* ../src/*nacl* ../src/svg/* ../src/views/* ../src/ xml/*) 54 remove_srcs (../src/animator/* ../src/*nacl* ../src/svg/* ../src/views/* ../src/ xml/*)
47 55
48 # Some files only contain code in Debug mode. This quiets down some linker warn ings. 56 # Some files only contain code in Debug mode. This quiets down some linker warn ings.
49 if (NOT CMAKE_BUILD_TYPE EQUAL Debug) 57 if (NOT CMAKE_BUILD_TYPE EQUAL Debug)
50 remove_srcs (../src/core/SkDebug.cpp ../src/utils/SkDumpCanvas.cpp) 58 remove_srcs (../src/core/SkDebug.cpp ../src/utils/SkDumpCanvas.cpp)
51 endif() 59 endif()
52 60
53 # Remove OS-specific source files. 61 # Remove OS-specific source files.
54 if (NOT WIN32) 62 if (NOT WIN32)
55 remove_srcs(../src/utils/win/* ../src/*_win*.cpp ../src/*xps* ../src/gpu/gl/ angle/* ../src/*WIC* ../src/*DWRITE*) 63 remove_srcs(../src/*XPS*
64 ../src/*_win*.cpp
65 ../src/gpu/gl/angle/*
66 ../src/ports/SkImageDecoder_WIC.cpp
67 ../src/utils/win/*)
56 endif() 68 endif()
57 if (NOT LINUX) 69 if (APPLE OR NOT UNIX)
58 remove_srcs(../src/*linux* ../src/*FreeType* ../src/*FontConfig* ../src/*Fon tMgr_custom*) 70 remove_srcs(../src/gpu/gl/glx/*
71 ../src/images/SkImageDecoder_FactoryDefault.cpp
72 ../src/ports/SkFontMgr_fontconfig*.cpp
73 ../src/*FreeType*)
59 endif() 74 endif()
60 if (NOT ANDROID) 75 if (NOT ANDROID)
61 remove_srcs(../src/*android* ../src/*hwui*) 76 remove_srcs(../src/*Hwui* ../src/*android*)
77 endif()
78 if (NOT APPLE)
79 remove_srcs(../src/*darwin*
80 ../src/ports/SkImageDecoder_CG.cpp
81 ../src/utils/mac/*
82 ../src/*mac*)
62 endif() 83 endif()
63 84
64 # Remove processor-specific source files. 85 # Remove processor-specific source files.
65 if (NOT CMAKE_SYSTEM_PROCESSOR EQUAL ARM) 86 if (NOT CMAKE_SYSTEM_PROCESSOR EQUAL ARM)
66 remove_srcs(../src/*arm* ../src/*ARM* ../src/*neon* ../src/*NEON*) 87 remove_srcs(../src/*arm* ../src/*ARM* ../src/*neon* ../src/*NEON*)
67 endif() 88 endif()
68 if (NOT CMAKE_SYSTEM_PROCESSOR EQUAL MIPS) 89 if (NOT CMAKE_SYSTEM_PROCESSOR EQUAL MIPS)
69 remove_srcs(../src/*mips* ../src/*MIPS*) 90 remove_srcs(../src/*mips* ../src/*MIPS*)
70 endif() 91 endif()
71 92
72 # Make our ports choices. 93 # Make our ports choices.
73 remove_srcs( 94 remove_srcs(
74 ../src/*moz* # We're probably not Mozilla. 95 ../src/*moz* # We're probably not Mozilla.
75 ../src/gpu/GrContextFactory.cpp # For internal testing only . 96 ../src/gpu/GrContextFactory.cpp # For internal testing only .
76 ../src/gpu/gl/GrGLCreateNativeInterface_none.cpp 97 ../src/gpu/gl/GrGLCreateNativeInterface_none.cpp
77 ../src/gpu/gl/GrGLDefaultInterface_none.cpp 98 ../src/gpu/gl/GrGLDefaultInterface_none.cpp
78 ../src/gpu/gl/SkCreatePlatformGLContext*.cpp # For internal testing only . 99 ../src/gpu/gl/SkCreatePlatformGLContext*.cpp # For internal testing only .
79 ../src/gpu/gl/command_buffer/* 100 ../src/gpu/gl/command_buffer/*
80 ../src/gpu/gl/egl/* 101 ../src/gpu/gl/egl/*
81 ../src/gpu/gl/glx/*
82 ../src/gpu/gl/iOS/* 102 ../src/gpu/gl/iOS/*
83 ../src/gpu/gl/mesa/* 103 ../src/gpu/gl/mesa/*
84 ../src/images/SkImageDecoder_FactoryDefault.cpp
85 ../src/opts/SkBitmapProcState_opts_none.cpp 104 ../src/opts/SkBitmapProcState_opts_none.cpp
86 ../src/opts/SkBlitMask_opts_none.cpp 105 ../src/opts/SkBlitMask_opts_none.cpp
87 ../src/opts/SkBlitRow_opts_none.cpp 106 ../src/opts/SkBlitRow_opts_none.cpp
88 ../src/ports/SkFontMgr_empty_factory.cpp 107 ../src/ports/SkFontMgr_empty_factory.cpp
89 ../src/ports/SkGlobalInitialization_chromium.cpp 108 ../src/ports/SkGlobalInitialization_chromium.cpp
90 ../src/ports/SkImageDecoder_empty.cpp 109 ../src/ports/SkImageDecoder_empty.cpp
91 ../src/ports/SkImageGenerator_none.cpp 110 ../src/ports/SkImageGenerator_none.cpp
92 ../src/ports/SkTLS_none.cpp 111 ../src/ports/SkTLS_none.cpp)
93 ../src/utils/SkThreadUtils_pthread_other.cpp
94 )
95 112
96 remove_srcs(../src/codec/*) # TODO: Requires Chromium's libjpeg-turbo, and inco mpatible giflib. 113 remove_srcs(../src/codec/*) # TODO: Requires Chromium's libjpeg-turbo, and inco mpatible giflib.
97 114
98 # Certain files must be compiled with support for SSSE3 or SSE4.1 intrinsics. 115 # 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) 116 file (GLOB_RECURSE ssse3_srcs ../src/*ssse3*.cpp ../src/*SSSE3*.cpp)
100 file (GLOB_RECURSE sse41_srcs ../src/*sse4*.cpp ../src/*SSE4*.cpp) 117 file (GLOB_RECURSE sse41_srcs ../src/*sse4*.cpp ../src/*SSE4*.cpp)
101 set_source_files_properties(${ssse3_srcs} PROPERTIES COMPILE_FLAGS -mssse3) 118 set_source_files_properties(${ssse3_srcs} PROPERTIES COMPILE_FLAGS -mssse3)
102 set_source_files_properties(${sse41_srcs} PROPERTIES COMPILE_FLAGS -msse4.1) 119 set_source_files_properties(${sse41_srcs} PROPERTIES COMPILE_FLAGS -msse4.1)
103 120
104 # Detect our optional dependencies. 121 # Detect our optional dependencies.
105 # If we can't find them, don't build the parts of Skia that use them. 122 # If we can't find them, don't build the parts of Skia that use them.
106 123 find_package (Lua)
107 find_package (GIF)
108 find_package (JPEG)
109 find_package (LUA)
110 find_package (PNG)
111 find_package (ZLIB) 124 find_package (ZLIB)
112 # No find_package for libwebp as far as I can tell, so simulate it here. 125 # No find_package for libwebp as far as I can tell, so simulate it here.
113 find_path (WEBP_INCLUDE_DIRS "webp/decode.h") 126 find_path (WEBP_INCLUDE_DIRS "webp/decode.h")
114 find_library (WEBP_LIBRARIES webp) 127 find_library (WEBP_LIBRARIES webp)
115 128
116 if (NOT GIF_FOUND) 129 if (UNIX AND NOT APPLE)
130 find_package (Freetype)
131 # Same deal for fontconfig.
132 find_path (FONTCONFIG_INCLUDE_DIRS "fontconfig/fontconfig.h")
133 find_library (FONTCONFIG_LIBRARIES fontconfig)
134 find_package (GIF)
135 find_package (JPEG)
136 find_package (PNG)
137 endif()
138
139 # TODO: macro away this if (found) ... else() ... endif() stuff.
140
141 if (GIF_FOUND)
142 list (APPEND private_includes ${GIF_INCLUDE_DIRS})
143 list (APPEND libs ${GIF_LIBRARIES})
144 else()
117 remove_srcs(../src/images/*gif*) 145 remove_srcs(../src/images/*gif*)
118 endif() 146 endif()
119 if (NOT JPEG_FOUND) 147
148 if (JPEG_FOUND)
149 list (APPEND private_includes ${JPEG_INCLUDE_DIRS})
150 list (APPEND libs ${JPEG_LIBRARIES})
151 else()
120 remove_srcs(../src/images/*jpeg*) 152 remove_srcs(../src/images/*jpeg*)
121 endif() 153 endif()
122 if (NOT LUA_FOUND) 154
123 remove_srcs(../src/utils/*lua*) 155 if (LUA_FOUND)
156 list (APPEND private_includes ${LUA_INCLUDE_DIR})
157 list (APPEND libs ${LUA_LIBRARIES})
158 else()
159 remove_srcs(../src/utils/*Lua*)
124 endif() 160 endif()
125 if (NOT PNG_FOUND) 161
162 if (PNG_FOUND)
163 list (APPEND private_includes ${PNG_INCLUDE_DIRS})
164 list (APPEND libs ${PNG_LIBRARIES})
165 else()
126 remove_srcs(../src/images/*png*) 166 remove_srcs(../src/images/*png*)
127 endif() 167 endif()
128 if (NOT ZLIB_FOUND) 168
169 if (ZLIB_FOUND)
170 list (APPEND private_includes ${ZLIB_INCLUDE_DIRS})
171 list (APPEND libs ${ZLIB_LIBRARIES})
172 remove_srcs(../src/doc/SkDocument_PDF_None.cpp)
173 else()
129 remove_srcs(../src/pdf/*.cpp ../src/doc/SkDocument_PDF.cpp) 174 remove_srcs(../src/pdf/*.cpp ../src/doc/SkDocument_PDF.cpp)
175 endif()
176
177 if (WEBP_INCLUDE_DIRS AND WEBP_LIBRARIES)
178 list (APPEND private_includes ${WEBP_INCLUDE_DIRS})
179 list (APPEND libs ${WEBP_LIBRARIES})
130 else() 180 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*) 181 remove_srcs(../src/images/*webp*)
135 endif() 182 endif()
136 183
184 if (FREETYPE_FOUND)
185 list (APPEND private_includes ${FREETYPE_INCLUDE_DIRS})
186 list (APPEND libs ${FREETYPE_LIBRARIES})
187 endif()
188
189 if (FONTCONFIG_INCLUDE_DIRS AND FONTCONFIG_LIBRARIES)
190 list (APPEND private_includes ${FONTCONFIG_INCLUDE_DIRS})
191 list (APPEND libs ${FONTCONFIG_LIBRARIES})
192 endif()
193
137 if (APPLE) 194 if (APPLE)
138 find_library(APPLICATION_SERVICES_FRAMEWORK ApplicationServices) 195 find_library(APPLICATION_SERVICES_FRAMEWORK ApplicationServices REQUIRED)
196 list (APPEND libs ${APPLICATION_SERVICES_FRAMEWORK})
139 endif() 197 endif()
140 198
141 # This is our main output, libskia.so. 199 # This is our main output, libskia.so.
142 # We mostly build an .so here because it helps test we've linked everything, 200 # 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 . 201 # not so much that we think Skia is a good candidate to ship as a shared library .
144 add_library (skia SHARED ${srcs}) 202 add_library (skia SHARED ${srcs})
145 203
146 target_compile_definitions(skia 204 target_compile_definitions(skia
147 PUBLIC 205 PUBLIC
148 PRIVATE -DSKIA_DLL) 206 PRIVATE -DSKIA_DLL)
149 207
150 target_include_directories(skia 208 target_include_directories(skia
151 PUBLIC ${public_includes} 209 PUBLIC ${public_includes}
152 PRIVATE ${private_includes} 210 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 211
160 target_link_libraries(skia 212 target_link_libraries(skia
161 PUBLIC 213 PUBLIC
162 PRIVATE ${APPLICATION_SERVICES_FRAMEWORK} 214 PRIVATE ${libs})
163 ${GIF_LIBRARIES} 215
164 ${JPEG_LIBRARIES}
165 ${LUA_LIBRARIES}
166 ${PNG_LIBRARIES}
167 ${WEBP_LIBRARIES}
168 ${ZLIB_LIBRARIES})
169 216
170 set_target_properties(skia PROPERTIES 217 set_target_properties(skia PROPERTIES
171 COMPILE_FLAGS "-fno-exceptions -fno-rtti -Wno-deprecated-declarations" 218 COMPILE_FLAGS "-fno-exceptions -fno-rtti -Wno-deprecated-declarations"
172 CXX_VISIBILITY_PRESET hidden 219 CXX_VISIBILITY_PRESET hidden
173 VISIBILITY_INLINES_HIDDEN true) 220 VISIBILITY_INLINES_HIDDEN true)
174 221
175 # Now build a simple example app that uses Skia via libskia.so. 222 # Now build a simple example app that uses Skia via libskia.so.
176 find_package(OpenGL REQUIRED) 223 find_package(OpenGL REQUIRED)
177 add_executable(example example.cpp) 224 add_executable(example example.cpp)
178 target_link_libraries(example skia ${OPENGL_LIBRARIES}) 225 target_link_libraries(example skia ${OPENGL_LIBRARIES})
OLDNEW
« no previous file with comments | « cmake/.gitignore ('k') | cmake/example.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698