mirror of
https://github.com/rizinorg/cutter.git
synced 2024-12-22 12:56:11 +00:00
4e0e0000e1
Crash dumps generated with breakpad were not made use of to an extent that would justify the extra maintenance overhead that it comes with. As Windows builds have recently been broken by it, now is a good time to retire it.
83 lines
3.4 KiB
CMake
83 lines
3.4 KiB
CMake
include(BundleUtilities)
|
|
|
|
set(MACDEPLOYQT_PATH "@MACDEPLOYQT_PATH@")
|
|
set(INFO_PLIST_PATH "@CPACK_BUNDLE_PLIST@")
|
|
set(ADJUST_RIZIN_LIBS "@ADJUST_RIZIN_LIBS@")
|
|
set(CUTTER_PACKAGE_DEPENDENCIES "@CUTTER_PACKAGE_DEPENDENCIES@")
|
|
set(CUTTER_ENABLE_PYTHON "@CUTTER_ENABLE_PYTHON@")
|
|
|
|
macro(run_or_die)
|
|
execute_process(${ARGV} RESULT_VARIABLE PROC_RESULT)
|
|
if(PROC_RESULT)
|
|
message(FATAL_ERROR "Failed to run ${ARGV}")
|
|
endif()
|
|
endmacro()
|
|
|
|
get_filename_component(BUNDLE_PATH "${CMAKE_INSTALL_PREFIX}/../.." ABSOLUTE)
|
|
set(EXECUTABLE_DIR "${BUNDLE_PATH}/Contents/MacOS")
|
|
set(FRAMEWORK_DIR "${BUNDLE_PATH}/Contents/Frameworks")
|
|
|
|
# Copying the Info.plist will be done later again by CPack but we need it a bit earlier
|
|
# so macdeployqt has enough info.
|
|
file(COPY "${INFO_PLIST_PATH}" DESTINATION "${BUNDLE_PATH}/Contents")
|
|
|
|
# replace absolute path from build directory in rizin pkgconfig files with relative ones
|
|
file(GLOB RZ_PCFILES "${CMAKE_INSTALL_PREFIX}/lib/pkgconfig/rz_*.pc")
|
|
foreach (_pcfile ${RZ_PCFILES})
|
|
file(READ "${_pcfile}" _text)
|
|
string(REGEX REPLACE "^prefix=[^\n]*\n" "prefix=\${pcfiledir}/../..\n" _text "${_text}")
|
|
file(WRITE "${_pcfile}" "${_text}")
|
|
endforeach()
|
|
# macdeployqt would put the rz libraries into Contents/Frameworks by default, but we want to have them
|
|
# only in the prefix, so we fix the paths manually.
|
|
foreach(_lib ${ADJUST_RIZIN_LIBS})
|
|
get_filename_component(_lib "${_lib}" REALPATH)
|
|
get_filename_component(_name "${_lib}" NAME)
|
|
# Cutter reference to lib
|
|
run_or_die(COMMAND install_name_tool
|
|
-change "${_lib}" "@rpath/${_name}"
|
|
"${EXECUTABLE_DIR}/cutter")
|
|
# lib LC_ID_DYLIB
|
|
run_or_die(COMMAND install_name_tool
|
|
-id "@rpath/${_name}"
|
|
"${CMAKE_INSTALL_PREFIX}/lib/${_name}")
|
|
# Fix every lib for every lib too
|
|
foreach(_lib2 ${ADJUST_RIZIN_LIBS})
|
|
get_filename_component(_lib2 "${_lib2}" REALPATH)
|
|
get_filename_component(_name2 "${_lib2}" NAME)
|
|
run_or_die(COMMAND install_name_tool
|
|
-change "${_lib2}" "@rpath/${_name2}"
|
|
"${CMAKE_INSTALL_PREFIX}/lib/${_name}")
|
|
endforeach()
|
|
endforeach()
|
|
|
|
# Add rpaths because macdeployqt fails to do that properly
|
|
run_or_die(COMMAND install_name_tool
|
|
-add_rpath "@executable_path/../Frameworks"
|
|
"${EXECUTABLE_DIR}/cutter")
|
|
run_or_die(COMMAND install_name_tool
|
|
-add_rpath "@executable_path/../Resources/lib"
|
|
"${EXECUTABLE_DIR}/cutter")
|
|
run_or_die(COMMAND install_name_tool
|
|
-add_rpath "@executable_path/../Resources/lib/rizin/plugins"
|
|
"${EXECUTABLE_DIR}/cutter")
|
|
|
|
set(MACDEPLOYQT_COMMAND "${MACDEPLOYQT_PATH}" "${BUNDLE_PATH}" "-verbose=2" "-libpath=${CMAKE_INSTALL_PREFIX}/lib")
|
|
message("Running macdeployqt \"${MACDEPLOYQT_COMMAND}\"")
|
|
run_or_die(COMMAND ${MACDEPLOYQT_COMMAND}) # First run
|
|
if (CUTTER_PACKAGE_DEPENDENCIES AND CUTTER_ENABLE_PYTHON)
|
|
file(REAL_PATH "${FRAMEWORK_DIR}/Python.framework/Python" _python_lib_path)
|
|
message("Python lib ${_python_lib_path}")
|
|
list(APPEND MACDEPLOYQT_COMMAND "-executable=${_python_lib_path}")
|
|
endif()
|
|
# Qt plugins are not getting deployed on first macdeployqt run. Runing twice helps.
|
|
# If python is added as additional executable in first run it also breaks plugin copying.
|
|
run_or_die(COMMAND ${MACDEPLOYQT_COMMAND}) # Second run
|
|
|
|
# Clean up the mess that macdeployqt made (duplicate rz libs, we only want the ones in the prefix)
|
|
foreach(_lib ${ADJUST_RIZIN_LIBS})
|
|
get_filename_component(_lib "${_lib}" REALPATH)
|
|
get_filename_component(_name "${_lib}" NAME)
|
|
file(REMOVE "${BUNDLE_PATH}/Contents/Frameworks/${_name}")
|
|
endforeach()
|