From 6a76fb5746818f8ca3617ebe63e2cf0116082bc5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Hrdli=C4=8Dka?= Date: Fri, 17 Dec 2021 07:19:12 +0100 Subject: [PATCH] Move Mac related stuff from the main build file --- src/CMakeLists.txt | 49 +++----------------------------------- src/mac/CMakeLists.txt | 54 ++++++++++++++++++++++++++++++++++++++++-- src/mac/Info.plist.in | 16 ++++++------- 3 files changed, 63 insertions(+), 56 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b6c934306..3fb0c229f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -15,37 +15,15 @@ # Copyright 2021 dob205. # -# Prepare the macOS app bundle icon depending on the release channel -set(APP_ICON_MACOSX) -if (APPLE) - if(RELEASE_BUILD) - set(APP_ICON_MACOSX ${CMAKE_CURRENT_SOURCE_DIR}/mac/icons/release/86Box.icns) - elseif(BETA_BUILD) - set(APP_ICON_MACOSX ${CMAKE_CURRENT_SOURCE_DIR}/mac/icons/beta/86Box.icns) - elseif(ALPHA_BUILD) - set(APP_ICON_MACOSX ${CMAKE_CURRENT_SOURCE_DIR}/mac/icons/dev/86Box.icns) - else() - set(APP_ICON_MACOSX ${CMAKE_CURRENT_SOURCE_DIR}/mac/icons/branch/86Box.icns) - endif() - -set_source_files_properties(${APP_ICON_MACOSX} PROPERTIES - MACOSX_PACKAGE_LOCATION "Resources") -endif() - # WIN32 marks us as a GUI app on Windows -# MACOSX_BUNDLE prepares a macOS application bundle including with the app icon add_executable(86Box WIN32 MACOSX_BUNDLE 86box.c config.c log.c random.c timer.c io.c acpi.c apm.c dma.c ddma.c nmi.c pic.c pit.c port_6x.c port_92.c ppi.c pci.c mca.c usb.c fifo8.c - device.c nvr.c nvr_at.c nvr_ps2.c ${APP_ICON_MACOSX}) + device.c nvr.c nvr_at.c nvr_ps2.c) if(CPPTHREADS) target_sources(86Box PRIVATE thread.cpp) endif() -if(APPLE) - target_link_libraries(86Box "-framework AppKit") -endif() - if(NEW_DYNAREC) add_compile_definitions(USE_NEW_DYNAREC) endif() @@ -107,30 +85,8 @@ if(APPLE) # Force using the newest library if it's installed by homebrew set(CMAKE_FIND_FRAMEWORK LAST) - - # prepare stuff for macOS app bundles - set(CMAKE_MACOSX_BUNDLE 1) - # setting our compilation target to macOS 10.13 High Sierra set(CMAKE_OSX_DEPLOYMENT_TARGET "10.13") - - # set the Info.plist properly - set_target_properties(86Box PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/mac/Info.plist.in) - set(MACOSX_BUNDLE_GUI_IDENTIFIER net.86Box.86Box) - set(MACOSX_BUNDLE_BUNDLE_NAME 86Box) - set(MACOSX_BUNDLE_BUNDLE_VERSION 3.1.${EMU_BUILD_NUM}) - set(MACOSX_BUNDLE_SHORT_VERSION_STRING "3.1.${EMU_BUILD_NUM}") - set(MACOSX_BUNDLE_LONG_VERSION_STRING "3.1.${EMU_BUILD_NUM}") - set(MACOSX_BUNDLE_ICON_FILE 86Box.icns) - set(MACOSX_BUNDLE_INFO_STRING "A emulator of old computers") - set(MACOSX_BUNDLE_COPYRIGHT "© 2007-${EMU_COPYRIGHT_YEAR} 86Box contributors") - - - # preparing the code signing for easier distribution, Apple dev certificate needed at one point - #set(XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "YES") - #set(XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "-") - #set(XCODE_ATTRIBUTE_CODE_SIGN_ENTITLEMENTS ${CMAKE_CURRENT_SOURCE_DIR}/mac/codesign/dev/app.entitlements) - endif() find_package(Freetype REQUIRED) @@ -213,7 +169,8 @@ if(APPLE) set(APPS ${CMAKE_CURRENT_BINARY_DIR}/86Box.app) install(CODE " include(BundleUtilities) - fixup_bundle(\"${APPS}\" \"\" \"\")" + get_filename_component(CMAKE_INSTALL_PREFIX_ABSOLUTE \${CMAKE_INSTALL_PREFIX} ABSOLUTE) + fixup_bundle(\"\${CMAKE_INSTALL_PREFIX_ABSOLUTE}/bin/86Box.app\" \"\" \"\")" COMPONENT Runtime) endif() diff --git a/src/mac/CMakeLists.txt b/src/mac/CMakeLists.txt index 1bfd8c11e..ac5cc2114 100644 --- a/src/mac/CMakeLists.txt +++ b/src/mac/CMakeLists.txt @@ -1,3 +1,53 @@ -include_directories("./mac") -target_sources(86Box PUBLIC "./macOSXGlue.m") +# +# 86Box A hypervisor and IBM PC system emulator that specializes in +# running old operating systems and software designed for IBM +# PC systems and compatibles from 1981 through fairly recent +# system designs based on the PCI bus. +# +# This file is part of the 86Box distribution. +# +# CMake build script. +# +# Authors: dob205, +# Jerome Vernet +# David Hrdlička, +# +# Copyright 2021 dob205. +# Copyright 2021 Jerome Vernet. +# Copyright 2021 David Hrdlička. +# +# Pick the bundle icon depending on the release channel +if(RELEASE_BUILD) + set(APP_ICON_MACOSX icons/release/86Box.icns) +elseif(BETA_BUILD) + set(APP_ICON_MACOSX icons/beta/86Box.icns) +elseif(ALPHA_BUILD) + set(APP_ICON_MACOSX icons/dev/86Box.icns) +else() + set(APP_ICON_MACOSX icons/branch/86Box.icns) +endif() + +target_link_libraries(86Box "-framework AppKit") +target_sources(86Box PRIVATE macOSXGlue.m ${APP_ICON_MACOSX}) + +# Make sure the icon is copied to the bundle +set_source_files_properties(${APP_ICON_MACOSX} + TARGET_DIRECTORY 86Box + PROPERTIES MACOSX_PACKAGE_LOCATION "Resources") + +# Prepare long version string +if(EMU_BUILD) + set(LONG_VER_STRING "${CMAKE_PROJECT_VERSION} [${EMU_BUILD}]") +else() + set(LONG_VER_STRING "${CMAKE_PROJECT_VERSION}") +endif() + +# Generate Info.plist +configure_file(Info.plist.in Info.plist @ONLY) +set_target_properties(86Box + PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_BINARY_DIR}/Info.plist) + +#set(XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "YES") +#set(XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "-") +#set(XCODE_ATTRIBUTE_CODE_SIGN_ENTITLEMENTS ${CMAKE_CURRENT_SOURCE_DIR}/mac/codesign/dev/app.entitlements) \ No newline at end of file diff --git a/src/mac/Info.plist.in b/src/mac/Info.plist.in index e06b17ecf..2f2080460 100644 --- a/src/mac/Info.plist.in +++ b/src/mac/Info.plist.in @@ -7,29 +7,29 @@ CFBundleExecutable ${MACOSX_BUNDLE_EXECUTABLE_NAME} CFBundleGetInfoString - ${MACOSX_BUNDLE_INFO_STRING} + An emulator of old computers CFBundleIconFile - ${MACOSX_BUNDLE_ICON_FILE} + 86Box.icns CFBundleIdentifier - ${MACOSX_BUNDLE_GUI_IDENTIFIER} + net.86Box.86Box CFBundleInfoDictionaryVersion 6.0 CFBundleLongVersionString - ${MACOSX_BUNDLE_LONG_VERSION_STRING} + @LONG_VER_STRING@ CFBundleName - ${MACOSX_BUNDLE_BUNDLE_NAME} + 86Box CFBundlePackageType APPL CFBundleShortVersionString - ${MACOSX_BUNDLE_SHORT_VERSION_STRING} + @CMAKE_PROJECT_VERSION@ CFBundleSignature ???? CFBundleVersion - ${MACOSX_BUNDLE_BUNDLE_VERSION} + @CMAKE_PROJECT_VERSION_MAJOR@.@CMAKE_PROJECT_VERSION_MINOR@.@CMAKE_PROJECT_VERSION_PATCH@.@EMU_BUILD_NUM@ CSResourcesFileMapped NSHumanReadableCopyright - ${MACOSX_BUNDLE_COPYRIGHT} + © 2007-@EMU_COPYRIGHT_YEAR@ 86Box contributors NSPrincipalClass NSApplication NSHighResolutionCapable