Skip to content

Add support for Apple framework builds #1444

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

Merged
merged 4 commits into from
Jan 23, 2025
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
# see here: https://stackoverflow.com/questions/7335420/global-git-ignore

build
_build
third-party/SVT-AV1/
third-party/dav1d/
third-party/libwebp/
third-party/rav1e/
third-party/rav1e/
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ if (HAVE_UNISTD_H)
add_definitions(-DHAVE_UNISTD_H)
endif()

if (APPLE)
option(BUILD_FRAMEWORK "Build as Apple Frameworks" OFF)
endif()

set(CMAKE_COMPILE_WARNING_AS_ERROR ON CACHE BOOL "Treat compilation warning as error")

if(NOT MSVC)
Expand Down
21 changes: 19 additions & 2 deletions libheif/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,27 @@ set_target_properties(heif
SOVERSION ${PROJECT_VERSION_MAJOR})

if (APPLE)
set_target_properties(heif
PROPERTIES
set_target_properties(heif PROPERTIES
LINK_FLAGS "-Wl,-compatibility_version,${MACOS_COMPATIBLE_VERSION}")
endif ()

if (BUILD_FRAMEWORK)
set_target_properties(heif PROPERTIES
FRAMEWORK TRUE
FRAMEWORK_VERSION "${PACKAGE_VERSION}"
PRODUCT_BUNDLE_IDENTIFIER "github.com/strukturag/libheif"
XCODE_ATTRIBUTE_INSTALL_PATH "@rpath"
# OUTPUT_NAME "heif"
XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY ""
XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED "NO"
XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO"
PUBLIC_HEADER "${libheif_headers}"
MACOSX_FRAMEWORK_IDENTIFIER "github.com/strukturag/libheif"
MACOSX_FRAMEWORK_BUNDLE_VERSION "${PACKAGE_VERSION}"
MACOSX_FRAMEWORK_SHORT_VERSION_STRING "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}"
MACOSX_RPATH TRUE)
endif()

target_compile_definitions(heif
PUBLIC
LIBHEIF_EXPORTS
Expand Down Expand Up @@ -239,6 +255,7 @@ install(TARGETS heif EXPORT ${PROJECT_NAME}-config
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
FRAMEWORK DESTINATION Library/Frameworks COMPONENT runtime OPTIONAL
)

install(FILES ${libheif_headers} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME})
Expand Down
Loading