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 |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
237 list (APPEND libs ${OSMESA_LIBRARIES}) | 237 list (APPEND libs ${OSMESA_LIBRARIES}) |
238 list (APPEND private_includes ${OSMESA_INCLUDE_DIRS}) | 238 list (APPEND private_includes ${OSMESA_INCLUDE_DIRS}) |
239 list (APPEND public_defines "-DSK_MESA=1") | 239 list (APPEND public_defines "-DSK_MESA=1") |
240 set (SK_MESA 1) | 240 set (SK_MESA 1) |
241 else() | 241 else() |
242 remove_srcs(../src/gpu/gl/mesa/*) | 242 remove_srcs(../src/gpu/gl/mesa/*) |
243 endif() | 243 endif() |
244 | 244 |
245 if (WIN32) | 245 if (WIN32) |
246 list (APPEND libs FontSub.lib Usp10.lib) | 246 list (APPEND libs FontSub.lib Usp10.lib) |
247 else() | |
248 list (APPEND libs pthread) | |
247 endif() | 249 endif() |
248 | 250 |
249 find_package(OpenGL REQUIRED) | 251 find_package(OpenGL REQUIRED) |
250 list (APPEND libs ${OPENGL_LIBRARIES}) | 252 list (APPEND libs ${OPENGL_LIBRARIES}) |
251 | 253 |
252 # This is our main output, libskia.so. | 254 # This is our main output, libskia.{a,so,dll,dylib,etc...} |
253 # We mostly build an .so here because it helps test we've linked everything, | 255 # You can control whether this is static or shared with BUILD_SHARED_LIBS. |
254 # not so much that we think Skia is a good candidate to ship as a shared library . | 256 add_library (skia ${srcs}) |
255 add_library (skia SHARED ${srcs}) | |
256 | 257 |
257 target_compile_definitions(skia | 258 target_compile_definitions(skia |
258 PUBLIC ${public_defines} | 259 PUBLIC ${public_defines} |
259 PRIVATE -DSKIA_DLL -DSKIA_IMPLEMENTATION=1) | 260 PRIVATE -DSKIA_DLL -DSKIA_IMPLEMENTATION=1) |
260 | 261 |
261 target_include_directories(skia | 262 target_include_directories(skia |
262 PUBLIC ${public_includes} | 263 PUBLIC ${public_includes} |
263 PRIVATE ${private_includes}) | 264 PRIVATE ${private_includes}) |
264 | 265 |
265 target_link_libraries(skia | 266 target_link_libraries(skia |
266 PUBLIC | 267 PUBLIC |
267 PRIVATE ${libs}) | 268 PRIVATE ${libs}) |
268 | 269 |
269 if (MSVC) | 270 if (MSVC) |
270 string(REGEX REPLACE " /W3 " " " CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") | 271 string(REGEX REPLACE " /W3 " " " CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") |
271 set(cc_flags "/w /GR-") | 272 set(cc_flags "/w /GR-") |
272 else() | 273 else() |
273 set(cc_flags "-w -fno-rtti -fno-exceptions") | 274 set(cc_flags "-w -fno-rtti -fno-exceptions") |
274 endif() | 275 endif() |
275 | 276 |
276 set_target_properties(skia PROPERTIES | 277 set_target_properties(skia PROPERTIES |
277 COMPILE_FLAGS ${cc_flags} | 278 COMPILE_FLAGS ${cc_flags}) |
278 CXX_VISIBILITY_PRESET hidden | 279 if (BUILD_SHARED_LIBS) |
279 VISIBILITY_INLINES_HIDDEN true) | 280 set_target_properties(skia PROPERTIES |
281 CXX_VISIBILITY_PRESET hidden | |
282 VISIBILITY_INLINES_HIDDEN true) | |
283 endif() | |
280 | 284 |
281 # Experimental C API install: | 285 # Experimental C API install: |
282 file(GLOB c_headers "../include/c/*.h") | 286 file(GLOB c_headers "../include/c/*.h") |
283 install(FILES ${c_headers} DESTINATION include) | 287 install(FILES ${c_headers} DESTINATION include) |
284 install(TARGETS skia DESTINATION lib) | 288 install(TARGETS skia DESTINATION lib) |
285 | 289 |
286 # SkUserConfig.h | 290 # SkUserConfig.h |
287 if (CMAKE_BUILD_TYPE STREQUAL Release) | 291 if (CMAKE_BUILD_TYPE STREQUAL Release) |
288 set (SK_RELEASE 1) | 292 set (SK_RELEASE 1) |
289 else() | 293 else() |
290 set (SK_RELEASE 0) | 294 set (SK_RELEASE 0) |
291 endif() | 295 endif() |
292 if (UNIX AND NOT APPLE) | 296 if (UNIX AND NOT APPLE) |
293 set (SK_SAMPLES_FOR_X 1) | 297 set (SK_SAMPLES_FOR_X 1) |
294 else() | 298 else() |
295 set (SK_SAMPLES_FOR_X 0) | 299 set (SK_SAMPLES_FOR_X 0) |
296 endif() | 300 endif() |
297 configure_file ("SkUserConfig.h.in" "${userconfig_directory}/SkUserConfig.h") | 301 configure_file ("SkUserConfig.h.in" "${userconfig_directory}/SkUserConfig.h") |
298 | 302 |
299 # skia_link_arguments.txt | 303 # skia_link_arguments.txt |
hal.canary
2016/05/24 14:44:51
Should this change depending on static/shared?
hal.canary
2016/05/24 15:26:48
Something like this?
if (BUILD_SHARED_LIBS)
fil
hal.canary
2016/05/24 15:44:45
This seems to work, even if it is hacky:
# skia_l
| |
300 set (link_arguments ${CMAKE_BINARY_DIR}/skia_link_arguments.txt) | 304 set (link_arguments ${CMAKE_BINARY_DIR}/skia_link_arguments.txt) |
301 file (WRITE ${link_arguments} "-L${CMAKE_BINARY_DIR}\n") | 305 file (WRITE ${link_arguments} "-L${CMAKE_BINARY_DIR}\n") |
302 file (APPEND ${link_arguments} "-lskia\n") | 306 file (APPEND ${link_arguments} "-lskia\n") |
303 file (APPEND ${link_arguments} "-Wl,-rpath,${CMAKE_BINARY_DIR}\n") | 307 file (APPEND ${link_arguments} "-Wl,-rpath,${CMAKE_BINARY_DIR}\n") |
304 | 308 |
305 # skia_compile_arguments.txt | 309 # skia_compile_arguments.txt |
306 set (compile_arguments ${CMAKE_BINARY_DIR}/skia_compile_arguments.txt) | 310 set (compile_arguments ${CMAKE_BINARY_DIR}/skia_compile_arguments.txt) |
307 file (WRITE ${compile_arguments} "--std=c++11\n") | 311 file (WRITE ${compile_arguments} "--std=c++11\n") |
308 foreach (include ${public_includes}) | 312 foreach (include ${public_includes}) |
309 get_filename_component (abs_include ${include} ABSOLUTE) | 313 get_filename_component (abs_include ${include} ABSOLUTE) |
(...skipping 22 matching lines...) Expand all Loading... | |
332 file (APPEND ${skia_h_path} "#include \"${filename_component}\"\n") | 336 file (APPEND ${skia_h_path} "#include \"${filename_component}\"\n") |
333 endif () | 337 endif () |
334 endforeach() | 338 endforeach() |
335 endif() | 339 endif() |
336 endforeach() | 340 endforeach() |
337 file(APPEND ${skia_h_path} "\n#endif // skia_DEFINED\n") | 341 file(APPEND ${skia_h_path} "\n#endif // skia_DEFINED\n") |
338 | 342 |
339 # Now build a simple example app that uses Skia via libskia.so. | 343 # Now build a simple example app that uses Skia via libskia.so. |
340 add_executable(example example.cpp) | 344 add_executable(example example.cpp) |
341 target_link_libraries(example skia ${OPENGL_LIBRARIES}) | 345 target_link_libraries(example skia ${OPENGL_LIBRARIES}) |
OLD | NEW |