Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Librsvg port #6807

Merged
merged 5 commits into from
Jul 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
154 changes: 154 additions & 0 deletions ports/librsvg/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
cmake_minimum_required(VERSION 3.11)
project(librsvg C)

find_package(unofficial-cairo CONFIG REQUIRED)
find_package(unofficial-libcroco CONFIG REQUIRED)
find_package(unofficial-glib CONFIG REQUIRED)
find_package(LibXml2 REQUIRED)
find_library(PANGO_LIB pango-1.0)
find_library(PANGO_CAIRO_LIB pangocairo-1.0)
if(CMAKE_SYSTEM_NAME MATCHES "Windows")
find_library(GDK_PIXBUF_LIB gdk_pixbuf-2.0)
else()
find_library(GDK_PIXBUF_LIB gdk_pixbuf-2)
endif()

find_path(CAIRO_INCLUDE_DIR cairo/cairo.h)

# Add include directories
include_directories(${CAIRO_INCLUDE_DIR} ${GDK_PIXBUF_INCLUDE_DIR})

set(LIBRSVG_SOURCES
librsvg-features.c
rsvg-css.c
rsvg-css.h
rsvg-compat.h
rsvg-defs.c
rsvg-defs.h
rsvg-image.c
rsvg-image.h
rsvg-io.c
rsvg-io.h
rsvg-paint-server.c
rsvg-paint-server.h
rsvg-path.c
rsvg-path.h
rsvg-private.h
rsvg-base-file-util.c
rsvg-filter.c
rsvg-filter.h
rsvg-marker.c
rsvg-marker.h
rsvg-mask.c
rsvg-mask.h
rsvg-shapes.c
rsvg-shapes.h
rsvg-structure.c
rsvg-structure.h
rsvg-styles.c
rsvg-styles.h
rsvg-text.c
rsvg-text.h
rsvg-cond.c
rsvg-base.c
librsvg-enum-types.c
rsvg-cairo-draw.c
rsvg-cairo-draw.h
rsvg-cairo-render.c
rsvg-cairo-render.h
rsvg-cairo-clip.h
rsvg-cairo-clip.c
rsvg.c
rsvg-gobject.c
rsvg-file-util.c
rsvg-size-callback.c
rsvg-size-callback.h
rsvg-xml.c
rsvg-xml.h
rsvg.h
rsvg-cairo.h
librsvg-features.h
librsvg-enum-types.h
)

set(PIXBUFLOADERSVG_SOURCES
gdk-pixbuf-loader/io-svg.c
)

if(WIN32)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.win32 ${CMAKE_CURRENT_SOURCE_DIR}/config.h COPYONLY)
add_custom_command(OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/rsvg.def
COMMAND echo "EXPORTS" > ${CMAKE_CURRENT_SOURCE_DIR}/rsvg.def
COMMAND ${CMAKE_C_COMPILER} /EP ${CMAKE_CURRENT_SOURCE_DIR}/rsvg.symbols >> ${CMAKE_CURRENT_SOURCE_DIR}/rsvg.def)
list(APPEND LIBRSVG_SOURCES rsvg.def)
else()
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.linux ${CMAKE_CURRENT_SOURCE_DIR}/config.h COPYONLY)
list(APPEND LIBRSVG_SOURCES rsvg.symbols)
endif()

set(CMAKE_DEBUG_POSTFIX "d")

add_library(rsvg-2.40 ${LIBRSVG_SOURCES})
add_library(pixbufloader-svg ${PIXBUFLOADERSVG_SOURCES})

target_compile_definitions(rsvg-2.40 PRIVATE -DRSVG_COMPILATION -D_CRT_SECURE_NO_WARNINGS -DSRCDIR="${CMAKE_CURRENT_SOURCE_DIR}")

target_include_directories(pixbufloader-svg PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_compile_definitions(pixbufloader-svg PRIVATE
-DRSVG_COMPILATION
-D_CRT_SECURE_NO_WARNINGS
-DSRCDIR="${CMAKE_CURRENT_SOURCE_DIR}"
-DGDK_PIXBUF_ENABLE_BACKEND
-DG_LOG_DOMAIN="libpixbufloader-svg")

target_link_libraries(rsvg-2.40 PRIVATE
unofficial::cairo::cairo
unofficial::libcroco::croco-0.6
unofficial::glib::gio
unofficial::glib::glib
unofficial::glib::gmodule
unofficial::glib::gobject
${LIBXML2_LIBRARIES}
${PANGO_LIB}
${PANGO_CAIRO_LIB}
${GDK_PIXBUF_LIB}
)
target_link_libraries(pixbufloader-svg PRIVATE
rsvg-2.40
unofficial::glib::glib
unofficial::glib::gobject
${GDK_PIXBUF_LIB}
)

install(TARGETS rsvg-2.40 pixbufloader-svg
EXPORT librsvg-targets
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
)

install(
EXPORT librsvg-targets
NAMESPACE unofficial::librsvg::
FILE unofficial-librsvg-targets.cmake
DESTINATION share/unofficial-librsvg
)

install(FILES
rsvg.h
rsvg-cairo.h
librsvg-features.h
librsvg-enum-types.h
DESTINATION include/librsvg
)

file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/unofficial-librsvg-config.cmake "
include(CMakeFindDependencyMacro)
find_dependency(unofficial-cairo CONFIG)
find_dependency(unofficial-libcroco CONFIG)
find_dependency(gdk-pixbuf CONFIG)
find_dependency(pango CONFIG)

include(\${CMAKE_CURRENT_LIST_DIR}/unofficial-librsvg-targets.cmake)
")
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/unofficial-librsvg-config.cmake DESTINATION share/unofficial-librsvg)
4 changes: 4 additions & 0 deletions ports/librsvg/CONTROL
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Source: librsvg
Version: 2.40.20
Description: A small library to render Scalable Vector Graphics (SVG)
Build-Depends: cairo, pango, gdk-pixbuf, libcroco
89 changes: 89 additions & 0 deletions ports/librsvg/config.h.linux
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
/* config.h. Generated from config.h.in by configure. */
/* config.h.in. Generated from configure.ac by autoheader. */

/* Define if building universal (internal helper macro) */
/* #undef AC_APPLE_UNIVERSAL_BUILD */

/* Define to 1 if you have the <dlfcn.h> header file. */
#define HAVE_DLFCN_H 1

/* Define to 1 if you have the <inttypes.h> header file. */
#define HAVE_INTTYPES_H 1

/* Define if your <locale.h> file defines LC_MESSAGES. */
#define HAVE_LC_MESSAGES 1

/* Define to 1 if you have the <locale.h> header file. */
#define HAVE_LOCALE_H 1

/* Define to 1 if you have the <memory.h> header file. */
#define HAVE_MEMORY_H 1

/* Have the pangoft2 library */
#define HAVE_PANGOFT2 1

/* Define to 1 if you have the <stdint.h> header file. */
#define HAVE_STDINT_H 1

/* Define to 1 if you have the <stdlib.h> header file. */
#define HAVE_STDLIB_H 1

/* Define to 1 if you have the <strings.h> header file. */
#define HAVE_STRINGS_H 1

/* Define to 1 if you have the <string.h> header file. */
#define HAVE_STRING_H 1

/* Define to 1 if you have the `strtok_r' function. */
#define HAVE_STRTOK_R 1

/* Define to 1 if you have the <sys/stat.h> header file. */
#define HAVE_SYS_STAT_H 1

/* Define to 1 if you have the <sys/types.h> header file. */
#define HAVE_SYS_TYPES_H 1

/* Define to 1 if you have the <unistd.h> header file. */
#define HAVE_UNISTD_H 1

/* Define to the sub-directory where libtool stores uninstalled libraries. */
#define LT_OBJDIR ".libs/"

/* Name of package */
#define PACKAGE "librsvg"

/* Define to the address where bug reports for this package should be sent. */
#define PACKAGE_BUGREPORT "https://bugzilla.gnome.org/enter_bug.cgi?product=librsvg"

/* Define to the full name of this package. */
#define PACKAGE_NAME "RSVG"

/* Define to the full name and version of this package. */
#define PACKAGE_STRING "RSVG 2.40.20"

/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "librsvg"

/* Define to the home page for this package. */
#define PACKAGE_URL ""

/* Define to the version of this package. */
#define PACKAGE_VERSION "2.40.20"

/* Define to 1 if you have the ANSI C header files. */
#define STDC_HEADERS 1

/* Version number of package */
#define VERSION "2.40.20"

/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
significant byte first (like Motorola and SPARC, unlike Intel). */
#if defined AC_APPLE_UNIVERSAL_BUILD
# if defined __BIG_ENDIAN__
# define WORDS_BIGENDIAN 1
# endif
#else
# ifndef WORDS_BIGENDIAN
/* # undef WORDS_BIGENDIAN */
# endif
#endif
32 changes: 32 additions & 0 deletions ports/librsvg/portfile.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
include(vcpkg_common_functions)

vcpkg_download_distfile(ARCHIVE
URLS "https://download.gnome.org/sources/librsvg/2.40/librsvg-2.40.20.tar.xz"
FILENAME "librsvg-2.40.20.tar.xz"
SHA512 cdd8224deb4c3786e29f48ed02c32ed9dff5cb15aba574a5ef845801ad3669cfcc3eedb9d359c22213dc7a29de24c363248825adad5877c40abf73b3688ff12f
)

vcpkg_extract_source_archive_ex(
OUT_SOURCE_PATH SOURCE_PATH
ARCHIVE ${ARCHIVE}
)

file(COPY ${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt DESTINATION ${SOURCE_PATH})
configure_file(${CMAKE_CURRENT_LIST_DIR}/config.h.linux ${SOURCE_PATH}/config.h.linux COPYONLY)

vcpkg_configure_cmake(
SOURCE_PATH ${SOURCE_PATH}
PREFER_NINJA # Disable this option if project cannot be built with Ninja
)

vcpkg_install_cmake()

vcpkg_fixup_cmake_targets(CONFIG_PATH share/unofficial-librsvg TARGET_PATH share/unofficial-librsvg)
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include)

# Handle copyright
file(INSTALL ${SOURCE_PATH}/COPYING DESTINATION ${CURRENT_PACKAGES_DIR}/share/librsvg RENAME copyright)

vcpkg_copy_pdbs()

vcpkg_test_cmake(PACKAGE_NAME unofficial-librsvg)