Commit 2c6b6724 authored by Dave Moxey's avatar Dave Moxey

Fix OS X source packaging, add PackageMaker generator to create installer,...

Fix OS X source packaging, add PackageMaker generator to create installer, rename LICENSE -> LICENSE.txt to keep PackageMaker happy
parent 60f42ec0
...@@ -55,7 +55,7 @@ solvers in the nektar++-solvers package.") ...@@ -55,7 +55,7 @@ solvers in the nektar++-solvers package.")
SET(CPACK_PACKAGE_VERSION_MAJOR ${NEKTAR_VERSION_MAJOR}) SET(CPACK_PACKAGE_VERSION_MAJOR ${NEKTAR_VERSION_MAJOR})
SET(CPACK_PACKAGE_VERSION_MINOR ${NEKTAR_VERSION_MINOR}) SET(CPACK_PACKAGE_VERSION_MINOR ${NEKTAR_VERSION_MINOR})
SET(CPACK_PACKAGE_VERSION_PATCH ${NEKTAR_VERSION_PATCH}) SET(CPACK_PACKAGE_VERSION_PATCH ${NEKTAR_VERSION_PATCH})
SET(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_SOURCE_DIR}/LICENSE) SET(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_SOURCE_DIR}/LICENSE.txt)
# RPM packaging # RPM packaging
IF (${NEKTAR_PACKAGE_GENERATOR} MATCHES "RPM") IF (${NEKTAR_PACKAGE_GENERATOR} MATCHES "RPM")
......
...@@ -12,8 +12,7 @@ function (write_lib_files PKG_INSTALL_LIBS OUTPUT_FILE) ...@@ -12,8 +12,7 @@ function (write_lib_files PKG_INSTALL_LIBS OUTPUT_FILE)
endif () endif ()
list(APPEND PKG_INSTALL_LIBS_FILES ${TARGET_LOCATION}) list(APPEND PKG_INSTALL_LIBS_FILES ${TARGET_LOCATION})
if (APPLE) if (APPLE)
list(APPEND PKG_INSTALL_LIBS_FILES list(APPEND PKG_INSTALL_LIBS_FILES $<TARGET_FILE:${l}>)
${TARGET_LOCATION}.${VERSION_MAJOR_MINOR})
else () else ()
list(APPEND PKG_INSTALL_LIBS_FILES list(APPEND PKG_INSTALL_LIBS_FILES
${TARGET_LOCATION}.${NEKTAR_VERSION}) ${TARGET_LOCATION}.${NEKTAR_VERSION})
...@@ -152,6 +151,37 @@ macro (add_tgz_package) ...@@ -152,6 +151,37 @@ macro (add_tgz_package)
add_dependencies(pkg-tgz pkg-tgz-${PKG_NAME}) add_dependencies(pkg-tgz pkg-tgz-${PKG_NAME})
endmacro (add_tgz_package) endmacro (add_tgz_package)
macro (add_pkgmaker_package)
set(options "")
set(oneValueArgs NAME SUMMARY DESCRIPTION)
set(multiValueArgs INSTALL_LIBS INSTALL_BINS BREAKS CONFLICTS DEPENDS)
cmake_parse_arguments(PKG "${options}"
"${oneValueArgs}" "${multiValueArgs}" ${ARGN} )
set(BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/${PKG_NAME}-pkgmaker)
file(MAKE_DIRECTORY "${BUILD_DIR}/targets")
write_lib_files("${PKG_INSTALL_LIBS}"
"${BUILD_DIR}/targets/install_libs.txt")
write_bin_files("${PKG_INSTALL_BINS}"
"${BUILD_DIR}/targets/install_bins.txt")
configure_file(CMakeListsPkgMaker.txt.in
${BUILD_DIR}/CMakeLists.txt @ONLY)
add_custom_target(
pkg-pkgmaker-${PKG_NAME}
rm -f ${BUILD_DIR}/CPackConfig.cmake
COMMAND ${CMAKE_COMMAND} .
COMMAND ${CMAKE_CPACK_COMMAND} --config CPackConfig.cmake
WORKING_DIRECTORY ${BUILD_DIR}
)
if (PKG_INSTALL_LIBS OR PKG_INSTALL_BINS)
add_dependencies(pkg-pkgmaker-${PKG_NAME}
${PKG_INSTALL_LIBS} ${PKG_INSTALL_BINS})
endif()
add_dependencies(pkg-pkgmaker pkg-pkgmaker-${PKG_NAME})
endmacro (add_pkgmaker_package)
# Base packaging target # Base packaging target
add_custom_target(pkg) add_custom_target(pkg)
...@@ -176,6 +206,9 @@ if (RPMBUILD) ...@@ -176,6 +206,9 @@ if (RPMBUILD)
add_dependencies(pkg pkg-rpm) add_dependencies(pkg pkg-rpm)
endif (RPMBUILD) endif (RPMBUILD)
add_custom_target(pkg-pkgmaker)
add_dependencies(pkg pkg-pkgmaker)
# Binary archive target # Binary archive target
add_custom_target(pkg-tgz) add_custom_target(pkg-tgz)
add_dependencies(pkg pkg-tgz) add_dependencies(pkg pkg-tgz)
...@@ -340,7 +340,16 @@ if (NEKTAR_BUILD_LIBRARY) ...@@ -340,7 +340,16 @@ if (NEKTAR_BUILD_LIBRARY)
SUMMARY "Nektar++ libraries and solvers" SUMMARY "Nektar++ libraries and solvers"
DESCRIPTION "This is all of Nektar++" DESCRIPTION "This is all of Nektar++"
INSTALL_LIBS "${nektar++_LIBS}" INSTALL_LIBS "${nektar++_LIBS}"
) INSTALL_BINS "${nektar++_BINS}"
)
add_pkgmaker_package(
NAME nektar++
SUMMARY "Nektar++ libraries and solvers"
DESCRIPTION "This is all of Nektar++"
INSTALL_LIBS "${nektar++_LIBS}"
INSTALL_BINS "${nektar++_BINS}"
)
endif (NEKTAR_BUILD_LIBRARY) endif (NEKTAR_BUILD_LIBRARY)
# Configure source package # Configure source package
......
cmake_minimum_required(VERSION 2.6)
project("pkg-@PKG_NAME@")
set(CPACK_GENERATOR "PackageMaker")
set(CPACK_OUTPUT_FILE_PREFIX "../..") # Put in builds dir.
# Find out the machine architecture
execute_process(COMMAND uname -m
OUTPUT_VARIABLE ARCHITECTURE
OUTPUT_STRIP_TRAILING_WHITESPACE)
# Package details
set(CPACK_PACKAGE_NAME "@PKG_NAME@")
set(CPACK_PACKAGE_VENDOR "Imperial College London")
set(CPACK_PACKAGE_CONTACT
"Nektar++ users mailing list <nektar-users@imperial.ac.uk>")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "@PKG_SUMMARY@")
set(CPACK_PACKAGE_DESCRIPTION "@PKG_DESCRIPTION@")
set(CPACK_RESOURCE_FILE_LICENSE "@CMAKE_SOURCE_DIR@/LICENSE.txt")
set(CPACK_PACKAGE_VERSION "@NEKTAR_VERSION@")
set(CPACK_PACKAGE_VERSION_MAJOR "@NEKTAR_VERSION_MAJOR@")
set(CPACK_PACKAGE_VERSION_MINOR "@NEKTAR_VERSION_MINOR@")
set(CPACK_PACKAGE_VERSION_PATCH "@NEKTAR_VERSION_PATCH@")
# Override the output filename to comply with Debian naming policy
set(CPACK_PACKAGE_FILE_NAME
"${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${ARCHITECTURE}")
set(CPACK_PACKAGE_DEFAULT_LOCATION "/usr/local/nektar++")
set(CPACK_PACKAGING_INSTALL_PREFIX "/")
# Files to go in the package
file(READ "targets/install_libs.txt" INSTALL_LIBS_FILES)
file(READ "targets/install_bins.txt" INSTALL_BINS_FILES)
# Install any libraries in the lib directory: exclude OS X, we will copy/patch
# up libraries as we install executables.
if(INSTALL_LIBS_FILES AND NOT APPLE)
install(FILES ${INSTALL_LIBS_FILES} DESTINATION lib
PERMISSIONS
OWNER_READ OWNER_WRITE OWNER_EXECUTE
GROUP_READ GROUP_EXECUTE
WORLD_READ WORLD_EXECUTE
)
endif()
# Install any binaries in the bin directory
if(INSTALL_BINS_FILES)
install(FILES ${INSTALL_BINS_FILES} DESTINATION bin
PERMISSIONS
OWNER_READ OWNER_WRITE OWNER_EXECUTE
GROUP_READ GROUP_EXECUTE
WORLD_READ WORLD_EXECUTE
)
endif()
# This horrible block of code is designed to patch up our executables ready for
# OS X deployment. The strategy is to create a piece of INSTALL code that will
# patch up each executables and copy any libraries that we depend on, so that
# things like ARPACK can be compiled using MacPorts/Homebrew.
#
# The strategy is:
#
# - Examine the library dependencies using the get_prerequisites function from
# the GetPrerequisites CMake module (basically, run otool recursively)
# - Copy each of the libraries into dist/lib
# - Run install_name_tool on each library to remove the absolute path to the
# installed library.
# - This is then replaced by @rpath/../lib/libName.dylib so that @rpath can be
# embedded into the executable.
# - Change the library install name so that it follows the same convention
# - Extract the rpaths from our executable using the get_item_rpaths function
# from BundleUtilities
# - Finally, set the rpath of each executable to be @executable_path so that
# everything becomes relative to the executable
#
# All of this makes an entirely self-contained version of Nektar++ that can be
# extracted anywhere on the system and still retain its dependencies.
if(APPLE)
foreach(app ${INSTALL_BINS_FILES})
get_filename_component(appname ${app} NAME)
set(app "\${CMAKE_INSTALL_PREFIX}/bin/${appname}")
install(CODE "
include(GetPrerequisites)
include(BundleUtilities)
get_filename_component(exepath ${app} DIRECTORY)
get_prerequisites(\"${app}\" prereqs 1 1 \"\${exepath}\" \"\" \"\" 1)
message(STATUS \"Fixing executable: ${app}\")
# First pass -- copy libraries and figure out -change command for
# install_name_tool. Note that since install_name_tool doesn't complain
# if the thing you're changing isn't there, we just throw everything
# at every library.
unset(changes)
unset(changes_lib)
foreach(req \${prereqs})
get_filename_component(reqname \${req} NAME)
set(libdest \${CMAKE_INSTALL_PREFIX}/lib/\${reqname})
set(changes \${changes} \"-change\" \"\${req}\" \"@executable_path/../lib/\${reqname}\")
set(changes_lib \${changes_lib} \"-change\" \"\${req}\" \"@rpath/../lib/\${reqname}\")
# Copy this library
if (NOT EXISTS \${libdest})
file(COPY \${req}
DESTINATION \${CMAKE_INSTALL_PREFIX}/lib
FILE_PERMISSIONS OWNER_WRITE OWNER_READ)
# If the library was symlinked, we follow the symlink and then
# copy that, too.
if (IS_SYMLINK \${req})
# resolve symlink
get_filename_component(req_abs \${req} REALPATH)
file(COPY \${req_abs}
DESTINATION \${CMAKE_INSTALL_PREFIX}/lib
FILE_PERMISSIONS OWNER_WRITE OWNER_READ)
endif()
endif()
endforeach()
# Second pass -- fix up library to use @rpath/../lib/libName.dylib
foreach(req \${prereqs})
set(searchname \${req})
if (IS_SYMLINK \${req})
get_filename_component(req_abs \${req} REALPATH)
set(req \${req_abs})
endif()
get_filename_component(reqname \${req} NAME)
set(libdest \${CMAKE_INSTALL_PREFIX}/lib/\${reqname})
set(cmd install_name_tool \${changes_lib} \"\${libdest}\")
execute_process(COMMAND \${cmd} RESULT_VARIABLE install_name_tool_result)
# change library install name ID
execute_process(COMMAND install_name_tool -id @rpath/../lib/\${reqname} \${libdest})
# change @loader_path (used by some boost libs through homebrew)
endforeach()
# Third pass -- fix executable library names
foreach(req \${prereqs})
set(cmd install_name_tool \${changes} \"${app}\")
execute_process(COMMAND \${cmd} RESULT_VARIABLE install_name_tool_result)
endforeach()
# Fix rpath -- unset variables that have been used on previous passes
unset(app_rpaths)
get_item_rpaths(\"${app}\" app_rpaths)
unset(app_rpaths_unique)
unset(rpath_changes)
foreach(rpath \${app_rpaths})
gp_append_unique (app_rpaths_unique \${rpath})
endforeach()
foreach(rpath \${app_rpaths_unique})
set(rpath_changes \${rpath_changes} -delete_rpath \${rpath})
endforeach()
set(rpath_changes \${rpath_changes} -add_rpath @executable_path)
execute_process(COMMAND install_name_tool \${rpath_changes} \"${app}\")
")
ENDFOREACH()
endif()
include(CPack)
...@@ -17,7 +17,7 @@ set(CPACK_PACKAGE_CONTACT ...@@ -17,7 +17,7 @@ set(CPACK_PACKAGE_CONTACT
"Nektar++ users mailing list <nektar-users@imperial.ac.uk>") "Nektar++ users mailing list <nektar-users@imperial.ac.uk>")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "@PKG_SUMMARY@") set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "@PKG_SUMMARY@")
set(CPACK_PACKAGE_DESCRIPTION "@PKG_DESCRIPTION@") set(CPACK_PACKAGE_DESCRIPTION "@PKG_DESCRIPTION@")
set(CPACK_RESOURCE_FILE_LICENSE "@CMAKE_SOURCE_DIR@/LICENSE") set(CPACK_RESOURCE_FILE_LICENSE "@CMAKE_SOURCE_DIR@/LICENSE.txt")
set(CPACK_PACKAGE_VERSION "@NEKTAR_VERSION@") set(CPACK_PACKAGE_VERSION "@NEKTAR_VERSION@")
set(CPACK_PACKAGE_VERSION_MAJOR "@NEKTAR_VERSION_MAJOR@") set(CPACK_PACKAGE_VERSION_MAJOR "@NEKTAR_VERSION_MAJOR@")
set(CPACK_PACKAGE_VERSION_MINOR "@NEKTAR_VERSION_MINOR@") set(CPACK_PACKAGE_VERSION_MINOR "@NEKTAR_VERSION_MINOR@")
...@@ -31,8 +31,9 @@ set(CPACK_PACKAGE_FILE_NAME ...@@ -31,8 +31,9 @@ set(CPACK_PACKAGE_FILE_NAME
file(READ "targets/install_libs.txt" INSTALL_LIBS_FILES) file(READ "targets/install_libs.txt" INSTALL_LIBS_FILES)
file(READ "targets/install_bins.txt" INSTALL_BINS_FILES) file(READ "targets/install_bins.txt" INSTALL_BINS_FILES)
# Install any libraries in the lib directory # Install any libraries in the lib directory: exclude OS X, we will copy/patch
if(INSTALL_LIBS_FILES) # up libraries as we install executables.
if(INSTALL_LIBS_FILES AND NOT APPLE)
install(FILES ${INSTALL_LIBS_FILES} DESTINATION lib install(FILES ${INSTALL_LIBS_FILES} DESTINATION lib
PERMISSIONS PERMISSIONS
OWNER_READ OWNER_WRITE OWNER_EXECUTE OWNER_READ OWNER_WRITE OWNER_EXECUTE
...@@ -51,4 +52,113 @@ if(INSTALL_BINS_FILES) ...@@ -51,4 +52,113 @@ if(INSTALL_BINS_FILES)
) )
endif() endif()
# This horrible block of code is designed to patch up our executables ready for
# OS X deployment. The strategy is to create a piece of INSTALL code that will
# patch up each executables and copy any libraries that we depend on, so that
# things like ARPACK can be compiled using MacPorts/Homebrew.
#
# The strategy is:
#
# - Examine the library dependencies using the get_prerequisites function from
# the GetPrerequisites CMake module (basically, run otool recursively)
# - Copy each of the libraries into dist/lib
# - Run install_name_tool on each library to remove the absolute path to the
# installed library.
# - This is then replaced by @rpath/../lib/libName.dylib so that @rpath can be
# embedded into the executable.
# - Change the library install name so that it follows the same convention
# - Extract the rpaths from our executable using the get_item_rpaths function
# from BundleUtilities
# - Finally, set the rpath of each executable to be @executable_path so that
# everything becomes relative to the executable
#
# All of this makes an entirely self-contained version of Nektar++ that can be
# extracted anywhere on the system and still retain its dependencies.
if(APPLE)
foreach(app ${INSTALL_BINS_FILES})
get_filename_component(appname ${app} NAME)
set(app "\${CMAKE_INSTALL_PREFIX}/bin/${appname}")
install(CODE "
include(GetPrerequisites)
include(BundleUtilities)
get_filename_component(exepath ${app} DIRECTORY)
get_prerequisites(\"${app}\" prereqs 1 1 \"\${exepath}\" \"\" \"\" 1)
message(STATUS \"Fixing executable: ${app}\")
# First pass -- copy libraries and figure out -change command for
# install_name_tool. Note that since install_name_tool doesn't complain
# if the thing you're changing isn't there, we just throw everything
# at every library.
unset(changes)
unset(changes_lib)
foreach(req \${prereqs})
get_filename_component(reqname \${req} NAME)
set(libdest \${CMAKE_INSTALL_PREFIX}/lib/\${reqname})
set(changes \${changes} \"-change\" \"\${req}\" \"@executable_path/../lib/\${reqname}\")
set(changes_lib \${changes_lib} \"-change\" \"\${req}\" \"@rpath/../lib/\${reqname}\")
# Copy this library
if (NOT EXISTS \${libdest})
file(COPY \${req}
DESTINATION \${CMAKE_INSTALL_PREFIX}/lib
FILE_PERMISSIONS OWNER_WRITE OWNER_READ)
# If the library was symlinked, we follow the symlink and then
# copy that, too.
if (IS_SYMLINK \${req})
# resolve symlink
get_filename_component(req_abs \${req} REALPATH)
file(COPY \${req_abs}
DESTINATION \${CMAKE_INSTALL_PREFIX}/lib
FILE_PERMISSIONS OWNER_WRITE OWNER_READ)
endif()
endif()
endforeach()
# Second pass -- fix up library to use @rpath/../lib/libName.dylib
foreach(req \${prereqs})
set(searchname \${req})
if (IS_SYMLINK \${req})
get_filename_component(req_abs \${req} REALPATH)
set(req \${req_abs})
endif()
get_filename_component(reqname \${req} NAME)
set(libdest \${CMAKE_INSTALL_PREFIX}/lib/\${reqname})
set(cmd install_name_tool \${changes_lib} \"\${libdest}\")
execute_process(COMMAND \${cmd} RESULT_VARIABLE install_name_tool_result)
# change library install name ID
execute_process(COMMAND install_name_tool -id @rpath/../lib/\${reqname} \${libdest})
# change @loader_path (used by some boost libs through homebrew)
endforeach()
# Third pass -- fix executable library names
foreach(req \${prereqs})
set(cmd install_name_tool \${changes} \"${app}\")
execute_process(COMMAND \${cmd} RESULT_VARIABLE install_name_tool_result)
endforeach()
# Fix rpath -- unset variables that have been used on previous passes
unset(app_rpaths)
get_item_rpaths(\"${app}\" app_rpaths)
unset(app_rpaths_unique)
unset(rpath_changes)
foreach(rpath \${app_rpaths})
gp_append_unique (app_rpaths_unique \${rpath})
endforeach()
foreach(rpath \${app_rpaths_unique})
set(rpath_changes \${rpath_changes} -delete_rpath \${rpath})
endforeach()
set(rpath_changes \${rpath_changes} -add_rpath @executable_path)
execute_process(COMMAND install_name_tool \${rpath_changes} \"${app}\")
")
ENDFOREACH()
endif()
include(CPack) include(CPack)
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