From 06318b084a0c1043516acbdae39fdf617fee474c Mon Sep 17 00:00:00 2001 From: Treata Date: Thu, 2 Jan 2025 22:41:51 +0330 Subject: [PATCH] Add support for Apple framework builds (#653) 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. --- CMakeLists.txt | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5f023180..174784d6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 $<$:PUGIXML_WCHAR_MODE> $<$:PUGIXML_COMPACT> @@ -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" @@ -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::