2015-08-28 18:51:06 +00:00
|
|
|
# Boilerplate.
|
2015-09-01 16:22:31 +00:00
|
|
|
cmake_minimum_required (VERSION 3.1) # First version with CMAKE_CXX_STANDARD.
|
2015-08-28 18:51:06 +00:00
|
|
|
project (skimake)
|
|
|
|
set (CMAKE_CXX_STANDARD 11)
|
|
|
|
|
|
|
|
# Default to Release mode. We're mainly targeting Skia users, not Skia developers.
|
|
|
|
if (NOT CMAKE_BUILD_TYPE)
|
|
|
|
set (CMAKE_BUILD_TYPE Release)
|
|
|
|
endif ()
|
|
|
|
|
|
|
|
# To first approximation, the Skia library comprises all .cpp files under src/.
|
|
|
|
file (GLOB_RECURSE srcs ../src/*.cpp)
|
|
|
|
|
|
|
|
function (find_include_dirs out)
|
2015-08-31 13:59:21 +00:00
|
|
|
file (GLOB_RECURSE headers ${ARGN})
|
2015-08-28 18:51:06 +00:00
|
|
|
foreach (path ${headers})
|
|
|
|
get_filename_component (dir ${path} PATH)
|
|
|
|
list (APPEND include_dirs ${dir})
|
|
|
|
endforeach()
|
|
|
|
list (REMOVE_DUPLICATES include_dirs)
|
|
|
|
set (${out} ${include_dirs} PARENT_SCOPE)
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
# We need src/ directories and include/private on our path when building Skia.
|
|
|
|
# Users should be able to use Skia with only include/ directories that are not include/private.
|
|
|
|
find_include_dirs(private_includes ../src/*.h ../include/private/*.h)
|
|
|
|
find_include_dirs(public_includes ../include/*.h)
|
|
|
|
list (REMOVE_ITEM public_includes ${private_includes}) # Easiest way to exclude private.
|
|
|
|
|
|
|
|
# These guys are third_party but provided by a Skia checkout.
|
|
|
|
list (APPEND srcs ../third_party/etc1/etc1.cpp ../third_party/ktx/ktx.cpp)
|
|
|
|
list (APPEND private_includes ../third_party/etc1 ../third_party/ktx)
|
|
|
|
|
|
|
|
function (remove_srcs)
|
2015-08-31 13:59:21 +00:00
|
|
|
file (GLOB_RECURSE to_remove ${ARGN})
|
2015-08-28 18:51:06 +00:00
|
|
|
list (REMOVE_ITEM srcs ${to_remove})
|
|
|
|
set (srcs ${srcs} PARENT_SCOPE)
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
# This file is empty and is only used to trick GYP.
|
|
|
|
remove_srcs (../src/core/SkForceCPlusPlusLinking.cpp)
|
|
|
|
# This file forces linking for all our supported image decoders. We're more fine-grained.
|
|
|
|
remove_srcs (../src/images/SkForceLinking.cpp)
|
2015-08-31 13:59:21 +00:00
|
|
|
# Chrome only?
|
|
|
|
remove_srcs (../src/ports/SkFontHost_fontconfig.cpp
|
|
|
|
../src/fonts/SkFontMgr_fontconfig.cpp
|
|
|
|
../src/ports/SkFontConfigInterface_direct.cpp)
|
|
|
|
# Alternative font managers.
|
|
|
|
remove_srcs (../src/ports/SkFontMgr_custom*.cpp)
|
|
|
|
# Not actually used by Skia.
|
|
|
|
remove_srcs (../src/utils/SkThreadUtils_pthread_*.cpp)
|
2015-08-28 18:51:06 +00:00
|
|
|
|
|
|
|
# Skia sure ships a lot of code no one uses.
|
|
|
|
remove_srcs (../src/animator/* ../src/*nacl* ../src/svg/* ../src/views/* ../src/xml/*)
|
|
|
|
|
|
|
|
# Remove OS-specific source files.
|
|
|
|
if (NOT WIN32)
|
2015-08-31 13:59:21 +00:00
|
|
|
remove_srcs(../src/*XPS*
|
|
|
|
../src/*_win*.cpp
|
|
|
|
../src/ports/SkImageDecoder_WIC.cpp
|
|
|
|
../src/utils/win/*)
|
2015-08-28 18:51:06 +00:00
|
|
|
endif()
|
2015-09-30 18:06:53 +00:00
|
|
|
if (NOT UNIX)
|
|
|
|
remove_srcs(../src/doc/SkDocument_XPS_None.cpp
|
|
|
|
../src/ports/SkDebug_stdio.cpp
|
|
|
|
../src/ports/SkOSFile_posix.cpp
|
|
|
|
../src/ports/SkTLS_pthread.cpp
|
|
|
|
../src/ports/SkTime_Unix.cpp
|
|
|
|
../src/utils/SkThreadUtils_pthread.cpp
|
|
|
|
../src/utils/SkThreadUtils_pthread_other.cpp)
|
|
|
|
endif()
|
2015-08-31 13:59:21 +00:00
|
|
|
if (APPLE OR NOT UNIX)
|
|
|
|
remove_srcs(../src/gpu/gl/glx/*
|
|
|
|
../src/images/SkImageDecoder_FactoryDefault.cpp
|
|
|
|
../src/ports/SkFontMgr_fontconfig*.cpp
|
|
|
|
../src/*FreeType*)
|
2015-08-28 18:51:06 +00:00
|
|
|
endif()
|
|
|
|
if (NOT ANDROID)
|
2015-08-31 13:59:21 +00:00
|
|
|
remove_srcs(../src/*Hwui* ../src/*android*)
|
|
|
|
endif()
|
|
|
|
if (NOT APPLE)
|
|
|
|
remove_srcs(../src/*darwin*
|
|
|
|
../src/ports/SkImageDecoder_CG.cpp
|
|
|
|
../src/utils/mac/*
|
2015-09-29 20:16:33 +00:00
|
|
|
../src/*_mac*)
|
2015-08-28 18:51:06 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
# Remove processor-specific source files.
|
2015-09-14 19:02:32 +00:00
|
|
|
if (NOT CMAKE_SYSTEM_PROCESSOR STREQUAL ARM)
|
2015-08-28 18:51:06 +00:00
|
|
|
remove_srcs(../src/*arm* ../src/*ARM* ../src/*neon* ../src/*NEON*)
|
|
|
|
endif()
|
2015-09-14 19:02:32 +00:00
|
|
|
if (NOT CMAKE_SYSTEM_PROCESSOR STREQUAL MIPS)
|
2015-08-28 18:51:06 +00:00
|
|
|
remove_srcs(../src/*mips* ../src/*MIPS*)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# Make our ports choices.
|
|
|
|
remove_srcs(
|
|
|
|
../src/*moz* # We're probably not Mozilla.
|
|
|
|
../src/gpu/GrContextFactory.cpp # For internal testing only.
|
|
|
|
../src/gpu/gl/GrGLCreateNativeInterface_none.cpp
|
|
|
|
../src/gpu/gl/GrGLDefaultInterface_none.cpp
|
|
|
|
../src/gpu/gl/SkCreatePlatformGLContext*.cpp # For internal testing only.
|
|
|
|
../src/gpu/gl/command_buffer/*
|
|
|
|
../src/gpu/gl/egl/*
|
|
|
|
../src/gpu/gl/iOS/*
|
|
|
|
../src/opts/SkBitmapProcState_opts_none.cpp
|
|
|
|
../src/opts/SkBlitMask_opts_none.cpp
|
|
|
|
../src/opts/SkBlitRow_opts_none.cpp
|
|
|
|
../src/ports/SkFontMgr_empty_factory.cpp
|
|
|
|
../src/ports/SkGlobalInitialization_chromium.cpp
|
|
|
|
../src/ports/SkImageDecoder_empty.cpp
|
|
|
|
../src/ports/SkImageGenerator_none.cpp
|
2015-08-31 13:59:21 +00:00
|
|
|
../src/ports/SkTLS_none.cpp)
|
2015-08-28 18:51:06 +00:00
|
|
|
|
2015-09-30 18:06:53 +00:00
|
|
|
if (WIN32)
|
|
|
|
if(SKIA_GDI)
|
|
|
|
remove_srcs(../src/ports/SkFontMgr_win_dw_factory.cpp)
|
|
|
|
else()
|
|
|
|
remove_srcs(../src/ports/SkFontMgr_win_gdi_factory.cpp)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
remove_srcs(../src/gpu/gl/angle/*) # TODO
|
2015-08-28 18:51:06 +00:00
|
|
|
remove_srcs(../src/codec/*) # TODO: Requires Chromium's libjpeg-turbo, and incompatible giflib.
|
|
|
|
|
|
|
|
# Certain files must be compiled with support for SSSE3 or SSE4.1 intrinsics.
|
|
|
|
file (GLOB_RECURSE ssse3_srcs ../src/*ssse3*.cpp ../src/*SSSE3*.cpp)
|
|
|
|
file (GLOB_RECURSE sse41_srcs ../src/*sse4*.cpp ../src/*SSE4*.cpp)
|
|
|
|
set_source_files_properties(${ssse3_srcs} PROPERTIES COMPILE_FLAGS -mssse3)
|
|
|
|
set_source_files_properties(${sse41_srcs} PROPERTIES COMPILE_FLAGS -msse4.1)
|
|
|
|
|
|
|
|
# Detect our optional dependencies.
|
|
|
|
# If we can't find them, don't build the parts of Skia that use them.
|
2015-08-31 13:59:21 +00:00
|
|
|
find_package (Lua)
|
2015-08-28 18:51:06 +00:00
|
|
|
find_package (ZLIB)
|
|
|
|
# No find_package for libwebp as far as I can tell, so simulate it here.
|
|
|
|
find_path (WEBP_INCLUDE_DIRS "webp/decode.h")
|
|
|
|
find_library (WEBP_LIBRARIES webp)
|
2015-09-21 16:42:23 +00:00
|
|
|
find_path (OSMESA_INCLUDE_DIRS "GL/osmesa.h")
|
|
|
|
find_library(OSMESA_LIBRARIES "OSMesa")
|
2015-08-28 18:51:06 +00:00
|
|
|
|
2015-08-31 13:59:21 +00:00
|
|
|
if (UNIX AND NOT APPLE)
|
|
|
|
find_package (Freetype)
|
|
|
|
# Same deal for fontconfig.
|
|
|
|
find_path (FONTCONFIG_INCLUDE_DIRS "fontconfig/fontconfig.h")
|
|
|
|
find_library (FONTCONFIG_LIBRARIES fontconfig)
|
|
|
|
find_package (GIF)
|
|
|
|
find_package (JPEG)
|
|
|
|
find_package (PNG)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# TODO: macro away this if (found) ... else() ... endif() stuff.
|
|
|
|
|
|
|
|
if (GIF_FOUND)
|
|
|
|
list (APPEND private_includes ${GIF_INCLUDE_DIRS})
|
|
|
|
list (APPEND libs ${GIF_LIBRARIES})
|
|
|
|
else()
|
2015-08-28 18:51:06 +00:00
|
|
|
remove_srcs(../src/images/*gif*)
|
|
|
|
endif()
|
2015-08-31 13:59:21 +00:00
|
|
|
|
|
|
|
if (JPEG_FOUND)
|
|
|
|
list (APPEND private_includes ${JPEG_INCLUDE_DIRS})
|
|
|
|
list (APPEND libs ${JPEG_LIBRARIES})
|
|
|
|
else()
|
2015-08-28 18:51:06 +00:00
|
|
|
remove_srcs(../src/images/*jpeg*)
|
|
|
|
endif()
|
2015-08-31 13:59:21 +00:00
|
|
|
|
|
|
|
if (LUA_FOUND)
|
|
|
|
list (APPEND private_includes ${LUA_INCLUDE_DIR})
|
|
|
|
list (APPEND libs ${LUA_LIBRARIES})
|
|
|
|
else()
|
|
|
|
remove_srcs(../src/utils/*Lua*)
|
2015-08-28 18:51:06 +00:00
|
|
|
endif()
|
2015-08-31 13:59:21 +00:00
|
|
|
|
|
|
|
if (PNG_FOUND)
|
|
|
|
list (APPEND private_includes ${PNG_INCLUDE_DIRS})
|
|
|
|
list (APPEND libs ${PNG_LIBRARIES})
|
|
|
|
else()
|
2015-08-28 18:51:06 +00:00
|
|
|
remove_srcs(../src/images/*png*)
|
|
|
|
endif()
|
2015-08-31 13:59:21 +00:00
|
|
|
|
|
|
|
if (ZLIB_FOUND)
|
|
|
|
list (APPEND private_includes ${ZLIB_INCLUDE_DIRS})
|
|
|
|
list (APPEND libs ${ZLIB_LIBRARIES})
|
2015-08-28 18:51:06 +00:00
|
|
|
remove_srcs(../src/doc/SkDocument_PDF_None.cpp)
|
2015-08-31 13:59:21 +00:00
|
|
|
else()
|
|
|
|
remove_srcs(../src/pdf/*.cpp ../src/doc/SkDocument_PDF.cpp)
|
2015-08-28 18:51:06 +00:00
|
|
|
endif()
|
2015-08-31 13:59:21 +00:00
|
|
|
|
|
|
|
if (WEBP_INCLUDE_DIRS AND WEBP_LIBRARIES)
|
|
|
|
list (APPEND private_includes ${WEBP_INCLUDE_DIRS})
|
|
|
|
list (APPEND libs ${WEBP_LIBRARIES})
|
|
|
|
else()
|
2015-08-28 18:51:06 +00:00
|
|
|
remove_srcs(../src/images/*webp*)
|
|
|
|
endif()
|
|
|
|
|
2015-08-31 13:59:21 +00:00
|
|
|
if (FREETYPE_FOUND)
|
|
|
|
list (APPEND private_includes ${FREETYPE_INCLUDE_DIRS})
|
|
|
|
list (APPEND libs ${FREETYPE_LIBRARIES})
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if (FONTCONFIG_INCLUDE_DIRS AND FONTCONFIG_LIBRARIES)
|
|
|
|
list (APPEND private_includes ${FONTCONFIG_INCLUDE_DIRS})
|
|
|
|
list (APPEND libs ${FONTCONFIG_LIBRARIES})
|
|
|
|
endif()
|
|
|
|
|
2015-08-28 18:51:06 +00:00
|
|
|
if (APPLE)
|
2015-08-31 13:59:21 +00:00
|
|
|
find_library(APPLICATION_SERVICES_FRAMEWORK ApplicationServices REQUIRED)
|
|
|
|
list (APPEND libs ${APPLICATION_SERVICES_FRAMEWORK})
|
2015-08-28 18:51:06 +00:00
|
|
|
endif()
|
|
|
|
|
2015-09-21 16:42:23 +00:00
|
|
|
if (OSMESA_LIBRARIES AND OSMESA_INCLUDE_DIRS)
|
|
|
|
list (APPEND libs ${OSMESA_LIBRARIES})
|
|
|
|
list (APPEND private_includes ${OSMESA_INCLUDE_DIRS})
|
|
|
|
list (APPEND public_defines "-DSK_MESA=1")
|
|
|
|
else()
|
|
|
|
remove_srcs(../src/gpu/gl/mesa/*)
|
|
|
|
endif()
|
|
|
|
|
2015-09-30 18:06:53 +00:00
|
|
|
if (WIN32)
|
|
|
|
list (APPEND libs FontSub.lib Usp10.lib)
|
|
|
|
endif()
|
|
|
|
|
2015-09-01 17:11:44 +00:00
|
|
|
find_package(OpenGL REQUIRED)
|
|
|
|
list (APPEND libs ${OPENGL_LIBRARIES})
|
|
|
|
|
2015-08-28 18:51:06 +00:00
|
|
|
# This is our main output, libskia.so.
|
|
|
|
# We mostly build an .so here because it helps test we've linked everything,
|
|
|
|
# not so much that we think Skia is a good candidate to ship as a shared library.
|
|
|
|
add_library (skia SHARED ${srcs})
|
|
|
|
|
|
|
|
target_compile_definitions(skia
|
2015-09-21 16:42:23 +00:00
|
|
|
PUBLIC ${public_defines}
|
2015-09-30 18:06:53 +00:00
|
|
|
PRIVATE -DSKIA_DLL -DSKIA_IMPLEMENTATION=1)
|
2015-08-28 18:51:06 +00:00
|
|
|
|
|
|
|
target_include_directories(skia
|
|
|
|
PUBLIC ${public_includes}
|
2015-08-31 13:59:21 +00:00
|
|
|
PRIVATE ${private_includes})
|
2015-08-28 18:51:06 +00:00
|
|
|
|
|
|
|
target_link_libraries(skia
|
|
|
|
PUBLIC
|
2015-08-31 13:59:21 +00:00
|
|
|
PRIVATE ${libs})
|
|
|
|
|
2015-09-30 18:06:53 +00:00
|
|
|
if (MSVC)
|
|
|
|
set(cc_flags "/w /GR-")
|
|
|
|
else()
|
|
|
|
set(cc_flags "-w -fno-rtti -fno-exceptions")
|
|
|
|
endif()
|
2015-08-28 18:51:06 +00:00
|
|
|
|
|
|
|
set_target_properties(skia PROPERTIES
|
2015-09-30 18:06:53 +00:00
|
|
|
COMPILE_FLAGS ${cc_flags}
|
2015-08-28 18:51:06 +00:00
|
|
|
CXX_VISIBILITY_PRESET hidden
|
|
|
|
VISIBILITY_INLINES_HIDDEN true)
|
|
|
|
|
2015-09-03 21:23:17 +00:00
|
|
|
# Experimental C API install:
|
2015-09-29 20:16:33 +00:00
|
|
|
file(GLOB c_headers "../include/c/*.h")
|
|
|
|
install(FILES ${c_headers} DESTINATION include)
|
2015-09-03 21:23:17 +00:00
|
|
|
install(TARGETS skia DESTINATION lib)
|
|
|
|
|
2015-08-28 18:51:06 +00:00
|
|
|
# Now build a simple example app that uses Skia via libskia.so.
|
|
|
|
add_executable(example example.cpp)
|
|
|
|
target_link_libraries(example skia ${OPENGL_LIBRARIES})
|