cmb.bundle.apple.cmake 6.83 KB
Newer Older
Ben Boeckel's avatar
Ben Boeckel committed
1
foreach(program IN LISTS cmb_programs_to_install)
2
  set(additional_libraries)
3
  set(plugins)
4
  set(plugin_paths)
5

6
7
8
9
  # Install additional libraries in the app
  foreach(library IN LISTS cmb_additional_libraries)
    list(APPEND additional_libraries "${superbuild_install_location}/lib/lib${library}.dylib")
  endforeach()
10

11
12
13
14
15
  # Gather the list of plugins for this program
  if (EXISTS "${superbuild_install_location}/Applications/${program}.app/Contents/Resources/${program}.conf")
    file(READ "${superbuild_install_location}/Applications/${program}.app/Contents/Resources/${program}.conf" conf_contents)
    string(REGEX REPLACE "[^\n]*/" "../Plugins/" pkg_conf_contents "${conf_contents}")
    file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/${program}.conf" "${pkg_conf_contents}")
16

17
18
19
20
21
22
23
24
    string(REPLACE "\n" ";" app_plugin_files "${conf_contents}")
    set(app_plugin_filenames)
    foreach (conf_line IN LISTS app_plugin_files)
      if (NOT conf_line)
        continue ()
      endif ()
      get_filename_component(plugin_filename "${conf_line}" NAME)
      list(APPEND app_plugin_filenames "${plugin_filename}")
25
    endforeach ()
26

27
28
29
30
31
32
    foreach (plugin_file IN LISTS all_plugin_files)
      # Check if the plugin file is recognized by the app.
      get_filename_component(plugin_file_name "${plugin_file}" NAME)
      if (NOT plugin_file_name IN_LIST app_plugin_filenames)
        continue ()
      endif ()
33

34
35
36
37
38
39
      # Get a list of plugins from this plugin file that need to be installed.
      get_filename_component(plugin_file_dir "${plugin_file}" DIRECTORY)
      foreach (plugin IN LISTS "plugins_${plugin_file}")
        list(APPEND plugin_paths "${superbuild_install_location}/${plugin_file_dir}/${plugin}/${plugin}.so")
        list(APPEND plugins "${plugin}")
      endforeach ()
40
    endforeach ()
41
  endif ()
42

Ben Boeckel's avatar
Ben Boeckel committed
43
  superbuild_apple_create_app(
44
    "\${CMAKE_INSTALL_PREFIX}"
Ben Boeckel's avatar
Ben Boeckel committed
45
46
47
    "${program}.app"
    "${superbuild_install_location}/Applications/${program}.app/Contents/MacOS/${program}"
    CLEAN
48
    PLUGINS ${plugin_paths}
49
    ADDITIONAL_LIBRARIES ${additional_libraries}
Ben Boeckel's avatar
Ben Boeckel committed
50
51
    SEARCH_DIRECTORIES
            "${superbuild_install_location}/lib")
52
  foreach (icon_filename MacIcon.icns pvIcon.icns modelbuilder.icns aeva.icns)
53
54
55
56
    set(icon_path "${superbuild_install_location}/Applications/${program}.app/Contents/Resources/${icon_filename}")
    if (EXISTS "${icon_path}")
      install(
        FILES       "${icon_path}"
57
        DESTINATION "${program}.app/Contents/Resources"
58
59
        COMPONENT   superbuild)
    endif ()
Ben Boeckel's avatar
Ben Boeckel committed
60
  endforeach ()
61
62
  install(
    FILES       "${superbuild_install_location}/Applications/${program}.app/Contents/Info.plist"
63
    DESTINATION "${program}.app/Contents"
64
    COMPONENT   superbuild)
Ben Boeckel's avatar
Ben Boeckel committed
65

66
67
  install(
    FILES       "${CMAKE_CURRENT_BINARY_DIR}/${program}.conf"
68
    DESTINATION "${program}.app/Contents/Resources/"
69
70
71
72
73
74
75
76
77
78
    COMPONENT   superbuild)
  foreach (app_plugin_file IN LISTS app_plugin_files)
    if (NOT app_plugin_file)
      continue ()
    endif ()
    if (IS_ABSOLUTE "${app_plugin_file}")
      set(plugin_source_path "${app_plugin_file}")
    else ()
      set(plugin_source_path "${superbuild_install_location}/Applications/${program}.app/Contents/Resources/${app_plugin_file}")
    endif ()
79
    install(
80
      FILES       "${plugin_source_path}"
81
      DESTINATION "${program}.app/Contents/Plugins/"
82
      COMPONENT   superbuild)
83
  endforeach ()
84

85
86
  foreach (executable IN LISTS paraview_executables)
    superbuild_apple_install_utility(
87
      "\${CMAKE_INSTALL_PREFIX}"
88
      "${program}.app"
89
      "${superbuild_install_location}/bin/${executable}"
90
91
92
93
      SEARCH_DIRECTORIES
              "${superbuild_install_location}/lib")
  endforeach ()

Ben Boeckel's avatar
Ben Boeckel committed
94
  install(CODE
95
96
    "file(MAKE_DIRECTORY \"\${CMAKE_INSTALL_PREFIX}/${program}.app/Contents/Resources\")
    file(WRITE \"\${CMAKE_INSTALL_PREFIX}/${program}.app/Contents/Resources/qt.conf\" \"[Paths]\nPlugins = Plugins\n\")"
Ben Boeckel's avatar
Ben Boeckel committed
97
98
    COMPONENT superbuild)

99
100
101
  if (python3_built_by_superbuild)
    include(python3.functions)
    superbuild_install_superbuild_python3(
Ben Boeckel's avatar
Ben Boeckel committed
102
      BUNDLE "${program}.app")
103
104
105
106
  endif ()

  file(GLOB egg_dirs
    "${superbuild_install_location}/lib/python${superbuild_python_version}/site-packages/*.egg/")
Ben Boeckel's avatar
Ben Boeckel committed
107
  superbuild_apple_install_python(
108
    "\${CMAKE_INSTALL_PREFIX}"
Ben Boeckel's avatar
Ben Boeckel committed
109
    "${program}.app"
110
    MODULES ${cmb_python_modules}
Ben Boeckel's avatar
Ben Boeckel committed
111
112
    MODULE_DIRECTORIES
            "${superbuild_install_location}/Applications/paraview.app/Contents/Python"
113
114
            "${superbuild_install_location}/lib/python${superbuild_python_version}/site-packages"
            ${egg_dirs}
Ben Boeckel's avatar
Ben Boeckel committed
115
    SEARCH_DIRECTORIES
116
117
            "${superbuild_install_location}/Applications/paraview.app/Contents/Libraries"
            "${superbuild_install_location}/lib")
118

119
120
  if (matplotlib_enabled)
    install(
121
      DIRECTORY   "${superbuild_install_location}/lib/python${superbuild_python_version}/site-packages/matplotlib/mpl-data/"
122
      DESTINATION "${program}.app/Contents/Python/matplotlib/mpl-data"
123
124
125
      COMPONENT   superbuild)
  endif ()

126
127
  if (pythonrequests_enabled)
    install(
128
      FILES       "${superbuild_install_location}/lib/python${superbuild_python_version}/site-packages/requests/cacert.pem"
129
      DESTINATION "${program}.app/Contents/Python/requests"
130
131
      COMPONENT   superbuild)
  endif ()
132
133
134
135

  if (paraviewweb_enabled)
    install(
      FILES       "${superbuild_install_location}/Applications/paraview.app/Contents/Python/paraview/web/defaultProxies.json"
136
      DESTINATION "${program}.app/Contents/Python/paraview/web"
137
138
139
      COMPONENT   "superbuild")
    install(
      DIRECTORY   "${superbuild_install_location}/share/paraview/web"
140
      DESTINATION "${program}.app/Contents/Resources"
141
142
      COMPONENT   "superbuild")
  endif ()
Ben Boeckel's avatar
Ben Boeckel committed
143
144
145
146
147
148

  foreach (qt5_plugin_path IN LISTS qt5_plugin_paths)
    get_filename_component(qt5_plugin_group "${qt5_plugin_path}" DIRECTORY)
    get_filename_component(qt5_plugin_group "${qt5_plugin_group}" NAME)

    superbuild_apple_install_module(
149
      "\${CMAKE_INSTALL_PREFIX}"
Ben Boeckel's avatar
Ben Boeckel committed
150
151
152
153
154
      "${program}.app"
      "${qt5_plugin_path}"
      "Contents/Plugins/${qt5_plugin_group}"
      SEARCH_DIRECTORIES  "${library_paths}")
  endforeach ()
155

156
  if (cmb_doc_base_dir)
157
    set(cmb_doc_dir "${program}.app/Contents/Resources/${cmb_doc_base_dir}")
158
159
160
161
  endif ()

  # Install PDF guides.
  cmb_install_extra_data()
Ben Boeckel's avatar
Ben Boeckel committed
162

163
164
165
166
167
168
169
170
  # Note: Ignoring the cmb_workflow_dir for apple and treating it as a flag
  if (cmb_workflow_dir)
    install(
      DIRECTORY   "${superbuild_install_location}/share/cmb/workflows/"
      DESTINATION ${program}.app/${cmb_workflow_dir}
      COMPONENT   superbuild)
  endif ()
endforeach ()
171
172
173
174

if (meshkit_enabled)
  foreach (meshkit_exe IN ITEMS coregen assygen)
    superbuild_apple_install_utility(
175
      "\${CMAKE_INSTALL_PREFIX}"
176
177
178
179
180
181
182
      "modelbuilder.app"
      "${superbuild_install_location}/bin/${meshkit_exe}"
      SEARCH_DIRECTORIES  "${library_paths}"
      FRAMEWORK_DEST      "Frameworks/meshkit"
      LIBRARY_DEST        "Libraries/meshkit")
  endforeach ()
endif ()