CMake: control static/shared the normal CMake way.

This flips the default build mode to create a static libskia.

To create a shared libskia, pass -DBUILD_SHARED_LIBS=1 when running cmake.

BUG=skia:5341
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2009503002
CQ_EXTRA_TRYBOTS=client.skia.compile:Build-Ubuntu-GCC-x86_64-Release-CMake-Trybot,Build-Mac-Clang-x86_64-Release-CMake-Trybot

Review-Url: https://codereview.chromium.org/2009503002
This commit is contained in:
mtklein 2016-05-24 09:44:05 -07:00 committed by Commit bot
parent 6d195b22bf
commit 7dd44673e0
2 changed files with 22 additions and 9 deletions

View File

@ -244,15 +244,16 @@ endif()
if (WIN32)
list (APPEND libs FontSub.lib Usp10.lib)
else()
list (APPEND libs pthread)
endif()
find_package(OpenGL REQUIRED)
list (APPEND libs ${OPENGL_LIBRARIES})
# 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})
# This is our main output, libskia.{a,so,dll,dylib,etc...}
# You can control whether this is static or shared with BUILD_SHARED_LIBS.
add_library (skia ${srcs})
target_compile_definitions(skia
PUBLIC ${public_defines}
@ -274,9 +275,12 @@ else()
endif()
set_target_properties(skia PROPERTIES
COMPILE_FLAGS ${cc_flags}
CXX_VISIBILITY_PRESET hidden
VISIBILITY_INLINES_HIDDEN true)
COMPILE_FLAGS ${cc_flags})
if (BUILD_SHARED_LIBS)
set_target_properties(skia PROPERTIES
CXX_VISIBILITY_PRESET hidden
VISIBILITY_INLINES_HIDDEN true)
endif()
# Experimental C API install:
file(GLOB c_headers "../include/c/*.h")

View File

@ -25,9 +25,18 @@ pushd $here/../third_party/externals/cmake
make -j $cores cmake
popd
echo "Building with bootstrapped CMake"
echo "Building static library with bootstrapped CMake"
mkdir -p $SKIA_OUT/$BUILDTYPE
pushd $SKIA_OUT/$BUILDTYPE
$here/../third_party/externals/cmake/bin/cmake -DCMAKE_BUILD_TYPE=$BUILDTYPE $here -G Ninja
$here/../third_party/externals/cmake/bin/cmake -DCMAKE_BUILD_TYPE=$BUILDTYPE \
$here -G Ninja
ninja
popd
echo "Building shared library with bootstrapped CMake"
mkdir -p $SKIA_OUT/$BUILDTYPE
pushd $SKIA_OUT/$BUILDTYPE
$here/../third_party/externals/cmake/bin/cmake -DCMAKE_BUILD_TYPE=$BUILDTYPE -DBUILD_SHARED_LIBS=1 \
$here -G Ninja
ninja
popd