Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit d87a212

Browse filesBrowse files
committed
fix linker errors when building Apple executables
GraphicsMagick, as installed via Homebrew (https://brew.sh), has library dependencies that must be linked-to at link-time. Various io2d backends have been linking to these directly, except the SDL2 backend. SDL2's backend now instructs executables to link to GraphicsMagick's dependencies, when targeting Apple platform(s). This was implemented using similar means to other io2d backends, but with a bit more use of CMake's find_package(...) function.
1 parent dc0a635 commit d87a212
Copy full SHA for d87a212

File tree

Expand file treeCollapse file tree

1 file changed

+54
-1
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+54
-1
lines changed

‎P0267_RefImpl/P0267_RefImpl/cairo/sdl2/CMakeLists.txt

Copy file name to clipboardExpand all lines: P0267_RefImpl/P0267_RefImpl/cairo/sdl2/CMakeLists.txt
+54-1Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,36 @@ project(io2d CXX)
44
# Find dependencies
55
find_package(SDL2 REQUIRED)
66

7+
# HACK: on Apple, find + link-to dependencies of GraphicsMagick,
8+
# lest we get linker errors when building certain demo-apps
9+
if (APPLE)
10+
find_package(LibXml2 REQUIRED)
11+
find_package(PNG REQUIRED)
12+
find_package(JPEG REQUIRED)
13+
find_package(ZLIB REQUIRED)
14+
find_package(X11 REQUIRED)
15+
find_package(TIFF REQUIRED)
16+
find_package(Freetype REQUIRED)
17+
find_package(BZip2 REQUIRED)
18+
19+
# Use find_library(...), rather than find_package(...), for
20+
# stuff that doesn't have CMake find_package(...) modules.
21+
find_library(LCMS2_LIBRARIES lcms2)
22+
if (NOT LCMS2_LIBRARIES)
23+
message(FATAL_ERROR "Unable to find library: lcms2")
24+
endif()
25+
26+
find_library(WEBP_LIBRARIES webp)
27+
if (NOT WEBP_LIBRARIES)
28+
message(FATAL_ERROR "Unable to find library: webp")
29+
endif()
30+
31+
find_library(WEBPMUX_LIBRARIES webpmux)
32+
if (NOT WEBPMUX_LIBRARIES)
33+
message(FATAL_ERROR "Unable to find library: webpmux")
34+
endif()
35+
endif()
36+
737
# Create and configure library
838
add_library(io2d_cairo_sdl2
939
cairo_renderer_sdl2.cpp
@@ -21,7 +51,30 @@ target_include_directories(io2d_cairo_sdl2 PUBLIC
2151
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
2252
${SDL2_INCLUDE_DIRS}
2353
)
24-
target_link_libraries(io2d_cairo_sdl2 PUBLIC io2d_cairo ${SDL2_LIBRARIES})
54+
target_link_libraries(io2d_cairo_sdl2
55+
PUBLIC
56+
io2d_cairo
57+
${SDL2_LIBRARIES}
58+
)
59+
60+
if (APPLE)
61+
# Follow-up with above hack, regarding linking of GraphicsMagick's
62+
# dependencies (lest we may get linker errors).
63+
target_link_libraries(io2d_cairo_sdl2
64+
PUBLIC
65+
# LibXml2::LibXml2 # dludwig@pobox.com: this causes errors for me when building with Homebrew installed, on macOS 10.14
66+
${LIBXML2_LIBRARIES}
67+
PNG::PNG
68+
JPEG::JPEG
69+
${LCMS2_LIBRARIES}
70+
${X11_LIBRARIES}
71+
${WEBP_LIBRARIES}
72+
${WEBPMUX_LIBRARIES}
73+
TIFF::TIFF
74+
Freetype::Freetype
75+
BZip2::BZip2
76+
)
77+
endif()
2578

2679
# Install library artifact(s)
2780
install(

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.