mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-10-01 01:26:01 -04:00
abfebea4f2
CPack by default invokes the 'make install' target to install all project files into a staging area for further packaging. The order of installation follows the order of install() commands. One of the first install() commands is the one that installs the KeePassXC.app bundle and all the contents inside of it, which includes POST_BUILD copied binaries like keepassxc-cli and keepassxc-proxy. Subsequent install(TARGETS) commands would then override the keepassxc-cli and keepassxc-proxy binaries inside the staging area with the ones which didn't have macdeployqt run on them (the ones from src/cli and src/proxy). Launching the binaries would then fail because of missing rpath adjustments. The libkeepassxc-autotype-cocoa.so library was working fine because there is no install(TARGETS) command for it in a WITH_APP_BUNDLE build, so the POST_BUILD copy with the adjusted rpaths was preserved. To fix the issue and make the handling consistent, macdeployqt is no longer run at POST_BUILD time, but instead at 'make install' time, after each binary is installed by install(TARGETS). libkeepassxc-autotype-cocoa.so also has its install command run unconditionally now. The build dir binaries that are POST_BUILD copied into src/KeePassXC.app continue to run because they use the build dir rpaths that CMake embeds by default. They don't macdeployqt run for them anymore, which slightly speeds up the build time. Fixes: #7475
34 lines
1.2 KiB
CMake
34 lines
1.2 KiB
CMake
function(kpxc_run_macdeployqt_on_installed_helper_binary app_name installed_binary_relative_path)
|
|
# Running macdeployqt on a POST_BUILD copied binary is not useful for CPack, because
|
|
# the copied binary will be overriden by the corresponding install(TARGETS) command of the same
|
|
# binary.
|
|
# Thus, we run macdeployqt using install(CODE) on the already installed binary.
|
|
# The precondition is that install(TARGETS) has to be called before this function is called.
|
|
set(escaped_prefix "\${CMAKE_INSTALL_PREFIX}")
|
|
set(app_bundle_name "${app_name}.app")
|
|
set(app_bundle_path "${escaped_prefix}/${app_bundle_name}")
|
|
set(installed_binary_path "${escaped_prefix}/${installed_binary_relative_path}")
|
|
|
|
if(CMAKE_VERSION VERSION_GREATER "3.14")
|
|
set(command_echo "COMMAND_ECHO STDOUT")
|
|
else()
|
|
set(command_echo "")
|
|
endif()
|
|
|
|
install(CODE
|
|
"
|
|
execute_process(
|
|
COMMAND
|
|
${MACDEPLOYQT_EXE}
|
|
${app_bundle_path}
|
|
-executable=${installed_binary_path} -no-plugins 2> /dev/null
|
|
${command_echo}
|
|
RESULT_VARIABLE exit_code
|
|
)
|
|
if(NOT exit_code EQUAL 0)
|
|
message(FATAL_ERROR
|
|
\"Running macdeployqt on ${installed_binary_path} failed with exit code \${exit_code}.\")
|
|
endif()
|
|
")
|
|
endfunction()
|