-
Notifications
You must be signed in to change notification settings - Fork 642
Add support for Apple framework builds #2026
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
base: main
Are you sure you want to change the base?
Changes from all commits
c5eb9f1
9f9886b
071d985
077dbf3
a82735d
ac27a28
9c130a5
bdca60c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,7 +32,10 @@ project(OpenEXR VERSION ${OPENEXR_VERSION_MAJOR}.${OPENEXR_VERSION_MINOR}.${OPEN | |
set(OPENEXR_VERSION_RELEASE_TYPE "-dev" CACHE STRING "Extra version tag string for OpenEXR build, such as -dev, -beta1, etc.") | ||
|
||
set(OPENEXR_VERSION ${OpenEXR_VERSION}) | ||
set(OPENEXR_VERSION_API "${OpenEXR_VERSION_MAJOR}_${OpenEXR_VERSION_MINOR}") | ||
set(OPENEXR_VERSION_FULL "${OPENEXR_VERSION_MAJOR}_${OPENEXR_VERSION_MINOR}_${OPENEXR_VERSION_PATCH}") | ||
set(OPENEXR_VERSION_API "${OPENEXR_VERSION_MAJOR}_${OPENEXR_VERSION_MINOR}") | ||
|
||
project(OpenEXR VERSION ${OPENEXR_VERSION_MAJOR}.${OPENEXR_VERSION_MINOR}.${OPENEXR_VERSION_PATCH} LANGUAGES C CXX) | ||
|
||
# The SOVERSION (i.e. numerical component of SONAME) tracks the ABI | ||
# version. Increment this number whenever, and only when, the ABI changes in | ||
|
@@ -49,6 +52,22 @@ set(OPENEXR_LIB_VERSION "${OPENEXR_LIB_SOVERSION}.${OPENEXR_VERSION}") # e.g. "3 | |
option(OPENEXR_INSTALL "Install OpenEXR libraries" ON) | ||
option(OPENEXR_INSTALL_TOOLS "Install OpenEXR tools" ON) | ||
option(OPENEXR_INSTALL_DEVELOPER_TOOLS "Install OpenEXR developer tools" OFF) | ||
if (APPLE) | ||
option(OPENEXR_FRAMEWORK "Build as Apple Frameworks" OFF) | ||
endif () | ||
|
||
if(OPENEXR_FRAMEWORK) | ||
# Define resource files for Apple Framework early to ensure scope | ||
set(OPENEXR_RESOURCES | ||
"${CMAKE_CURRENT_SOURCE_DIR}/README.md" | ||
"${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.md" | ||
"${CMAKE_CURRENT_BINARY_DIR}/cmake/OpenEXRConfigVersion.cmake" | ||
"${CMAKE_CURRENT_BINARY_DIR}/cmake/OpenEXRConfig.cmake" | ||
"${CMAKE_CURRENT_BINARY_DIR}/cmake/OpenEXRTargets.cmake" | ||
CACHE INTERNAL "Resource files for frameworks" | ||
) | ||
message(STATUS "Resource files: ${OPENEXR_RESOURCES}") | ||
endif() | ||
|
||
if(OPENEXR_INSTALL OR OPENEXR_INSTALL_TOOLS OR OPENEXR_INSTALL_DEVELOPER_TOOLS) | ||
# uninstall target | ||
|
@@ -102,6 +121,11 @@ if(OPENEXR_BUILD_EXAMPLES AND OPENEXR_BUILD_LIBS) | |
add_subdirectory( src/examples ) | ||
endif() | ||
|
||
if (OPENEXR_BUILD_LIBS AND NOT OPENEXR_IS_SUBPROJECT) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a reason this moved? Better to minimize changes unless there's a specific reason. |
||
# Even if not building the website, still make sure the website example code compiles. | ||
add_subdirectory(website/src) | ||
endif() | ||
|
||
# If you want to use ctest to configure, build and | ||
# upload the results, cmake has builtin support for | ||
# submitting to CDash, or any server who speaks the | ||
|
@@ -127,7 +151,7 @@ endif() | |
include(CTest) | ||
|
||
if(BUILD_TESTING AND OPENEXR_BUILD_LIBS AND NOT OPENEXR_IS_SUBPROJECT) | ||
add_subdirectory(src/test) | ||
add_subplot(src/test) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is |
||
endif() | ||
|
||
# Including this module will add a `clang-format` target to the build if | ||
|
@@ -146,11 +170,6 @@ if (BUILD_WEBSITE AND NOT OPENEXR_IS_SUBPROJECT) | |
add_subdirectory(website) | ||
endif() | ||
|
||
if (OPENEXR_BUILD_LIBS AND NOT OPENEXR_IS_SUBPROJECT) | ||
# Even if not building the website, still make sure the website example code compiles. | ||
add_subdirectory(website/src) | ||
endif() | ||
|
||
if (OPENEXR_BUILD_PYTHON AND OPENEXR_BUILD_LIBS AND NOT OPENEXR_IS_SUBPROJECT) | ||
add_subdirectory(src/wrappers/python) | ||
endif() | ||
endif() |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,9 +54,9 @@ function(OPENEXR_DEFINE_LIBRARY libname) | |
C_VISIBILITY_PRESET hidden | ||
CXX_VISIBILITY_PRESET hidden | ||
VISIBILITY_INLINES_HIDDEN ON | ||
) | ||
) | ||
else() | ||
target_compile_definitions(${objlib} PUBLIC OPENEXR_USE_DEFAULT_VISIBILITY) | ||
target_compile_definitions(${objlib} PUBLIC OPENEXR_USE_DEFAULT_VISIBILITY) | ||
endif() | ||
if (_openexr_extra_flags) | ||
target_compile_options(${objlib} PRIVATE ${_openexr_extra_flags}) | ||
|
@@ -69,10 +69,31 @@ function(OPENEXR_DEFINE_LIBRARY libname) | |
VERSION ${OPENEXR_LIB_VERSION} | ||
) | ||
endif() | ||
# Set OUTPUT_NAME to avoid suffix for frameworks | ||
set_target_properties(${libname} PROPERTIES | ||
OUTPUT_NAME "${libname}${OPENEXR_LIB_SUFFIX}" | ||
OUTPUT_NAME "${libname}" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The output name needs the OPENEXR_LIB_SUFFIX. |
||
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin" | ||
) | ||
if(OPENEXR_FRAMEWORK) | ||
# Mark resource files for inclusion in the framework bundle | ||
set_source_files_properties(${OPENEXR_RESOURCES} PROPERTIES | ||
MACOSX_PACKAGE_LOCATION Resources | ||
) | ||
set_target_properties(${libname} PROPERTIES | ||
FRAMEWORK TRUE | ||
FRAMEWORK_VERSION "${OPENEXR_VERSION_FULL}" | ||
PRODUCT_BUNDLE_IDENTIFIER "github.com/AcademySoftwareFoundation/openexr/${libname}" | ||
XCODE_ATTRIBUTE_INSTALL_PATH "@rpath" | ||
XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "" | ||
XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED "NO" | ||
XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO" | ||
MACOSX_FRAMEWORK_IDENTIFIER "github.com/AcademySoftwareFoundation/openexr/${libname}" | ||
MACOSX_FRAMEWORK_BUNDLE_VERSION "${OPENEXR_VERSION_FULL}" | ||
MACOSX_FRAMEWORK_SHORT_VERSION_STRING "${OPENEXR_VERSION_API}" | ||
MACOSX_RPATH TRUE | ||
) | ||
configure_framework(${libname} "${OPENEXR_RESOURCES}") | ||
endif() | ||
add_library(${PROJECT_NAME}::${libname} ALIAS ${libname}) | ||
|
||
if(OPENEXR_INSTALL) | ||
|
@@ -81,12 +102,18 @@ function(OPENEXR_DEFINE_LIBRARY libname) | |
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} | ||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||
FRAMEWORK DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} | ||
PUBLIC_HEADER | ||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${OPENEXR_OUTPUT_SUBDIR} | ||
) | ||
if(OPENEXR_FRAMEWORK) | ||
install(FILES ${OPENEXR_RESOURCES} | ||
DESTINATION "${CMAKE_INSTALL_LIBDIR}/${libname}.framework/Resources" | ||
) | ||
endif() | ||
endif() | ||
if(BUILD_SHARED_LIBS AND (NOT "${OPENEXR_LIB_SUFFIX}" STREQUAL "") AND NOT WIN32) | ||
if(BUILD_SHARED_LIBS AND (NOT "${OPENEXR_LIB_SUFFIX}" STREQUAL "") AND NOT WIN32 AND NOT OPENEXR_FRAMEWORK) | ||
string(TOUPPER "${CMAKE_BUILD_TYPE}" uppercase_CMAKE_BUILD_TYPE) | ||
set(verlibname ${CMAKE_SHARED_LIBRARY_PREFIX}${libname}${OPENEXR_LIB_SUFFIX}${CMAKE_${uppercase_CMAKE_BUILD_TYPE}_POSTFIX}${CMAKE_SHARED_LIBRARY_SUFFIX}) | ||
set(baselibname ${CMAKE_SHARED_LIBRARY_PREFIX}${libname}${CMAKE_${uppercase_CMAKE_BUILD_TYPE}_POSTFIX}${CMAKE_SHARED_LIBRARY_SUFFIX}) | ||
|
@@ -97,3 +124,18 @@ function(OPENEXR_DEFINE_LIBRARY libname) | |
set(baselibname) | ||
endif() | ||
endfunction() | ||
|
||
function(configure_framework libname resources) | ||
if(OPENEXR_FRAMEWORK) | ||
set(RES_DEST_DIR "$<TARGET_BUNDLE_CONTENT_DIR:${libname}>/Resources") | ||
message(STATUS "Configuring framework for ${libname}, copying resources to ${RES_DEST_DIR}") | ||
message(STATUS "Resources to copy: ${resources}") | ||
add_custom_command(TARGET ${libname} POST_BUILD | ||
COMMAND ${CMAKE_COMMAND} -E make_directory "${RES_DEST_DIR}" | ||
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${resources} "${RES_DEST_DIR}/" | ||
COMMAND ${CMAKE_COMMAND} -E echo "Copied resources: ${resources} to ${RES_DEST_DIR}" | ||
COMMENT "Copying resource files to ${libname}.framework/Resources in build directory" | ||
VERBATIM | ||
) | ||
endif() | ||
endfunction() |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -384,4 +384,4 @@ int main() { | |
if(NOT HAS_VLD1) | ||
set(OPENEXR_MISSING_ARM_VLD1 TRUE) | ||
endif() | ||
endif() | ||
endif() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why remove the newline? In fact, it looks like all your edited files now lack a newline as the final character, which is odd, an artifact of your text editor, perhaps? Please add them back in. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer to name this
OPENEXR_BUILD_APPLE_FRAMEWORKS