Skip to content

Instantly share code, notes, and snippets.

@smolck
Created November 28, 2022 14:07
Show Gist options
  • Save smolck/cf8589e501dda9a117d8384e53b74006 to your computer and use it in GitHub Desktop.
Save smolck/cf8589e501dda9a117d8384e53b74006 to your computer and use it in GitHub Desktop.
Just Skia stuff for future reference
cmake_minimum_required(VERSION 3.24) # MY MAJOR VERSION IS THE BEST VERSION
project(VacuumTerm
VERSION 0.1
LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 20)
SET(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # Completion is my friend
set(SKIA_DIR "${CMAKE_CURRENT_LIST_DIR}/third_party/skia")
include(FindPNG)
find_package(ICU 70.1 COMPONENTS uc REQUIRED)
find_library(HARFBUZZ_LIB harfbuzz)
add_subdirectory("${PROJECT_SOURCE_DIR}/third_party/glfw")
add_library(libskia STATIC IMPORTED)
set_property(TARGET libskia PROPERTY
IMPORTED_LOCATION "${SKIA_DIR}/out/Static/libskia.a")
add_library(libskshaper STATIC IMPORTED)
set_property(TARGET libskshaper PROPERTY
IMPORTED_LOCATION "${SKIA_DIR}/out/Static/libskshaper.a")
add_library(libskunicode STATIC IMPORTED)
set_property(TARGET libskunicode PROPERTY
IMPORTED_LOCATION "${SKIA_DIR}/out/Static/libskunicode.a")
add_executable(VacuumTerm
src/main.cpp)
target_include_directories(VacuumTerm PUBLIC
"${PROJECT_SOURCE_DIR}/include/"
"${SKIA_DIR}"
"${PROJECT_SOURCE_DIR}/third_party/glfw/include")
target_link_libraries(VacuumTerm PRIVATE
${HARFBUZZ_LIB}
glfw
${GLFW_LIBRARIES}
PNG::PNG
libskia
libskshaper
libskunicode
ICU::uc)
# Hurray younger me for figuring all this out before https://github.com/smolck/libnvim-test/blob/e286bb2e336355d18336aacd4f00707b8da0f043/Makefile
# This is necessary because reasons I think
.PHONY: all configure build format prepare run
all: build
configure:
cmake -S . -B build
run:
./build/VacuumTerm
build:
cmake --build build
format:
clang-format -i --style=Microsoft src/*.cpp
SKIA_ARGS= is_official_build=true
# NOTE(smolck): On macOS gotta brew install icu4c and then brew link icu4c --force
# BECAUSE REASONS gosh macos is annoying
# Thanks GH issues lol https://github.com/douban/linguist/issues/14
SKIA_ARGS+= skia_use_icu=true
SKIA_ARGS+= skia_use_system_libjpeg_turbo=false
SKIA_ARGS+= skia_use_system_libwebp=false
SKIA_ARGS+= skia_use_system_expat=true
SKIA_ARGS+= skia_use_system_libpng=false
SKIA_ARGS+= skia_use_zlib=true
SKIA_ARGS+= skia_use_harfbuzz=true
SKIA_ARGS+= skia_use_gl=true
SKIA_ARGS+= skia_enable_skshaper=true
# TODO(smolck): MacOS-specific and tbh specific to my system even
SKIA_ARGS+= extra_cflags=["-I", "/opt/homebrew/include/harfbuzz", "-I", "/opt/homebrew/include"]
prepare:
cd third_party/skia \
&& python tools/git-sync-deps \
&& bin/gn gen out/Static --args='${SKIA_ARGS}' \
&& ninja -C out/Static
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment