Skip to content

Commit

Permalink
Enable Cross-Compilation for iOS.
Browse files Browse the repository at this point in the history
Signed-off-by: Treata11 <[email protected]>
  • Loading branch information
Treata11 committed Dec 24, 2024
1 parent aa28eb5 commit 802895e
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ if (BUILD_WEBSITE AND NOT IMATH_IS_SUBPROJECT)
add_subdirectory(website)
endif()

if (APPLE)
option(IMATH_BUILD_APPLE_FRAMEWORKS "Build as Apple Frameworks" OFF)
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
Expand Down
16 changes: 12 additions & 4 deletions config/LibraryDefine.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,18 @@ function(IMATH_DEFINE_LIBRARY libname)
if (IMATH_INSTALL)
install(TARGETS ${libname}
EXPORT ${PROJECT_NAME}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
RUNTIME
DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY
DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE
DESTINATION ${CMAKE_INSTALL_LIBDIR}
FRAMEWORK
DESTINATION ${CMAKE_INSTALL_LIBDIR}
COMPONENT runtime
OPTIONAL
INCLUDES
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
PUBLIC_HEADER
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${IMATH_OUTPUT_SUBDIR}
)
Expand Down
10 changes: 10 additions & 0 deletions src/Imath/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,13 @@ imath_define_library(Imath
ImathVec.h
ImathVecAlgo.h
)

if(IMATH_BUILD_APPLE_FRAMEWORKS)
set_target_properties(Imath PROPERTIES
FRAMEWORK TRUE
FRAMEWORK_VERSION IMATH_LIB_VERSION
XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER com.AcademySoftwareFoundation.Imath
MACOSX_FRAMEWORK_IDENTIFIER com.AcademySoftwareFoundation.Imath
MACOSX_FRAMEWORK_BUNDLE_VERSION IMATH_LIB_VERSION
MACOSX_FRAMEWORK_SHORT_VERSION_STRING ${Imath_VERSION})
endif()
4 changes: 4 additions & 0 deletions src/ImathTest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ function(DEFINE_IMATH_TESTS)
endforeach()
endfunction()

if (TBB_BUILD_APPLE_FRAMEWORKS)
add_compile_definitions(TBB_USE_APPLE_FRAMEWORKS)
endif()

define_imath_tests(
testToFloat
testSize
Expand Down
11 changes: 11 additions & 0 deletions src/pybind11/PyBindImath/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ if (IMATH_INSTALL)
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})

if(BUILD_SHARED_LIBS AND (NOT "${IMATH_LIB_SUFFIX}" STREQUAL "") AND IMATH_INSTALL_SYM_LINK)
Expand Down Expand Up @@ -109,3 +110,13 @@ if (IMATH_INSTALL)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${pcout} DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)

endif()

if(IMATH_BUILD_APPLE_FRAMEWORKS)
set_target_properties(${PYBINDIMATH_LIBRARY} PROPERTIES
FRAMEWORK TRUE
FRAMEWORK_VERSION PYBINDIMATH_LIB_SUFFIX
XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER com.AcademySoftwareFoundation.Imath.PyBind
MACOSX_FRAMEWORK_IDENTIFIER com.AcademySoftwareFoundation.Imath.PyBind
MACOSX_FRAMEWORK_BUNDLE_VERSION PYBINDIMATH_LIB_SUFFIX
MACOSX_FRAMEWORK_SHORT_VERSION_STRING ${Imath_VERSION})
endif()

0 comments on commit 802895e

Please sign in to comment.