Skip to content

Commit a8f76d9

Browse files
committed
Fix linker flags quoting for macOS static builds
1 parent 396d37e commit a8f76d9

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ option(ENABLE_STATIC "Build static library" OFF)
3737
option(ENABLE_TESTS "Build unit tests" ON)
3838
option(ENABLE_GIO "Support for gio file uris" OFF)
3939
option(ENABLE_THUMBNAILER "Register ffmpegthumbnailer as thumbnailer" OFF)
40+
option(ENABLE_FULL_STATIC "Build fully static binary" OFF)
4041
option(SANITIZE_ADDRESS "Build with address sanitizer (detect invalid memory access and memory leaks)" OFF)
4142

4243
if (SANITIZE_ADDRESS)

cmake/FindFFmpeg.cmake

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,7 @@ mark_as_advanced(
5151
)
5252

5353
# Determine if we need static linking
54-
set(FFMPEG_USE_STATIC_LIBS OFF)
55-
if(NOT BUILD_SHARED_LIBS OR ENABLE_STATIC)
56-
set(FFMPEG_USE_STATIC_LIBS ON)
57-
endif()
54+
set(FFMPEG_USE_STATIC_LIBS ${ENABLE_FULL_STATIC})
5855

5956
message(STATUS "FFmpeg found: ${FFmpeg_FOUND}")
6057
message(STATUS " avcodec: ${AVCODEC_LIBRARY_PATH}")
@@ -115,6 +112,11 @@ if(FFmpeg_FOUND AND NOT TARGET FFmpeg::avcodec)
115112
INTERFACE_LINK_DIRECTORIES "${AVCODEC_STATIC_LIBRARY_DIRS}")
116113
set_property(TARGET FFmpeg::avcodec APPEND PROPERTY
117114
INTERFACE_LINK_LIBRARIES "${AVCODEC_STATIC_LIBRARIES}")
115+
116+
if(APPLE)
117+
set_property(TARGET FFmpeg::avcodec APPEND PROPERTY
118+
INTERFACE_LINK_LIBRARIES "-framework CoreVideo" "-framework CoreImage" "-framework VideoToolbox")
119+
endif()
118120
endif()
119121
endif()
120122

flake.nix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,8 @@
169169
++ pkgsForHost.lib.optionals (isStatic && !isWindows && pkgsForHost.stdenv.isLinux) [
170170
"-DCMAKE_EXE_LINKER_FLAGS=-static"
171171
]
172-
++ pkgsForHost.lib.optionals (isStatic && pkgsForHost.stdenv.isDarwin) [
173-
"-DCMAKE_EXE_LINKER_FLAGS=-framework CoreVideo;-framework VideoToolbox"
172+
++ pkgsForHost.lib.optionals isStatic [
173+
"-DENABLE_FULL_STATIC=ON"
174174
]
175175
++ pkgsForHost.lib.optionals (pkgsForHost.stdenv.isLinux && !isStatic && !isWindows) [
176176
"-DENABLE_GIO=ON"

0 commit comments

Comments
 (0)