Medical Imaging Interaction Toolkit  2018.4.99-389bf124
Medical Imaging Interaction Toolkit
FixMacOSInstaller.cmake
Go to the documentation of this file.
1 set(bundle_path "${CMAKE_INSTALL_PREFIX}/${_bundle_dest_dir}/../..")
2 get_filename_component(bundle_path ${bundle_path} REALPATH)
3 
4 #############################
5 # (1) Fix Qt-related issues #
6 #############################
7 
8 # Compile list of Qt frameworks in bundle
9 unset(qt_frameworks)
10 file(GLOB qt_framework_paths "${bundle_path}/Contents/Frameworks/Qt*.framework")
11 foreach(qt_framework_path ${qt_framework_paths})
12  get_filename_component(qt_framework ${qt_framework_path} NAME_WE)
13  list(APPEND qt_frameworks ${qt_framework})
14 endforeach()
15 
16 # For each Qt framework, change the style of dependencies to other
17 # Qt frameworks from @executable_path to @rpath. The install name tool
18 # only changes existing dependencies.
19 foreach(qt_framework ${qt_frameworks})
20  set(in "${bundle_path}/Contents/Frameworks/${qt_framework}.framework/Versions/5/${qt_framework}")
21  foreach(other_qt_framework ${qt_frameworks})
22  set(from "@executable_path/../Frameworks/${other_qt_framework}.framework/Versions/5/${other_qt_framework}")
23  set(to "@rpath/${other_qt_framework}.framework/Versions/5/${other_qt_framework}")
24  execute_process(COMMAND install_name_tool -change ${from} ${to} ${in})
25  endforeach()
26 endforeach()
27 
28 # Do the same for QtWebEngineProcess
29 set(qtwebengineprocess_path "${bundle_path}/Contents/Frameworks/QtWebEngineCore.framework/Helpers/QtWebEngineProcess.app/Contents/MacOS/QtWebEngineProcess")
30 foreach(qt_framework ${qt_frameworks})
31  set(from "@executable_path/../Frameworks/${qt_framework}.framework/Versions/5/${qt_framework}")
32  set(to "@rpath/${qt_framework}.framework/Versions/5/${qt_framework}")
33  execute_process(COMMAND install_name_tool -change ${from} ${to} ${qtwebengineprocess_path})
34 endforeach()
35 
36 # Add corresponding rpath entries to the actual application and QtWebEngineProcess.
37 # The install name tool returns an error if an entry is already present.
38 get_filename_component(app ${bundle_path} NAME_WE)
39 set(app_path "${bundle_path}/Contents/MacOS/${app}")
40 execute_process(COMMAND install_name_tool -add_rpath "@executable_path/../Frameworks" ${app_path} ERROR_QUIET)
41 execute_process(COMMAND install_name_tool -add_rpath "@executable_path/../../../../.." ${qtwebengineprocess_path} ERROR_QUIET)
static bool in(Reader::Char c, Reader::Char c1, Reader::Char c2, Reader::Char c3, Reader::Char c4)
Definition: jsoncpp.cpp:244