From 5a9a5b3e7fc5bd79af55f22cb674e8d2d7021d9d Mon Sep 17 00:00:00 2001 From: halcanary Date: Thu, 3 Sep 2015 14:23:17 -0700 Subject: [PATCH] CMAKE + install command NOTRY=true Review URL: https://codereview.chromium.org/1325903004 --- cmake/CMakeLists.txt | 5 +++++ experimental/c-api-example/c.md | 39 ++++++++++++--------------------- 2 files changed, 19 insertions(+), 25 deletions(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index df88487730..ea02ddda4d 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -222,6 +222,11 @@ set_target_properties(skia PROPERTIES CXX_VISIBILITY_PRESET hidden VISIBILITY_INLINES_HIDDEN true) +# Experimental C API install: +file(GLOB cheaders "../include/c/*.h") +install(FILES ${cheaders} DESTINATION include) +install(TARGETS skia DESTINATION lib) + # Now build a simple example app that uses Skia via libskia.so. add_executable(example example.cpp) target_link_libraries(example skia ${OPENGL_LIBRARIES}) diff --git a/experimental/c-api-example/c.md b/experimental/c-api-example/c.md index 89ad577bb4..3011f8892b 100644 --- a/experimental/c-api-example/c.md +++ b/experimental/c-api-example/c.md @@ -106,38 +106,27 @@ Here is an example program that uses the C api. To try it out, get the file Cmake example ------------- -The following proof-of-concept workflow currently works on MacOS and Ubuntu +The following proof-of-concept workflow currently works on MacOS and +Ubuntu and depends on a C/C++ compiler, git, and cmake: -1. Aquire Skia (you may have already done this): +1. Aquire, compile, and install Skia as a shared library: - cd [Wherever you want skia src code] + prefix="$HOME" + cd $(mktemp -d /tmp/skiaXXXX) git clone 'https://skia.googlesource.com/skia' - SKIA_DIR="$PWD/skia" + cmake -DCMAKE_INSTALL_PREFIX:PATH="$prefix" skia/cmake + cmake --build . --target skia + cmake --build . --target install -2. Compile Skia (outside of source) as a shared library: +2. Compile, link, and run the example program: - cd [Wherever you want skia build files] - mkdir build_skia - cd build_skia - SKIA_BUILD="$PWD" - cmake "$SKIA_DIR/cmake" -G Ninja && ninja - -3. Compile, link, and run the example program: - - - - cd [Wherever you want the example] - mkdir skia_c_example - cd skia_c_example - cp "$SKIA_DIR/experimental/c-api-example/skia-c-example.c" . - cc -c -I "$SKIA_DIR/include/c" skia-c-example.c -o skia-c-example.o - c++ skia-c-example.o \ - "$SKIA_BUILD"/libskia.* -Wl,-rpath -Wl,"$SKIA_BUILD" \ - -o skia-c-example + cc -o skia-c-example -I "$prefix/include" \ + skia/experimental/c-api-example/skia-c-example.c \ + "$prefix"/lib/libskia.* -Wl,-rpath -Wl,"$prefix/lib" ./skia-c-example - [ $(uname) = Darwin ] && open skia-c-example.png - [ $(uname) = Linux ] && xdg-open skia-c-example.png + [ $(uname) = Darwin ] && open skia-c-example.png + [ $(uname) = Linux ] && xdg-open skia-c-example.png