CMake: Bring up DMG distribution on macOS

This commit is contained in:
Vicki Pfau 2021-08-20 18:59:30 -07:00
parent e107d90772
commit 96e1ae4272
3 changed files with 24 additions and 5 deletions

View File

@ -119,6 +119,10 @@ else()
set(CMAKE_INSTALL_INCLUDEDIR "include")
endif()
if(APPLE AND DISTBUILD)
set(CMAKE_INSTALL_DOCDIR ".")
endif()
if(NOT DEFINED LIBDIR)
set(LIBDIR "${CMAKE_INSTALL_LIBDIR}")
endif()
@ -1064,6 +1068,9 @@ endif()
if(DISTBUILD)
set(CPACK_ARCHIVE_COMPONENT_INSTALL ON)
set(CPACK_DMG_FILESYSTEM "HFS+")
set(CPACK_DMG_FORMAT "UDBZ")
set(CPACK_DMG_VOLUME_NAME "${PROJECT_NAME} ${VERSION_STRING}")
if(CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo" AND BUILD_SHARED)
if(NOT APPLE)
add_custom_command(TARGET ${BINARY_NAME} POST_BUILD COMMAND "${OBJCOPY}" --only-keep-debug "$<TARGET_FILE:${BINARY_NAME}>" "$<TARGET_FILE:${BINARY_NAME}>.debug")
@ -1074,7 +1081,8 @@ if(DISTBUILD)
endif()
if(APPLE)
set(CPACK_COMPONENTS_ALL ${BINARY_NAME} ${BINARY_NAME}-qt ${BINARY_NAME}-sdl ${BINARY_NAME}-qt-dbg ${BINARY_NAME}-sdl-dbg ${BINARY_NAME}-perf)
set(CPACK_COMPONENTS_GROUPING ALL_COMPONENTS_IN_ONE)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/platform/cmake/DMGOverrides.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/DMGOverrides.cmake @ONLY)
set(CPACK_PROJECT_CONFIG_FILE ${CMAKE_CURRENT_BINARY_DIR}/DMGOverrides.cmake)
elseif(WIN32)
set(CPACK_COMPONENTS_ALL ${BINARY_NAME} ${BINARY_NAME}-qt ${BINARY_NAME}-sdl ${BINARY_NAME}-qt-dbg ${BINARY_NAME}-sdl-dbg ${BINARY_NAME}-perf installer)
elseif(3DS)

View File

@ -0,0 +1,6 @@
message(FATAL ${CPACK_GENERATOR})
if(CPACK_GENERATOR STREQUAL "DragNDrop")
set(CPACK_COMPONENTS_ALL @BINARY_NAME@ @BINARY_NAME@-qt @BINARY_NAME@-qt-dbg)
set(CPACK_COMPONENTS_GROUPING ALL_COMPONENTS_IN_ONE)
unset(CPACK_RESOURCE_FILE_LICENSE)
endif()

View File

@ -241,6 +241,11 @@ if(APPLE)
set(MACOSX_BUNDLE_BUNDLE_NAME ${PROJECT_NAME})
set(MACOSX_BUNDLE_GUI_IDENTIFIER com.endrift.${BINARY_NAME}-qt)
set_source_files_properties(${CMAKE_SOURCE_DIR}/res/mgba.icns PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
if(DISTBUILD)
set(APPDIR ".")
else()
set(APPDIR "Applications")
endif()
endif()
if(WIN32)
configure_file(${CMAKE_SOURCE_DIR}/res/mgba.rc.in ${CMAKE_BINARY_DIR}/res/mgba.rc)
@ -249,7 +254,7 @@ if(WIN32)
endif()
if(NOT DEFINED DATADIR)
if(APPLE)
set(DATADIR Applications/${PROJECT_NAME}.app/Contents/Resources)
set(DATADIR ${APPDIR}/${PROJECT_NAME}.app/Contents/Resources)
elseif(WIN32 AND NOT WIN32_UNIX_PATHS)
set(DATADIR ".")
else()
@ -336,11 +341,11 @@ set(CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS}" PARENT_SCOPE)
install(TARGETS ${BINARY_NAME}-qt
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT ${BINARY_NAME}-qt
BUNDLE DESTINATION Applications COMPONENT ${BINARY_NAME}-qt)
BUNDLE DESTINATION ${APPDIR} COMPONENT ${BINARY_NAME}-qt)
if(UNIX AND NOT APPLE)
install(FILES ${CMAKE_SOURCE_DIR}/res/mgba-qt.desktop DESTINATION share/applications COMPONENT ${BINARY_NAME}-qt)
endif()
if(UNIX)
if(UNIX AND NOT (APPLE AND DISTBUILD))
install(FILES ${CMAKE_SOURCE_DIR}/doc/mgba-qt.6 DESTINATION ${MANDIR}/man6 COMPONENT ${BINARY_NAME}-qt)
endif()
if(APPLE OR WIN32)
@ -373,7 +378,7 @@ if(APPLE)
if(DEFINED CROSS_ROOT)
set(DEPLOY_OPTIONS ${DEPLOY_OPTIONS} -R "${CROSS_ROOT}")
endif()
install(CODE "execute_process(COMMAND \"${CMAKE_SOURCE_DIR}/tools/deploy-mac.py\" -v ${DEPLOY_OPTIONS} \"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/Applications/${PROJECT_NAME}.app\")")
install(CODE "execute_process(COMMAND \"${CMAKE_SOURCE_DIR}/tools/deploy-mac.py\" -v ${DEPLOY_OPTIONS} \"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${APPDIR}/${PROJECT_NAME}.app\")")
endif()
elseif(WIN32)
if(CMAKE_MAJOR_VERSION EQUAL 3 AND CMAKE_MINOR_VERSION EQUAL 8)