Set the --shared-memory linker flag for Emscripten builds.

This is only needed when building with WEBP support, which uses atomics,
therefore the linker needs the --shared-memory flag. The flag cannot be
added globally because not all executables link against libwebp.
This commit is contained in:
Attila Oláh 2020-09-24 16:22:25 +00:00
parent c8f0a16f4a
commit 433e052356
No known key found for this signature in database
GPG Key ID: 07E6C0643FD142C3
4 changed files with 59 additions and 0 deletions

View File

@ -32,3 +32,9 @@ include_directories(${PROJECT_SOURCE_DIR}/libtiff
add_executable(addtiffo addtiffo.c tif_overview.c tif_ovrcache.c tif_ovrcache.h)
target_link_libraries(addtiffo tiff port)
if(WEBP_SUPPORT AND EMSCRIPTEN)
# Emscripten is pretty finnicky about linker flags.
# It needs --shared-memory if and only if atomics or bulk-memory is used.
target_link_options(addtiffo PUBLIC "-Wl,--shared-memory")
endif()

View File

@ -41,3 +41,14 @@ target_link_libraries(tiff-rgb tiff port)
add_subdirectory(xtiff)
extra_dist(README)
if(WEBP_SUPPORT AND EMSCRIPTEN)
# Emscripten is pretty finnicky about linker flags.
# It needs --shared-memory if and only if atomics or bulk-memory is used.
foreach(target tiff-bi
tiff-grayscale
tiff-palette
tiff-rgb)
target_link_options(${target} PUBLIC "-Wl,--shared-memory")
endforeach()
endif()

View File

@ -220,6 +220,21 @@ target_link_libraries(defer_strile_writing tiff port)
add_executable(testtypes testtypes.c)
target_link_libraries(testtypes tiff port)
if(WEBP_SUPPORT AND EMSCRIPTEN)
# Emscripten is pretty finnicky about linker flags.
# It needs --shared-memory if and only if atomics or bulk-memory is used.
foreach(target ascii_tag
custom_dir
defer_strile_loading
defer_strile_writing
long_tag
rewrite
short_tag
strip_rw)
target_link_options(${target} PUBLIC "-Wl,--shared-memory")
endforeach()
endif()
set(TEST_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/output")
file(MAKE_DIRECTORY "${TEST_OUTPUT}")

View File

@ -123,3 +123,30 @@ if(HAVE_OPENGL)
install(TARGETS tiffgt
RUNTIME DESTINATION "${CMAKE_INSTALL_FULL_BINDIR}")
endif()
if(WEBP_SUPPORT AND EMSCRIPTEN)
# Emscripten is pretty finnicky about linker flags.
# It needs --shared-memory if and only if atomics or bulk-memory is used.
foreach(target fax2ps
fax2tiff
pal2rgb
ppm2tiff
raw2tiff
rgb2ycbcr
thumbnail
tiff2bw
tiff2pdf
tiff2ps
tiff2rgba
tiffcmp
tiffcp
tiffcrop
tiffdither
tiffdump
tiffinfo
tiffmedian
tiffset
tiffsplit)
target_link_options(${target} PUBLIC "-Wl,--shared-memory")
endforeach()
endif()