Skip to content

Commit

Permalink
fix pixman and cairo for macOS (#3923)
Browse files Browse the repository at this point in the history
* fix pixman error message about Unknown thread local support

* fixes for building cairo on macOS

* corrected appending files to sources

* [cairo][pixman] Bump package versions to include source code changes
  • Loading branch information
angelmixu authored and ras0219-msft committed Aug 1, 2018
1 parent 0618d13 commit 81d3b2c
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 15 deletions.
13 changes: 13 additions & 0 deletions ports/cairo/0001_fix_osx_defined.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/src/cairo-ft-font.c b/src/cairo-ft-font.c
index 3b308757..36700ff0 100644
--- a/src/cairo-ft-font.c
+++ b/src/cairo-ft-font.c
@@ -67,7 +67,7 @@
#include FT_LCD_FILTER_H
#endif

-#if HAVE_UNISTD_H
+#if defined(HAVE_UNISTD_H)
#include <unistd.h>
#else
#define access(p, m) 0
53 changes: 40 additions & 13 deletions ports/cairo/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ cmake_minimum_required(VERSION 3.0)
project(cairo C)

# Add include directories
include_directories("." "./win32")
include_directories(".")
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
include_directories("./win32")
endif()

file(GLOB SOURCES
"cairo-analysis-surface.c"
Expand Down Expand Up @@ -112,15 +115,6 @@ file(GLOB SOURCES
"cairo-user-font.c"
"cairo-version.c"
"cairo-wideint.c"
# win32
"win32/cairo-win32-debug.c"
"win32/cairo-win32-device.c"
"win32/cairo-win32-gdi-compositor.c"
"win32/cairo-win32-system.c"
"win32/cairo-win32-surface.c"
"win32/cairo-win32-display-surface.c"
"win32/cairo-win32-printing-surface.c"
"win32/cairo-win32-font.c"
# generic font support
"cairo-cff-subset.c"
"cairo-scaled-font-subsets.c"
Expand Down Expand Up @@ -148,6 +142,22 @@ file(GLOB SOURCES
"cairo-ft-font.c"
)

# win32
file(GLOB PLATFORM_SOURCES_WIN32
"win32/cairo-win32-debug.c"
"win32/cairo-win32-device.c"
"win32/cairo-win32-gdi-compositor.c"
"win32/cairo-win32-system.c"
"win32/cairo-win32-surface.c"
"win32/cairo-win32-display-surface.c"
"win32/cairo-win32-printing-surface.c"
"win32/cairo-win32-font.c"
)

if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
list(APPEND SOURCES ${PLATFORM_SOURCES_WIN32})
endif()

set(CMAKE_DEBUG_POSTFIX "d")

find_package(ZLIB REQUIRED)
Expand All @@ -172,10 +182,27 @@ add_definitions(
# Find FontConfig
find_library(FONTCONFIG_LIBRARY fontconfig)

# additional features for macOS
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
add_definitions(
-DHAVE_INTTYPES_H=1
-DHAVE_STDINT_H=1
-DHAVE_SYS_TYPES_H=1
-DHAVE_UINT64_T=1
-DHAVE_UNISTD_H=1
-DCAIRO_HAS_PTHREAD=1
-DCAIRO_HAS_REAL_PTHREAD=1)
endif()

add_library(cairo ${SOURCES})
# cairo produces a lot of warnings which are disabled here because they otherwise fill up the log files
target_compile_options(cairo PUBLIC "/wd4244" PUBLIC "/wd4146" PUBLIC "/wd4312" PUBLIC "/wd4267"
PUBLIC "/wd4996" PUBLIC "/wd4311" PUBLIC "/wd4334" PUBLIC "/wd4101")

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 PUBLIC "/wd4244" PUBLIC "/wd4146" PUBLIC "/wd4312" PUBLIC "/wd4267"
PUBLIC "/wd4996" PUBLIC "/wd4311" PUBLIC "/wd4334" PUBLIC "/wd4101")
endif()

target_link_libraries(cairo gdi32 msimg32 user32 ZLIB::ZLIB PNG::PNG freetype ${PIXMAN_LIBRARY} ${FONTCONFIG_LIBRARY})

install(TARGETS cairo
Expand Down
2 changes: 1 addition & 1 deletion ports/cairo/CONTROL
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Source: cairo
Version: 1.15.8-1
Version: 1.15.8-2
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
1 change: 1 addition & 0 deletions ports/cairo/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ vcpkg_extract_source_archive(${ARCHIVE})
vcpkg_apply_patches(
SOURCE_PATH ${SOURCE_PATH}
PATCHES "${CMAKE_CURRENT_LIST_DIR}/export-only-in-shared-build.patch"
"${CMAKE_CURRENT_LIST_DIR}/0001_fix_osx_defined.patch"
)

file(COPY ${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt DESTINATION ${SOURCE_PATH}/src)
Expand Down
5 changes: 5 additions & 0 deletions ports/pixman/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ project(pixman VERSION 0.32.0 LANGUAGES C)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
set(CMAKE_DEBUG_POSTFIX "d")

if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
add_definitions(-DTLS=__thread)
add_definitions(-DHAVE_PTHREADS)
endif()

include_directories(".")

file(GLOB SOURCES
Expand Down
2 changes: 1 addition & 1 deletion ports/pixman/CONTROL
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Source: pixman
Version: 0.34.0-2
Version: 0.34.0-3
Description: Pixman is a low-level software library for pixel manipulation, providing features such as image compositing and trapezoid rasterization.

0 comments on commit 81d3b2c

Please sign in to comment.