From 883b4c4be9c7e97fa0bbeccded30e5b44e24a397 Mon Sep 17 00:00:00 2001 From: cold-brewed <47337035+cold-brewed@users.noreply.github.com> Date: Fri, 9 Jun 2023 10:37:05 -0400 Subject: [PATCH] macos: Update library bundling process, add vde to bundle (#3390) Co-authored-by: cold-brewed --- src/network/CMakeLists.txt | 9 ++++++-- src/qt/CMakeLists.txt | 42 ++++++++++++++++---------------------- 2 files changed, 25 insertions(+), 26 deletions(-) diff --git a/src/network/CMakeLists.txt b/src/network/CMakeLists.txt index 94e066a19..54ec1edce 100644 --- a/src/network/CMakeLists.txt +++ b/src/network/CMakeLists.txt @@ -43,8 +43,13 @@ endif() if (UNIX) find_path(HAS_VDE "libvdeplug.h" PATHS ${VDE_INCLUDE_DIR} "/usr/include /usr/local/include" "/opt/homebrew/include" ) if(HAS_VDE) - add_compile_definitions(HAS_VDE) - list(APPEND net_sources net_vde.c) + find_library(VDE_LIB vdeplug) + if (NOT VDE_LIB) + message(WARNING "Could not find VDE. The library will not be bundled and any related features will be disabled.") + else() + add_compile_definitions(HAS_VDE) + list(APPEND net_sources net_vde.c) + endif() endif() endif() diff --git a/src/qt/CMakeLists.txt b/src/qt/CMakeLists.txt index d9c729d00..23e2c748e 100644 --- a/src/qt/CMakeLists.txt +++ b/src/qt/CMakeLists.txt @@ -239,7 +239,6 @@ if (APPLE) if (NOT MOLTENVK_LIB) message(FATAL_ERROR "Could not find MoltenVK library") endif() - target_link_libraries(ui PRIVATE "${MOLTENVK_LIB}") endif() endif() @@ -313,6 +312,20 @@ macro(install_qt5_plugin _qt_plugin_name _runtime_plugins_var _prefix) endif() endmacro() +macro(install_bundle_library _library_path _installed_name _runtime_plugins_var _prefix) + if(EXISTS "${_library_path}") + file(REAL_PATH "${_library_path}" _lib_resolved) + if(EXISTS "${_lib_resolved}") + install(FILES "${_lib_resolved}" DESTINATION "${_prefix}" RENAME "${_installed_name}") + list(APPEND ${_runtime_plugins_var} "\${CMAKE_INSTALL_PREFIX_ABSOLUTE}/${_prefix}/${_installed_name}") + else() + message(WARNING "Library ${_installed_name} will not be bundled: The library was found but could not be resolved.") + endif() + else() + message(STATUS "Library ${_installed_name} was not found - skipping") + endif() +endmacro() + if (APPLE AND CMAKE_MACOSX_BUNDLE) set(prefix "86Box.app/Contents") set(INSTALL_RUNTIME_DIR "${prefix}/MacOS") @@ -326,19 +339,10 @@ if (APPLE AND CMAKE_MACOSX_BUNDLE) install_qt5_plugin("Qt${QT_MAJOR}::QICNSPlugin" RUNTIME_PLUGINS ${prefix}) # Install libraries that are loaded at runtime and not linked - if (GHOSTSCRIPT_LIB) - set(GS_LIBRARY_NAME "libgs.dylib") - file(REAL_PATH ${GHOSTSCRIPT_LIB} GS_LIB_RESOLVED) - install(FILES ${GS_LIB_RESOLVED} DESTINATION ${INSTALL_LIB_DIR} RENAME ${GS_LIBRARY_NAME}) - list(APPEND RUNTIME_PLUGINS "\${CMAKE_INSTALL_PREFIX_ABSOLUTE}/${INSTALL_LIB_DIR}/${GS_LIBRARY_NAME}") - endif () - - if (FLUIDSYNTH_LIB) - set(FLUIDSYNTH_LIBRARY_NAME "libfluidsynth.dylib") - file(REAL_PATH ${FLUIDSYNTH_LIB} FLUIDSYNTH_LIB_RESOLVED) - install(FILES ${FLUIDSYNTH_LIB_RESOLVED} DESTINATION ${INSTALL_LIB_DIR} RENAME ${FLUIDSYNTH_LIBRARY_NAME}) - list(APPEND RUNTIME_PLUGINS "\${CMAKE_INSTALL_PREFIX_ABSOLUTE}/${INSTALL_LIB_DIR}/${FLUIDSYNTH_LIBRARY_NAME}") - endif () + install_bundle_library("${GHOSTSCRIPT_LIB}" "libgs.dylib" RUNTIME_PLUGINS ${INSTALL_LIB_DIR}) + install_bundle_library("${FLUIDSYNTH_LIB}" "libfluidsynth.dylib" RUNTIME_PLUGINS ${INSTALL_LIB_DIR}) + install_bundle_library("${VDE_LIB}" "libvdeplug.dylib" RUNTIME_PLUGINS ${INSTALL_LIB_DIR}) + install_bundle_library("${MOLTENVK_LIB}" "libVulkan.dylib" RUNTIME_PLUGINS ${INSTALL_LIB_DIR}) file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/qt.conf" "[Paths]\nPlugins = PlugIns\n") @@ -365,16 +369,6 @@ if (APPLE AND CMAKE_MACOSX_BUNDLE) COMMAND ${CMAKE_INSTALL_NAME_TOOL} -add_rpath \"@executable_path/../Frameworks/\" \"\${CMAKE_INSTALL_PREFIX_ABSOLUTE}/${INSTALL_RUNTIME_DIR}/86Box\") ") - if(MOLTENVK) - install(CODE " - execute_process( - COMMAND bash -c \"set -e - echo \\\"-- Creating vulkan dylib symlink for QT (libVulkan.dylib -> libMoltenVK.dylib)\\\" - cd \${CMAKE_INSTALL_PREFIX_ABSOLUTE}/${INSTALL_LIB_DIR} - ln -sf libMoltenVK.dylib libVulkan.dylib - \") - ") - endif() endif() if (UNIX AND NOT APPLE AND NOT HAIKU)