Allow bundling libraries on macOS (#1013)

This commit is contained in:
WaluigiWare64 2021-03-21 15:32:23 +00:00 committed by GitHub
parent f7347b1f7a
commit 6b431a6664
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 10 deletions

View File

@ -97,6 +97,7 @@ If everything went well, melonDS should now be in the `dist` folder.
```
4. Compile:
```zsh
export PKG_CONFIG_PATH="$(brew --prefix libarchive)/lib/pkgconfig"
cmake .. -DQt5_DIR=$(brew --prefix qt5)/lib/cmake/Qt5
make -j$(sysctl -n hw.ncpu)
mkdir dist && cp -r melonDS.app dist

View File

@ -54,14 +54,6 @@ find_package(PkgConfig REQUIRED)
find_package(Iconv REQUIRED)
pkg_check_modules(SDL2 REQUIRED sdl2)
pkg_check_modules(SLIRP REQUIRED slirp)
if (APPLE)
# Find libarchive on macOS, because macOS only provides the library, not the headers
execute_process(COMMAND brew --prefix libarchive
OUTPUT_VARIABLE LIBARCHIVE_DIR
OUTPUT_STRIP_TRAILING_WHITESPACE)
list(APPEND CMAKE_PREFIX_PATH "${LIBARCHIVE_DIR}")
endif()
pkg_check_modules(LIBARCHIVE REQUIRED libarchive)
add_compile_definitions(ARCHIVE_SUPPORT_ENABLED)
@ -74,7 +66,11 @@ endif()
target_link_libraries(melonDS ${CMAKE_THREAD_LIBS_INIT})
target_include_directories(melonDS PRIVATE ${SDL2_INCLUDE_DIRS} ${SLIRP_INCLUDE_DIRS} ${LIBARCHIVE_INCLUDE_DIRS})
target_link_directories(melonDS PRIVATE ${SDL2_LIBRARY_DIRS} ${SLIRP_LIBRARY_DIRS} ${LIBARCHIVE_LIBRARY_DIRS})
target_link_directories(melonDS PRIVATE ${SDL2_LIBRARY_DIRS} ${SLIRP_LIBRARY_DIRS})
if (NOT APPLE)
target_link_directories(melonDS PRIVATE ${LIBARCHIVE_LIBRARY_DIRS})
endif()
target_include_directories(melonDS PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}")
target_include_directories(melonDS PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/..")
target_include_directories(melonDS PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/../..")
@ -87,7 +83,7 @@ else()
endif()
if (NOT Iconv_IS_BUILT_IN)
target_link_libraries(melonDS iconv)
target_link_libraries(melonDS ${Iconv_LIBRARIES})
endif()
if (UNIX)
@ -124,6 +120,18 @@ if (APPLE)
target_sources(melonDS PRIVATE "${CMAKE_SOURCE_DIR}/melon.icns")
set_source_files_properties("${CMAKE_SOURCE_DIR}/melon.icns" PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
option(MACOS_BUNDLE_LIBS "Bundle libraries with the app on macOS" OFF)
if (MACOS_BUNDLE_LIBS)
# Copy Qt plugins into the bundle
get_target_property(qtcocoa_location Qt5::QCocoaIntegrationPlugin LOCATION)
target_sources(melonDS PRIVATE "${qtcocoa_location}")
set_source_files_properties("${qtcocoa_location}" PROPERTIES MACOSX_PACKAGE_LOCATION MacOS/platforms)
get_target_property(qtmacstyle_location Qt5::QMacStylePlugin LOCATION)
target_sources(melonDS PRIVATE "${qtmacstyle_location}")
set_source_files_properties("${qtmacstyle_location}" PROPERTIES MACOSX_PACKAGE_LOCATION MacOS/styles)
endif()
endif()
install(FILES ../../../net.kuribo64.melonDS.desktop DESTINATION ${CMAKE_INSTALL_PREFIX}/share/applications)