1
#-- Need this for link line stuff?
2
if(COMMAND cmake_policy)
3
cmake_policy(SET CMP0009 NEW)
4
endif(COMMAND cmake_policy)
6
set(OSX_App "Avogadro.app")
8
# gp_item_default_embedded_path item default_embedded_path_var
10
# Return the path that others should refer to the item by when the item
11
# is embedded inside a bundle.
13
# Override on a per-project basis by providing a project-specific
14
# gp_item_default_embedded_path_override function.
16
function(gp_item_default_embedded_path_override item default_embedded_path_var)
18
# The assumption here is that all executables in the bundle will be
19
# in same-level-directories inside the bundle. The parent directory
20
# of an executable inside the bundle should be MacOS or a sibling of
21
# MacOS and all embedded paths returned from here will begin with
22
# "@loader_path/../" and will work from all executables in all
23
# such same-level-directories inside the bundle.
26
# By default, embed things right next to the main bundle executable:
28
set(install_name_prefix "@executable_path")
29
# -------------------------------------------------------------------
30
# If your application uses plugins then you should consider using the following
31
# instead but will limit your deployment to OS X 10.4. There is also a patch
32
# needed for CMake that as of Sept 30, 2008 has NOT been applied to CMake.
33
# set (install_name_prefix "@loader_path")
35
set(path "${install_name_prefix}/../MacOS")
39
# Embed .dylibs in the Libraries Directory
41
if(item MATCHES "\\.dylib$")
42
# Don't override the Qt plugins
43
if(NOT item MATCHES "libq[a-zA-Z0-9]*\\.dylib$|libphonon_qt7.dylib$")
44
set(path "${install_name_prefix}/../lib")
46
endif(NOT item MATCHES "libq[a-zA-Z0-9]*\\.dylib$|libphonon_qt7.dylib$")
47
# Now for the various Qt plugins - I think this is very hackish...
48
if(item MATCHES "plugins/accessible/[a-zA-Z]*\\.dylib$")
49
set(path "${install_name_prefix}/../plugins/accessible")
51
endif(item MATCHES "plugins/accessible/[a-zA-Z]*\\.dylib$")
52
if(item MATCHES "plugins/bearer/[a-zA-Z]*\\.dylib$")
53
set(path "${install_name_prefix}/../plugins/bearer")
55
endif(item MATCHES "plugins/bearer/[a-zA-Z]*\\.dylib$")
56
if(item MATCHES "plugins/designer/[a-zA-Z]*\\.dylib$")
57
set(path "${install_name_prefix}/../plugins/designer")
59
endif(item MATCHES "plugins/designer/[a-zA-Z]*\\.dylib$")
60
if(item MATCHES "plugins/codecs/[a-zA-Z]*\\.dylib$")
61
set(path "${install_name_prefix}/../plugins/codecs")
63
endif(item MATCHES "plugins/codecs/[a-zA-Z]*\\.dylib$")
64
if(item MATCHES "plugins/graphicssystems/[a-zA-Z]*\\.dylib$")
65
set(path "${install_name_prefix}/../plugins/graphicssystems")
67
endif(item MATCHES "plugins/graphicssystems/[a-zA-Z]*\\.dylib$")
68
if(item MATCHES "plugins/iconengines/[a-zA-Z]*\\.dylib$")
69
set(path "${install_name_prefix}/../plugins/iconengines")
71
endif(item MATCHES "plugins/iconengines/[a-zA-Z]*\\.dylib$")
72
if(item MATCHES "plugins/imageformats/[a-zA-Z]*\\.dylib$")
73
set(path "${install_name_prefix}/../plugins/imageformats")
75
endif(item MATCHES "plugins/imageformats/[a-zA-Z]*\\.dylib$")
76
if(item MATCHES "plugins/mediaservices/[a-zA-Z]*\\.dylib$")
77
set(path "${install_name_prefix}/../plugins/mediaservices")
79
endif(item MATCHES "plugins/mediaservices/[a-zA-Z]*\\.dylib$")
80
if(item MATCHES "plugins/phonon_backend/[a-zA-Z]*\\.dylib$")
81
set(path "${install_name_prefix}/../plugins/phonon_backend")
83
endif(item MATCHES "plugins/phonon_backend/[a-zA-Z]*\\.dylib$")
84
if(item MATCHES "plugins/script/[a-zA-Z]*\\.dylib$")
85
set(path "${install_name_prefix}/../plugins/script")
87
endif(item MATCHES "plugins/script/[a-zA-Z]*\\.dylib$")
88
if(item MATCHES "plugins/sqldrivers/[a-zA-Z]*\\.dylib$")
89
set(path "${install_name_prefix}/../plugins/sqldrivers")
91
endif(item MATCHES "plugins/sqldrivers/[a-zA-Z]*\\.dylib$")
92
endif(item MATCHES "\\.dylib$")
94
# Embed .so plugin files in their directories
96
if(item MATCHES "tool\\.so$")
97
set(path "${install_name_prefix}/../lib/avogadro/tools")
99
endif(item MATCHES "tool\\.so$")
100
if(item MATCHES "engine\\.so$")
101
set(path "${install_name_prefix}/../lib/avogadro/engines")
103
endif(item MATCHES "engine\\.so$")
104
if(item MATCHES "extension\\.so$")
105
set(path "${install_name_prefix}/../lib/avogadro/extensions")
107
endif(item MATCHES "extension\\.so$")
108
if(item MATCHES "color\\.so$")
109
set(path "${install_name_prefix}/../lib/avogadro/colors")
111
endif(item MATCHES "color\\.so$")
113
if(item MATCHES "format\\.so$")
114
set(path "${install_name_prefix}/../lib/openbabel")
116
endif(item MATCHES "format\\.so$")
117
if(item MATCHES "Interface\\.so$")
118
set(path "${install_name_prefix}/../lib/openbabel")
120
endif(item MATCHES "Interface\\.so$")
121
if(item MATCHES "chemdrawcdx.so$|chemdrawct.so$|molreport.so$|pubchem.so")
122
set(path "${install_name_prefix}/../lib/openbabel")
124
endif(item MATCHES "chemdrawcdx.so$|chemdrawct.so$|molreport.so$|pubchem.so")
126
# Embed frameworks in the embedded "Frameworks" directory (sibling of MacOS):
129
if(item MATCHES "[^/]+\\.framework/")
130
set(path "${install_name_prefix}/../Frameworks")
132
endif(item MATCHES "[^/]+\\.framework/")
133
endif(NOT overridden)
135
message(STATUS "Item: ${item}, new path ${path}")
136
set(${default_embedded_path_var} "${path}" PARENT_SCOPE)
137
endfunction(gp_item_default_embedded_path_override)
139
# -- Copy the App bundle to the installation location first
140
EXECUTE_PROCESS(COMMAND "@OSX_MAKE_STANDALONE_BUNDLE_BASH_SCRIPT@")
142
file(GLOB_RECURSE pluginList "$ENV{DESTDIR}/Applications/${OSX_App}/Contents/lib/avogadro/*.so")
144
file(GLOB obList "$ENV{DESTDIR}/Applications/${OSX_App}/Contents/lib/openbabel/*")
145
file(GLOB_RECURSE qtPluginList "$ENV{DESTDIR}/Applications/${OSX_App}/Contents/plugins/*.dylib")
147
message(STATUS "PluginList: ${qtPluginList}")
149
# -- Run the BundleUtilities cmake code
150
include(BundleUtilities)
151
fixup_bundle("$ENV{DESTDIR}/Applications/${OSX_App}"
152
"${pluginList};${obList};${qtPluginList}"
153
"@LIB_INSTALL_DIR@;@LIB_INSTALL_DIR@/avogadro/tools;@LIB_INSTALL_DIR@/avogadro/engines;@LIB_INSTALL_DIR@/avogadro/colors;@LIB_INSTALL_DIR@/avogadro/extensions;$ENV{DESTDIR}/Applications/${OSX_App}/Contents/plugins/accessible;$ENV{DESTDIR}/Applications/${OSX_App}/Contents/plugins/designer;$ENV{DESTDIR}/Applications/${OSX_App}/Contents/plugins/iconengines;$ENV{DESTDIR}/Applications/${OSX_App}/Contents/plugins/phonon_backend;$ENV{DESTDIR}/Applications/${OSX_App}/Contents/plugins/sqldrivers;$ENV{DESTDIR}/Applications/${OSX_App}/Contents/plugins/codecs;$ENV{DESTDIR}/Applications/${OSX_App}/Contents/plugins/graphicssystems;$ENV{DESTDIR}/Applications/${OSX_App}/Contents/plugins/imageformats;$ENV{DESTDIR}/Applications/${OSX_App}/Contents/plugins/script")