Skip to content

Commit

Permalink
[cairo] Fix error in static build (#11829)
Browse files Browse the repository at this point in the history
* [cairo] Fix error in static build

* Fix Typo

* [pango] Update dependency cairo as cairo[gobject] to solve the regressions

* Update ports/cairo/portfile.cmake

Co-authored-by: Jack·Boos·Yu <47264268+JackBoosY@users.noreply.github.com>

* Update ports/cairo/CMakeLists.txt

* [pango] Update dependency

* Update

* Remove redundant target

* Post the message for feature gobject only in static build on Windows

Co-authored-by: Jack·Boos·Yu <47264268+JackBoosY@users.noreply.github.com>
  • Loading branch information
NancyLi1013 and JackBoosY committed Jun 23, 2020
1 parent 36bb6f0 commit db74895
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 30 deletions.
55 changes: 35 additions & 20 deletions ports/cairo/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,6 @@ find_package(Threads REQUIRED)
find_package(ZLIB REQUIRED)
find_package(PNG REQUIRED)
find_package(Freetype REQUIRED)
find_package(unofficial-glib CONFIG REQUIRED)
find_package(unofficial-fontconfig CONFIG REQUIRED)
find_package(unofficial-pixman CONFIG REQUIRED)

Expand Down Expand Up @@ -225,32 +224,37 @@ set(CAIRO_GOBJECT_SOURCES
"../util/cairo-gobject/cairo-gobject-structs.c")

# GObject support sources do not include header with export macro
if(BUILD_SHARED_LIBS)
if(MSVC)
set_source_files_properties(
"../util/cairo-gobject/cairo-gobject-enums.c"
"../util/cairo-gobject/cairo-gobject-structs.c"
PROPERTIES COMPILE_DEFINITIONS "cairo_public=__declspec(dllexport)")
else()
set_source_files_properties(
"../util/cairo-gobject/cairo-gobject-enums.c"
"../util/cairo-gobject/cairo-gobject-structs.c"
PROPERTIES COMPILE_DEFINITIONS "cairo_public=__attribute__((visibility(\"default\")))")
if(WITH_GOBJECT)
if(BUILD_SHARED_LIBS)
if(MSVC)
set_source_files_properties(
"../util/cairo-gobject/cairo-gobject-enums.c"
"../util/cairo-gobject/cairo-gobject-structs.c"
PROPERTIES COMPILE_DEFINITIONS "cairo_public=__declspec(dllexport)")
else()
set_source_files_properties(
"../util/cairo-gobject/cairo-gobject-enums.c"
"../util/cairo-gobject/cairo-gobject-structs.c"
PROPERTIES COMPILE_DEFINITIONS "cairo_public=__attribute__((visibility(\"default\")))")
endif()
endif()

find_package(unofficial-glib CONFIG REQUIRED)
add_library(cairo-gobject ${CAIRO_GOBJECT_SOURCES})
target_link_libraries(cairo-gobject PRIVATE cairo unofficial::glib::gobject unofficial::glib::glib)
endif()

add_library(cairo-gobject ${CAIRO_GOBJECT_SOURCES})
target_link_libraries(cairo-gobject PRIVATE cairo unofficial::glib::gobject unofficial::glib::glib)

if(MSVC)
# cairo produces a lot of warnings which are disabled here because they otherwise fill up the log files
# NOTE: options only available to MSVC, clang in macOS doesn't understand these flags
target_compile_options(cairo PRIVATE
"/wd4244" "/wd4146" "/wd4312" "/wd4267" "/wd4996" "/wd4311" "/wd4334" "/wd4101"
)
target_compile_options(cairo-gobject PRIVATE
"/wd4244" "/wd4146" "/wd4312" "/wd4267" "/wd4996" "/wd4311" "/wd4334" "/wd4101"
)
if(WITH_GOBJECT)
target_compile_options(cairo-gobject PRIVATE
"/wd4244" "/wd4146" "/wd4312" "/wd4267" "/wd4996" "/wd4311" "/wd4334" "/wd4101"
)
endif()
endif()

if (CAIRO_HAS_XLIB_SURFACE)
Expand All @@ -265,13 +269,22 @@ if (WITH_X11)
install(FILES ${CAIRO_X11_HEADERS} DESTINATION include/cairo)
endif()

install(TARGETS cairo cairo-gobject
install(TARGETS cairo
EXPORT cairo-targets
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
)

if(WITH_GOBJECT)
install(TARGETS cairo-gobject
EXPORT cairo-targets
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
)
endif()

install(
EXPORT cairo-targets
NAMESPACE unofficial::cairo::
Expand All @@ -284,9 +297,11 @@ include(CMakeFindDependencyMacro)
find_dependency(ZLIB)
find_dependency(PNG)
find_dependency(Freetype)
find_dependency(unofficial-glib CONFIG)
find_dependency(unofficial-fontconfig CONFIG)
find_dependency(unofficial-pixman CONFIG)
if(WITH_GOBJECT)
find_dependency(unofficial-glib CONFIG)
endif()
include(\${CMAKE_CURRENT_LIST_DIR}/unofficial-cairo-targets.cmake)
")
Expand Down
10 changes: 7 additions & 3 deletions ports/cairo/CONTROL
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
Source: cairo
Version: 1.16.0-4
Version: 1.16.0-5
Homepage: https://cairographics.org
Description: Cairo is a 2D graphics library with support for multiple output devices. Currently supported output targets include the X Window System (via both Xlib and XCB), Quartz, Win32, image buffers, PostScript, PDF, and SVG file output. Experimental backends include OpenGL, BeOS, OS/2, and DirectFB.
Build-Depends: zlib, libpng, pixman, glib, freetype, fontconfig
Build-Depends: zlib, libpng, pixman, freetype, fontconfig

Feature: x11
Description: build with x11 support
Description: build with x11 support

Feature: gobject
Description: build gobject module
Build-Depends: glib
9 changes: 8 additions & 1 deletion ports/cairo/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,15 @@ if ("x11" IN_LIST FEATURES)
message(WARNING "You will need to install Xorg dependencies to use feature x11:\napt install libx11-dev libxft-dev\n")
endif()

if("gobject" IN_LIST FEATURES)
if(VCPKG_TARGET_IS_WINDOWS AND VCPKG_LIBRARY_LINKAGE STREQUAL "static")
message(FATAL_ERROR "Feature gobject currently only supports dynamic build.")
endif()
endif()

vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
x11 WITH_X11
gobject WITH_GOBJECT
)

vcpkg_configure_cmake(
Expand Down Expand Up @@ -55,4 +62,4 @@ file(INSTALL ${SOURCE_PATH}/COPYING DESTINATION ${CURRENT_PACKAGES_DIR}/share/${

vcpkg_copy_pdbs()

#vcpkg_test_cmake(PACKAGE_NAME unofficial-cairo)
#vcpkg_test_cmake(PACKAGE_NAME unofficial-cairo)
4 changes: 2 additions & 2 deletions ports/pango/CONTROL
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Source: pango
Version: 1.40.11-6
Version: 1.40.11-7
Homepage: https://ftp.gnome.org/pub/GNOME/sources/pango/
Description: Text and font handling library.
Build-Depends: glib, gettext, cairo, fontconfig, freetype, harfbuzz[glib] (!(windows&static)&!osx)
Build-Depends: glib, gettext, cairo[gobject], fontconfig, freetype, harfbuzz[glib] (!(windows&static)&!osx)
5 changes: 1 addition & 4 deletions ports/pango/portfile.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
include(vcpkg_common_functions)

set(PANGO_VERSION 1.40.11)
vcpkg_download_distfile(ARCHIVE
URLS "http://ftp.gnome.org/pub/GNOME/sources/pango/1.40/pango-${PANGO_VERSION}.tar.xz"
Expand All @@ -25,5 +23,4 @@ vcpkg_configure_cmake(
vcpkg_install_cmake()
vcpkg_copy_pdbs()

file(COPY ${SOURCE_PATH}/COPYING DESTINATION ${CURRENT_PACKAGES_DIR}/share/pango)
file(RENAME ${CURRENT_PACKAGES_DIR}/share/pango/COPYING ${CURRENT_PACKAGES_DIR}/share/pango/copyright)
file(INSTALL ${SOURCE_PATH}/COPYING DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright)

0 comments on commit db74895

Please sign in to comment.