Commit 0503b0b3 authored by Ben Boeckel's avatar Ben Boeckel

apple: implement packaging

parent ba4c68b0
set(cmb_plugins)
foreach (cmb_plugin IN LISTS cmb_plugins_to_install)
foreach (path IN ITEMS "" "cmb-${cmb_version}" "paraview-${paraview_version}")
if (EXISTS "${superbuild_install_location}/lib/${path}/lib${cmb_plugin}.dylib")
list(APPEND cmb_plugins
"${superbuild_install_location}/lib/${path}/lib${cmb_plugin}.dylib")
break ()
endif ()
endforeach ()
endforeach ()
foreach(program IN LISTS cmb_programs_to_install)
superbuild_apple_create_app(
"\${CMAKE_INSTALL_PREFIX}/${cmb_package}"
"${program}.app"
"${superbuild_install_location}/Applications/${program}.app/Contents/MacOS/${program}"
CLEAN
PLUGINS ${cmb_plugins}
SEARCH_DIRECTORIES
"${superbuild_install_location}/lib")
install(CODE
"file(MAKE_DIRECTORY \"\${CMAKE_INSTALL_PREFIX}/${cmb_package}/${program}.app/Contents/Resources\")
file(WRITE \"\${CMAKE_INSTALL_PREFIX}/${cmb_package}/${program}.app/Contents/Resources/qt.conf\" \"\")"
COMPONENT superbuild)
install(
FILES "${cmb_plugins_file}"
DESTINATION "${cmb_package}/${program}.app/Contents/Plugins"
COMPONENT superbuild)
superbuild_apple_install_python(
"\${CMAKE_INSTALL_PREFIX}/${cmb_package}"
"${program}.app"
MODULES smtk
shiboken
MODULE_DIRECTORIES
"${superbuild_install_location}/lib/python2.7/site-packages"
SEARCH_DIRECTORIES
"${superbuild_install_location}/lib")
superbuild_apple_install_python(
"\${CMAKE_INSTALL_PREFIX}/${cmb_package}"
"${program}.app"
MODULES paraview
pygments
vtk
MODULE_DIRECTORIES
"${superbuild_install_location}/Applications/paraview.app/Contents/Python"
SEARCH_DIRECTORIES
"${superbuild_install_location}/Applications/paraview.app/Contents/Libraries")
endforeach ()
# FIXME: Install inside of each application?
install(
DIRECTORY "${superbuild_install_location}/share/cmb/workflows/"
DESTINATION "Workflows"
COMPONENT superbuild)
include("${CMAKE_CURRENT_LIST_DIR}/../cmb.cmake")
superbuild_project_add_step(install_cmb_paraview_plugin
COMMENT "Fixing missing include files."
COMMAND ${CMAKE_COMMAND}
-DINSTALL_DIR:PATH=<INSTALL_DIR>
-DCMB_BINARY_DIR:PATH=<BUILD_DIR>
-DTMP_DIR:PATH=<TMP_DIR>
-DCMB_VERSION:STRING=${cmb_version}
-P "${CMAKE_CURRENT_LIST_DIR}/scripts/cmb.install_paraview_plugin.cmake"
DEPENDEES install)
#special mac only script to install smtk plugins for cmb
superbuild_project_add_step(install_smtk_cmb_plugins
COMMENT "installing smtk plugins for cmb."
COMMAND ${CMAKE_COMMAND}
-DINSTALL_DIR:PATH=<INSTALL_DIR>
-DTMP_DIR:PATH=<TMP_DIR>
-P "${CMAKE_CURRENT_LIST_DIR}/scripts/cmb.install_smtk_paraview_plugin.cmake"
DEPENDEES install)
include(hydrology.bundle.common)
set(cmb_package "CMB-Hydro ${cmb_version_major}.${cmb_version_minor}.${cmb_version_patch}")
include(cmb.bundle.apple)
include(modelbuilder.bundle.common)
set(cmb_package "ModelBuilder ${cmb_version_major}.${cmb_version_minor}.${cmb_version_patch}")
include(cmb.bundle.apple)
#!/usr/bin/env python
# This is simple script that can be used to fixup a library (dylib or so)
# Usage:
# ./fixup_plugin.py <full path to lib to fix or dir with libraries to fix> "key=val" ["key=val" ...]
# This is simply replaces any referece to 'key' with 'val' in the libraries referred to
# by the plugin lib to fix. 'key' can be a Python regular expression.
# The order of the key=value pairs is significant. The expressions are
# tested in the order specified.
import commands
import sys
import os.path
import re
import shutil
from fixup_bundle import *
plugin_dir = sys.argv[1]
prefix_new = sys.argv[2]
libs_to_fix = commands.getoutput('find %s -type f | xargs file --separator ":--:" | grep -i ":--:.*Mach-O" | sed "s/:.*//" | sort | uniq ' % plugin_dir).split()
print "Found", len(libs_to_fix), "libraries to fix."
print "\n".join(libs_to_fix)
print ""
for plugin_lib in libs_to_fix:
base_name = os.path.basename(plugin_lib)
new_id = os.path.join(prefix_new,base_name)
print '======> install_name_tool -id "%s" %s'%(new_id,plugin_lib)
commands.getoutput('chmod u+w "%s"' % plugin_lib)
commands.getoutput('install_name_tool -id "%s" %s' % (new_id,plugin_lib))
commands.getoutput('chmod a-w "%s"' % plugin_lib)
print "Finished fixing up plugins"
set(SHARED_LIBRARY_SUFFIX ".dylib")
file(REMOVE_DIRECTORY "${TMP_DIR}/CmbPlugin")
file(MAKE_DIRECTORY "${TMP_DIR}/CmbPlugin")
set(plugin_install_dir ${INSTALL_DIR}/Applications/paraview.app/Contents/Plugins)
file(MAKE_DIRECTORY "${plugin_install_dir}")
file(COPY "${CMB_BINARY_DIR}/lib/cmb-${CMB_VERSION}/"
DESTINATION "${TMP_DIR}/CmbPlugin"
FILES_MATCHING
PATTERN "*Plugin*${SHARED_LIBRARY_SUFFIX}")
execute_process(
COMMAND ${CMAKE_CURRENT_LIST_DIR}/cmb.fixup_plugin.py
# The directory containing the plugin dylibs.
${TMP_DIR}/CmbPlugin
# fixup only the id of the plugins based on this string
"@executable_path/../Plugins/"
)
#okay the plugin is fixed up, now we need to install it into paraviews bundle
file(COPY "${TMP_DIR}/CmbPlugin/"
DESTINATION "${plugin_install_dir}"
FILES_MATCHING
PATTERN "*Plugin*${SHARED_LIBRARY_SUFFIX}"
)
set(SHARED_LIBRARY_SUFFIX ".dylib")
file(REMOVE_DIRECTORY "${TMP_DIR}/smtkCmbPlugin")
file(MAKE_DIRECTORY "${TMP_DIR}/smtkCmbPlugin")
set(plugin_install_dir ${INSTALL_DIR}/Applications/ModelBuilder.app/Contents/Plugins)
file(MAKE_DIRECTORY "${plugin_install_dir}")
file(COPY "${INSTALL_DIR}/lib/"
DESTINATION "${TMP_DIR}/smtkCmbPlugin"
FILES_MATCHING
PATTERN "libsmtk*Plugin*${SHARED_LIBRARY_SUFFIX}")
execute_process(
COMMAND ${CMAKE_CURRENT_LIST_DIR}/cmb.fixup_plugin.py
# The directory containing the plugin dylibs.
${TMP_DIR}/smtkCmbPlugin
# fixup only the id of the plugins based on this string
"@executable_path/../Plugins/"
)
#okay the plugin is fixed up, now we need to install it into paraviews bundle
file(COPY "${TMP_DIR}/smtkCmbPlugin/"
DESTINATION "${plugin_install_dir}"
FILES_MATCHING
PATTERN "*Plugin*${SHARED_LIBRARY_SUFFIX}"
)
#!/usr/bin/env python
# This is simple script that can be used to fixup a library (dylib or so)
# Usage:
# ./fixup_plugin.py <full path to lib to fix or dir with libraries to fix> "key=val" ["key=val" ...]
# This is simply replaces any referece to 'key' with 'val' in the libraries referred to
# by the plugin lib to fix. 'key' can be a Python regular expression.
# The order of the key=value pairs is significant. The expressions are
# tested in the order specified.
import commands
import sys
import os.path
import re
import shutil
from fixup_bundle import *
plugin_dir = sys.argv[1]
prefix_new = sys.argv[2]
libs_to_fix = commands.getoutput('find %s -type f | xargs file --separator ":--:" | grep -i ":--:.*Mach-O" | sed "s/:.*//" | sort | uniq ' % plugin_dir).split()
print "Found", len(libs_to_fix), "libraries to fix."
print "\n".join(libs_to_fix)
print ""
so_files = [x for x in libs_to_fix if ".so" in x]
for so in so_files:
libs = getdependencies(so)
for dylib in libs:
if not isexcluded(dylib):
if "libshiboken-python" in dylib:
commands.getoutput('install_name_tool -change "%s" "@loader_path/%s" "%s"'%(dylib, os.path.basename(dylib), so))
else:
commands.getoutput('install_name_tool -change "%s" "@executable_path/../Libraries/%s" "%s"'%(dylib, os.path.basename(dylib), so))
for plugin_lib in libs_to_fix:
base_name = os.path.basename(plugin_lib)
new_id = os.path.join(prefix_new,base_name)
commands.getoutput('chmod u+w "%s"' % plugin_lib)
commands.getoutput('install_name_tool -id "%s" %s' % (new_id,plugin_lib))
commands.getoutput('chmod a-w "%s"' % plugin_lib)
print "Finished fixing up python"
#We only have to do this special installation of the smtk libraries as a plugin
#on MAC
file(REMOVE_RECURSE "${tmp_dir}/SMTKPlugin")
file(MAKE_DIRECTORY "${tmp_dir}/SMTKPlugin")
set(plugin_install_dir ${INSTALL_DIR}/Applications/ModelBuilder.app/Contents/Python/smtk)
file(MAKE_DIRECTORY "${plugin_install_dir}")
set(py_files_libs ${smtk_bin_dir}/lib/python2.7/site-packages/smtk/smtkCorePython.so
${smtk_bin_dir}/lib/libshiboken-python2.7.1.2.dylib
${smtk_bin_dir}/lib/python2.7/site-packages/shiboken.so
${smtk_bin_dir}/lib/python2.7/site-packages/smtk/simple.py)
foreach(lib IN LISTS py_files_libs)
configure_file(
"${lib}"
"${tmp_dir}/SMTKPlugin"
COPYONLY)
endforeach()
execute_process(
COMMAND ${CMAKE_CURRENT_LIST_DIR}/smtk.fixup_python.py
# The directory containing the plugin dylibs.
${tmp_dir}/SMTKPlugin
# fixup only the id of the plugins based on this string
""
)
#okay the plugin is fixed up, now we need to install it into paraviews bundle
file(GLOB fixedUpLibs "${tmp_dir}/SMTKPlugin/*")
foreach(lib IN LISTS fixedUpLibs)
message(STATUS "Installing plugin: ${lib}")
configure_file(
"${lib}"
"${plugin_install_dir}"
COPYONLY)
endforeach()
include("${CMAKE_CURRENT_LIST_DIR}/../smtk.cmake")
superbuild_project_add_step(install-shiboken-python-plugin
COMMENT "smtk: fixing missing include files"
COMMAND ${CMAKE_COMMAND}
-Dparaview_version:STRING=${paraview_version}
-Dpv_python_executable:PATH=${pv_python_executable}
-Dsmtk_bin_dir:PATH=<INSTALL_DIR>
-Dtmp_dir:PATH=<TMP_DIR>
-P "${CMAKE_CURRENT_LIST_DIR}/scripts/smtk.install_python_plugin.cmake"
DEPENDEES install)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment