Skip to content

Commit

Permalink
Add support for Apple framework builds (#653)
Browse files Browse the repository at this point in the history
Add CMake option PUGIXML_BUILD_APPLE_FRAMEWORKS to build PugiXML as Apple Frameworks.

This is needed to be able to create iOS-derived compatible app bundles which need to embed PugiXML as framework, as using dylibs is prohibited by Apple.
  • Loading branch information
Treata11 authored Jan 2, 2025
1 parent 4bc1441 commit 06318b0
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ option(PUGIXML_NO_STL "Disable STL" OFF)
option(PUGIXML_NO_EXCEPTIONS "Disable Exceptions" OFF)
mark_as_advanced(PUGIXML_NO_XPATH PUGIXML_NO_STL PUGIXML_NO_EXCEPTIONS)

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

set(PUGIXML_PUBLIC_DEFINITIONS
$<$<BOOL:${PUGIXML_WCHAR_MODE}>:PUGIXML_WCHAR_MODE>
$<$<BOOL:${PUGIXML_COMPACT}>:PUGIXML_COMPACT>
Expand Down Expand Up @@ -174,6 +178,16 @@ set_target_properties(${libs}
EXCLUDE_FROM_ALL OFF)
set(install-targets pugixml ${libs})

if (PUGIXML_BUILD_APPLE_FRAMEWORK)
set_target_properties(${libs} PROPERTIES
FRAMEWORK TRUE
FRAMEWORK_VERSION ${PROJECT_VERSION}
XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER com.zeux.pugixml
MACOSX_FRAMEWORK_IDENTIFIER com.zeux.pugixml
MACOSX_FRAMEWORK_BUNDLE_VERSION ${PROJECT_VERSION}
MACOSX_FRAMEWORK_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR})
endif()

configure_package_config_file(
"${PROJECT_SOURCE_DIR}/scripts/pugixml-config.cmake.in"
"${PROJECT_BINARY_DIR}/pugixml-config.cmake"
Expand Down Expand Up @@ -234,7 +248,8 @@ if(PUGIXML_INSTALL)
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT ${PUGIXML_RUNTIME_COMPONENT}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT ${PUGIXML_LIBRARY_COMPONENT} ${namelink-component}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT ${PUGIXML_DEVELOPMENT_COMPONENT}
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}${versioned-dir})
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}${versioned-dir}
FRAMEWORK DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT runtime OPTIONAL)

install(EXPORT pugixml-targets
NAMESPACE pugixml::
Expand Down

0 comments on commit 06318b0

Please sign in to comment.