Commit 243fcefa authored by David Moxey's avatar David Moxey
Browse files

Remove packaging modifications

parent 756ff62b
This diff is collapsed.
if(CPACK_GENERATOR STREQUAL "DEB")
# Debian packages
execute_process(COMMAND dpkg --print-architecture
OUTPUT_VARIABLE CPACK_DEBIAN_PACKAGE_ARCHITECTURE
OUTPUT_STRIP_TRAILING_WHITESPACE)
set(ARCHITECTURE ${CPACK_DEBIAN_PACKAGE_ARCHITECTURE})
elseif(CPACK_GENERATOR STREQUAL "RPM")
execute_process(COMMAND rpm --eval %{_arch}
OUTPUT_VARIABLE CPACK_RPM_PACKAGE_ARCHITECTURE
OUTPUT_STRIP_TRAILING_WHITESPACE)
set(ARCHITECTURE ${CPACK_RPM_PACKAGE_ARCHITECTURE})
set(CPACK_PACKAGE_FILE_NAME
"nektar-${CPACK_PACKAGE_VERSION}-1.${CPACK_RPM_PACKAGE_ARCHITECTURE}")
set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST /usr /usr/bin /usr/lib64 /usr/lib64/openmpi
/usr/lib64/openmpi/lib /usr/lib64/openmpi/bin)
elseif(CPACK_GENERATOR STREQUAL "PackageMaker")
# OS X .pkg installer -- set install location
set(CPACK_MONOLITHIC_INSTALL ON)
# Set install locations
set(CPACK_PACKAGE_DEFAULT_LOCATION "/")
set(CPACK_PACKAGING_INSTALL_PREFIX "/opt/nektar++")
set(CPACK_RESOURCE_FILE_WELCOME "@CMAKE_SOURCE_DIR@/pkg/osx-installer.html")
set(CPACK_POSTFLIGHT_SCRIPT "@CMAKE_SOURCE_DIR@/pkg/osx-postflight.sh")
# This is used as part of the identifier, so make it without spaces
set(CPACK_PACKAGE_VENDOR "imperialcollegelondon")
elseif(CPACK_GENERATOR STREQUAL "TGZ" OR
CPACK_GENERATOR STREQUAL "TXZ" OR
CPACK_GENERATOR STREQUAL "TZ" OR
CPACK_GENERATOR STREQUAL "TBZ2" OR
CPACK_GENERATOR STREQUAL "ZIP")
# Archive generators should use a monolithic installation
set(CPACK_MONOLITHIC_INSTALL ON)
endif()
# Determine architecture if not detected by rpm/dpkg above
if(NOT DEFINED ARCHITECTURE)
execute_process(COMMAND uname -m
OUTPUT_VARIABLE ARCHITECTURE
OUTPUT_STRIP_TRAILING_WHITESPACE)
endif()
......@@ -4,104 +4,6 @@
## Frequently used Nektar++ CMake configuration macros and functions
##
# Attempt to determine architecture for debian/RPM packages
execute_process(COMMAND dpkg --print-architecture
OUTPUT_VARIABLE DPKG_ARCHITECTURE
OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(COMMAND rpm --eval %{_arch}
OUTPUT_VARIABLE RPM_ARCHITECTURE
OUTPUT_STRIP_TRAILING_WHITESPACE)
#
# CONSTRUCT_DEBIAN_DEPS(depends outvar)
#
# This macro converts a list of component names to a string containing the
# Debian package dependencies for use by the CPack DEB generator, and stores
# this in an output variable. It assumes that packages will be named
# nektar++-<component>.
#
# Arguments:
# - `depends`: List of packages.
# - `outvar`: Name of output variable.
#
MACRO(CONSTRUCT_DEBIAN_DEPS depends outvar)
SET(${outvar} "")
FOREACH (pkg ${depends})
STRING(TOLOWER ${pkg} pkg_lower)
LIST(FIND NEKTAR_LIBS ${pkg_lower} islib)
IF(islib EQUAL -1)
SET(${outvar} "${${outvar}}, nektar++-${pkg_lower} (>= ${NEKTAR_VERSION})")
ELSE()
SET(${outvar} "${${outvar}}, libnektar++-${pkg_lower} (>= ${NEKTAR_VERSION})")
ENDIF()
ENDFOREACH()
# Remove starting ", "
STRING(SUBSTRING ${${outvar}} 2 -1 ${outvar})
UNSET(pkg)
UNSET(pkg_lower)
ENDMACRO()
#
# FINALISE_CPACK_COMPONENT(name SUMMARY <summary> DESCRIPTION <description>)
#
# Finalises the variables needed for a component (and only really a component
# containing executables) in order to be packaged by CPack. This should be
# called once all executables and libraries have been added to the
# component. This routine will:
#
# - setup the component's name and description
# - compile a unique list of dependencies
# - construct a Debian dependency string using CONSTRUCT_DEBIAN_DEPS to be used
# in the resulting `.deb` file.
#
# Arguments:
# - `name`: component name.
# - `SUMMARY`: a brief summary of the package
# - `DESCRIPTION`: a more detailed description of the package
#
MACRO(FINALISE_CPACK_COMPONENT name)
# Don't both doing anything if we aren't building packages.
IF (NEKTAR_BUILD_PACKAGES)
CMAKE_PARSE_ARGUMENTS(COMP "" "DESCRIPTION;SUMMARY" "" ${ARGN})
# Component names are stored as upper case in the CPack variable names.
STRING(TOUPPER ${name} COMPVAR)
# Set the component name to `nektar++-<name>`
SET(CPACK_COMPONENT_${COMPVAR}_DISPLAY_NAME nektar++-${name}
CACHE INTERNAL "")
SET(CPACK_COMPONENT_${COMPVAR}_DESCRIPTION ${COMP_DESCRIPTION}
CACHE INTERNAL "")
SET(CPACK_COMPONENT_${COMPVAR}_DESCRIPTION_SUMMARY ${COMP_SUMMARY}
CACHE INTERNAL "")
SET(CPACK_RPM_${COMPVAR}_PACKAGE_SUMMARY ${COMP_SUMMARY}
CACHE INTERNAL "")
# Remove any duplicates from the existing CPack component dependencies
# which are set by NEKTAR_ADD_EXECUTABLE and NEKTAR_ADD_LIBRARY
SET(tmp ${CPACK_COMPONENT_${COMPVAR}_DEPENDS})
LIST(REMOVE_DUPLICATES tmp)
SET(CPACK_COMPONENT_${COMPVAR}_DEPENDS ${tmp}
CACHE INTERNAL "")
# Construct list of Debian dependencies
CONSTRUCT_DEBIAN_DEPS("${CPACK_COMPONENT_${COMPVAR}_DEPENDS}" "tmp")
SET(CPACK_DEBIAN_${COMPVAR}_PACKAGE_DEPENDS ${tmp}
CACHE INTERNAL "")
# Other Debian details
SET(CPACK_DEBIAN_${COMPVAR}_FILE_NAME
"nektar++-${name}-${NEKTAR_VERSION}-${DPKG_ARCHITECTURE}.deb"
CACHE INTERNAL "")
SET(CPACK_RPM_${COMPVAR}_FILE_NAME
"nektar++-${name}-${NEKTAR_VERSION}-1.${RPM_ARCHITECTURE}.rpm"
CACHE INTERNAL "")
ENDIF()
ENDMACRO()
#
# THIRDPARTY_LIBRARY(varname DESCRIPTION <description> [STATIC|SHARED])
#
......@@ -260,17 +162,8 @@ MACRO(ADD_NEKTAR_EXECUTABLE name)
ARCHIVE DESTINATION ${NEKTAR_LIB_DIR} COMPONENT ${NEKEXE_COMPONENT} OPTIONAL
LIBRARY DESTINATION ${NEKTAR_LIB_DIR} COMPONENT ${NEKEXE_COMPONENT} OPTIONAL)
# Add dependencies for executable. We append the dependencies to the CPack
# component list so that we can resolve these later.
# Add dependencies for executable.
TARGET_LINK_LIBRARIES(${name} LINK_PUBLIC ${NEKEXE_DEPENDS})
SET(tmp ${CPACK_COMPONENT_${NEKEXE_COMPVAR}_DEPENDS})
FOREACH(dep ${NEKEXE_DEPENDS})
STRING(TOLOWER ${dep} tmp2)
LIST(APPEND tmp ${tmp2})
ENDFOREACH()
LIST(REMOVE_DUPLICATES tmp)
SET(CPACK_COMPONENT_${NEKEXE_COMPVAR}_DEPENDS ${tmp}
CACHE INTERNAL "")
ENDMACRO()
#
......@@ -326,41 +219,9 @@ MACRO(ADD_NEKTAR_LIBRARY name)
COMPONENT dev)
ENDFOREACH()
# Add CPack information
SET(CPACK_COMPONENT_${NEKLIB_COMPVAR}_DISPLAY_NAME libnektar++-${NEKLIB_COMPONENT}
CACHE INTERNAL "")
SET(CPACK_COMPONENT_${NEKLIB_COMPVAR}_DISPLAY_GROUP lib
CACHE INTERNAL "")
SET(CPACK_COMPONENT_${NEKLIB_COMPVAR}_DESCRIPTION ${NEKLIB_DESCRIPTION}
CACHE INTERNAL "")
SET(CPACK_COMPONENT_${NEKLIB_COMPVAR}_DESCRIPTION_SUMMARY ${NEKLIB_SUMMARY}
CACHE INTERNAL "")
# Debian specific information
SET(CPACK_DEBIAN_${NEKLIB_COMPVAR}_FILE_NAME
"libnektar++-${NEKLIB_COMPONENT}-${NEKTAR_VERSION}-${DPKG_ARCHITECTURE}.deb"
CACHE INTERNAL "")
SET(CPACK_DEBIAN_${NEKLIB_COMPVAR}_PACKAGE_NAME
"libnektar++-${NEKLIB_COMPONENT}" CACHE INTERNAL "")
# RPM specific information
SET(CPACK_RPM_${NEKLIB_COMPVAR}_FILE_NAME
"libnektar++-${NEKLIB_COMPONENT}-1.${RPM_ARCHITECTURE}.rpm"
CACHE INTERNAL "")
SET(CPACK_RPM_${NEKLIB_COMPVAR}_PACKAGE_NAME
"libnektar++-${NEKLIB_COMPONENT}" CACHE INTERNAL "")
# If we have dependencies then link against them, and also configure CPack
# Debian dependencies, which are a special case for some reason. Then set up
# standard CPack components.
# If we have dependencies then link against them.
IF(NEKLIB_DEPENDS)
TARGET_LINK_LIBRARIES(${name} LINK_PUBLIC ${NEKLIB_DEPENDS})
CONSTRUCT_DEBIAN_DEPS(${NEKLIB_DEPENDS} "tmp")
SET(CPACK_DEBIAN_${NEKLIB_COMPVAR}_PACKAGE_DEPENDS ${tmp}
CACHE INTERNAL "")
STRING(TOLOWER ${NEKLIB_DEPENDS} tmp)
SET(CPACK_COMPONENT_${NEKLIB_COMPVAR}_DEPENDS ${tmp}
CACHE INTERNAL "")
ENDIF()
ENDMACRO()
......
# Packaging
SET(NEKTAR_PACKAGE_GENERATOR "None" CACHE STRING
"Support Packaging: RPM or DEB" )
MARK_AS_ADVANCED(NEKTAR_PACKAGE_GENERATOR)
# Define components
SET(CPACK_COMPONENTS_ALL dev lib demos extra-demos)
#SET(CPACK_RPM_PACKAGE_DEBUG ON)
SET(CPACK_COMPONENT_LIB_NAME "nektar++-lib")
SET(CPACK_COMPONENT_LIB_DISPLAY_NAME "nektar++-lib")
SET(CPACK_COMPONENT_LIB_DESCRIPTION "Nektar++ Libraries")
SET(CPACK_COMPONENT_DEV_NAME "nektar++-dev")
SET(CPACK_COMPONENT_DEV_DISPLAY_NAME "nektar++-dev")
SET(CPACK_COMPONENT_DEV_DESCRIPTION "Development files for Nektar++")
SET(CPACK_COMPONENT_DEV_DEPENDS lib)
SET(CPACK_COMPONENT_DEMOS_NAME "nektar++-demos")
SET(CPACK_COMPONENT_DEMOS_DISPLAY_NAME "nektar++-demos")
SET(CPACK_COMPONENT_DEMOS_DESCRIPTION "Framework demonstration binaries")
SET(CPACK_COMPONENT_DEMOS_DEPENDS lib)
SET(CPACK_COMPONENT_EXTRA-DEMOS_NAME "nektar++-extra-demos")
SET(CPACK_COMPONENT_EXTRA-DEMOS_DISPLAY_NAME "nektar++-extra-demos")
SET(CPACK_COMPONENT_EXTRA-DEMOS_DESCRIPTION
"Framework extra demonstration binaries")
SET(CPACK_COMPONENT_EXTRA-DEMOS_DEPENDS lib)
# CPack setup
IF (NOT ${NEKTAR_PACKAGE_GENERATOR} MATCHES "None")
# Check if we have a valid Package generator selected
IF (NOT ${NEKTAR_PACKAGE_GENERATOR} MATCHES "RPM"
AND NOT ${NEKTAR_PACKAGE_GENERATOR} MATCHES "DEB")
MESSAGE(SEND_ERROR "Unknown packaging generator:
${NEKTAR_PACKAGE_GENERATOR}")
ENDIF()
SET(CPACK_GENERATOR "${NEKTAR_PACKAGE_GENERATOR}")
SET(CPACK_TOPLEVEL_TAG "${CMAKE_SYSTEM_PROCESSOR}")
SET(CPACK_SYSTEM_NAME "${CMAKE_SYSTEM_PROCESSOR}")
SET(CPACK_PACKAGE_NAME "nektar++")
SET(CPACK_PACKAGE_VENDOR "Imperial College London")
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY
"Spectral/hp Element Framework for solving PDEs")
SET(CPACK_PACKAGE_DESCRIPTION "
The nektar++ packages provide a spectral/hp element framework for the numerical
solution of partial differential equations (PDEs). Demonstration codes are
provided in the nektar++-demos package, along with a number of time-dependent
solvers in the nektar++-solvers package.")
SET(CPACK_PACKAGE_INSTALL_DIRECTORY "nektar++")
SET(CPACK_PACKAGE_CONTACT "Chris Cantwell <c.cantwell@imperial.ac.uk>")
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})
SET(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_SOURCE_DIR}/LICENSE.txt)
# RPM packaging
IF (${NEKTAR_PACKAGE_GENERATOR} MATCHES "RPM")
MESSAGE(STATUS "Generating Packaging for RPM")
SET(CPACK_RPM_PACKAGE_URL "www.nektar.info")
SET(CPACK_RPM_COMPONENT_INSTALL ON)
SET(CPACK_RPM_PACKAGE_REQUIRES "fftw3, libboost_date_time1_44_0, libboost_filesystem1_44_0, libboost_iostreams1_44_0, libboost_system1_44_0, libboost_thread1_44_0, libboost_timer1_44_0, zlib")
SET(CPACK_RPM_PACKAGE_DESCRIPTION "
The nektar++ packages provide a spectral/hp element framework for the numerical
solution of partial differential equations (PDEs). Demonstration codes are
provided in the nektar++-demos package, along with a number of time-dependent
solvers in the nektar++-solvers package.")
ENDIF()
IF (${NEKTAR_PACKAGE_GENERATOR} MATCHES "DEB")
MESSAGE(STATUS "Generating Packaging for DEB")
SET(CPACK_DEB_PACKAGE_URL "www.nektar.info")
SET(CPACK_DEB_COMPONENT_INSTALL ON)
SET(CPACK_DEBIAN_PACKAGE_DEPENDS "libfftw3-3,libboost-date-time1.42.0,libboost-filesystem1.42.0,libboost-iostreams1.42.0,libboost-program-options1.42.0,libboost-system1.42.0,libboost-thread1.42.0,libboost-timer1.42.0,zlib1g")
SET(CPACK_DEBIAN_PACKAGE_DESCRIPTION
"${CPACK_PACKAGE_DESCRIPTION_SUMMARY}
${CPACK_PACKAGE_DESCRIPTION}")
SET(CPACK_DEBIAN_PACKAGE_SECTION "devel")
SET(CPACK_DEBIAN_PACKAGE_PRIORITY "optional")
ENDIF()
# Finally, include the CPack module
INCLUDE(CPack)
ENDIF()
......@@ -32,12 +32,6 @@ ADD_NEKTAR_EXECUTABLE(SteadyAdvectionDiffusionReaction2D
# Add ExtraDemos subdirectory.
ADD_SUBDIRECTORY(ExtraDemos)
# Finalise demos package here, since this is the last subdirectory to be
# processed by CMake from the upper level CMakeLists.txt
FINALISE_CPACK_COMPONENT(demos
SUMMARY "Nektar++ demonstration applications"
DESCRIPTION "This package contains a number of example programs for solving simple problems using the spectral/hp element method.")
ADD_NEKTAR_TEST(Helmholtz1D_CG_P8)
ADD_NEKTAR_TEST(Helmholtz1D_CG_P8_periodic)
ADD_NEKTAR_TEST(Helmholtz1D_CG_P8_RBC)
......
......@@ -17,10 +17,6 @@ ADD_NEKTAR_EXECUTABLE(SteadyLinearAdvectionReaction2D
ADD_NEKTAR_EXECUTABLE(PostProcessing
COMPONENT demos-extra DEPENDS MultiRegions SOURCES PostProcessing.cpp)
FINALISE_CPACK_COMPONENT(demos-extra
SUMMARY "Nektar++ extra demos"
DESCRIPTION "Additional demos for Nektar++.")
ADD_NEKTAR_TEST(ProjectionCont2D_P7)
IF (NEKTAR_USE_MPI)
ADD_NEKTAR_TEST(ProjectionCont2D_P7_par)
......
......@@ -121,9 +121,4 @@ ENDIF()
INSTALL(DIRECTORY ./
DESTINATION ${NEKTAR_INCLUDE_DIR}/NekMeshUtils
COMPONENT dev
FILES_MATCHING PATTERN "*.h" PATTERN "*.hpp")
SET(CPACK_COMPONENT_DEV_DEPENDS ${NEKTAR_LIBS} CACHE INTERNAL "")
FINALISE_CPACK_COMPONENT(dev
SUMMARY "Nektar++ development headers"
DESCRIPTION "Headers for Nektar++ spectral element framework")
FILES_MATCHING PATTERN "*.h" PATTERN "*.hpp")
\ No newline at end of file
......@@ -25,6 +25,4 @@ ADD_NEKTAR_EXECUTABLE(UnitTests
COMPONENT unit-test DEPENDS StdRegions SOURCES ${UnitTestSources})
ADD_TEST(NAME UnitTests COMMAND UnitTests --detect_memory_leaks=0)
SUBDIRS(LibUtilities LocalRegions Collections)
FINALISE_CPACK_COMPONENT(unit-test DESCRIPTION "Nektar++ unit tests" SUMMARY "Nektar++ unit tests")
SUBDIRS(LibUtilities LocalRegions Collections)
\ No newline at end of file
function (write_lib_files PKG_INSTALL_LIBS OUTPUT_FILE)
# Find library file and add the versioned form of each library
set(PKG_INSTALL_LIBS_FILES)
foreach(l ${PKG_INSTALL_LIBS})
IF(${CMAKE_MAJOR_VERSION} LESS 3)
get_target_property(TARGET_LOCATION ${l} LOCATION)
ELSE ()
SET(TARGET_LOCATION $<TARGET_LINKER_FILE:${l}>)
ENDIF()
if (NOT TARGET_LOCATION)
message(FATAL_ERROR "Target '${l}' could not be found.")
endif ()
list(APPEND PKG_INSTALL_LIBS_FILES ${TARGET_LOCATION})
if (APPLE)
list(APPEND PKG_INSTALL_LIBS_FILES $<TARGET_FILE:${l}>)
else ()
list(APPEND PKG_INSTALL_LIBS_FILES
${TARGET_LOCATION}.${NEKTAR_VERSION})
endif()
endforeach()
# Output the list of files to be installed in the package
IF(${CMAKE_MAJOR_VERSION} LESS 3)
file(WRITE "${OUTPUT_FILE}" "${PKG_INSTALL_LIBS_FILES}")
ELSE ()
file(GENERATE OUTPUT "${OUTPUT_FILE}"
CONTENT "${PKG_INSTALL_LIBS_FILES}")
ENDIF ()
endfunction ()
function (write_bin_files PKG_INSTALL_BINS OUTPUT_FILE)
# Find binary files
set(PKG_INSTALL_BINS_FILES)
foreach(b ${PKG_INSTALL_BINS})
IF(EXISTS ${b})
get_filename_component(TARGET_LOCATION ${b} REALPATH)
ELSEIF(${CMAKE_MAJOR_VERSION} LESS 3)
get_target_property(TARGET_LOCATION ${b} LOCATION)
ELSE ()
SET(TARGET_LOCATION $<TARGET_FILE:${b}>)
ENDIF ()
if (NOT TARGET_LOCATION)
message(FATAL_ERROR "Target '${b}' could not be found.")
endif ()
list(APPEND PKG_INSTALL_BINS_FILES ${TARGET_LOCATION})
endforeach()
# Output the list of files to be installed in the package
IF(${CMAKE_MAJOR_VERSION} LESS 3)
file(WRITE "${OUTPUT_FILE}" "${PKG_INSTALL_BINS_FILES}")
ELSE ()
file(GENERATE OUTPUT "${OUTPUT_FILE}"
CONTENT "${PKG_INSTALL_BINS_FILES}")
ENDIF ()
endfunction ()
macro (add_nektar_package)
set(options "")
set(oneValueArgs NAME SUMMARY DESCRIPTION TYPE)
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}-${PKG_TYPE})
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")
if(PKG_TYPE STREQUAL "deb")
set(PKG_GENERATOR "DEB")
elseif(PKG_TYPE STREQUAL "rpm")
set(PKG_GENERATOR "RPM")
elseif(PKG_TYPE STREQUAL "pkgmaker")
set(PKG_GENERATOR "PackageMaker")
elseif(PKG_TYPE STREQUAL "tgz")
set(PKG_GENERATOR "TGZ")
else()
message(ERROR "Unknown package type: ${PKG_TYPE}")
endif()
# Configure project for this package
configure_file(NektarPackage.cmake.in ${BUILD_DIR}/CMakeLists.txt @ONLY)
add_custom_target(
pkg-${PKG_TYPE}-${PKG_NAME}
rm -f ${BUILD_DIR}/CPackConfig.cmake
COMMAND ${CMAKE_COMMAND} .
COMMAND ${CMAKE_CPACK_COMMAND} --config CPackConfig.cmake -G ${PKG_GENERATOR}
WORKING_DIRECTORY ${BUILD_DIR}
)
if (PKG_INSTALL_LIBS OR PKG_INSTALL_BINS)
add_dependencies(pkg-${PKG_TYPE}-${PKG_NAME}
${PKG_INSTALL_LIBS} ${PKG_INSTALL_BINS})
endif ()
add_dependencies(pkg-${PKG_TYPE} pkg-${PKG_TYPE}-${PKG_NAME})
endmacro()
# Base packaging target
add_custom_target(pkg)
# Check if we can build DEB files
find_program(DPKG "dpkg")
mark_as_advanced(DPKG)
find_program(DPKGSHLIBDEPS "dpkg-shlibdeps")
mark_as_advanced(DPKGSHLIBDEPS)
if (DPKG)
if (NOT DPKGSHLIBDEPS)
MESSAGE(FATAL_ERROR "dpkg-shlibdeps program not found but is required.")
endif ()
add_custom_target(pkg-deb)
add_dependencies(pkg pkg-deb)
endif (DPKG)
# Check if we can build RPM files
find_program(RPMBUILD "rpmbuild")
mark_as_advanced(RPMBUILD)
if (RPMBUILD)
add_custom_target(pkg-rpm)
add_dependencies(pkg pkg-rpm)
endif (RPMBUILD)
# Check if we can build PackageMaker .pkg files. PackageMaker is technically
# deprecated but still works at least up to OS X 10.11. It could therefore live
# in a bunch of locations, so check common places.
find_program(PKGMAKER "PackageMaker"
PATHS /Applications/Xcode.app/Contents/Applications/PackageMaker.app/Contents/MacOS
/Applications/Utilities/PackageMaker.app/Contents/MacOS
/Applications/PackageMaker.app/Contents/MacOS
/Developer/Applications/Utilities/PackageMaker.app/Contents/MacOS
/Developer/Applications/PackageMaker.app/Contents/MacOS)
if (PKGMAKER)
add_custom_target(pkg-pkgmaker)
add_dependencies(pkg pkg-pkgmaker)
endif()
# Binary archive target
add_custom_target(pkg-tgz)
add_dependencies(pkg pkg-tgz)
This diff is collapsed.
cmake_minimum_required(VERSION 2.6)
project("pkg-@PKG_NAME@")
# Files to go in the package
file(READ "targets/install_libs.txt" INSTALL_LIBS_FILES)
file(READ "targets/install_bins.txt" INSTALL_BINS_FILES)
# Put output in builds dir.
set(CPACK_OUTPUT_FILE_PREFIX "../..")
# Package details
set(CPACK_GENERATOR "@PKG_GENERATOR@")
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@")
if(CPACK_GENERATOR STREQUAL "DEB")
# Debian packages
execute_process(COMMAND dpkg --print-architecture
OUTPUT_VARIABLE CPACK_DEBIAN_PACKAGE_ARCHITECTURE
OUTPUT_STRIP_TRAILING_WHITESPACE)
set(ARCHITECTURE ${CPACK_DEBIAN_PACKAGE_ARCHITECTURE})
set(CPACK_DEBIAN_PACKAGE_DEBUG ON)
set(CPACK_DEBIAN_PACKAGE_MAINTAINER
"Chris Cantwell <c.cantwell@imperial.ac.uk>")
set(CPACK_DEBIAN_PACKAGE_SECTION "devel")
set(CPACK_DEBIAN_PACKAGE_PRIORITY "optional")
set(CPACK_DEBIAN_PACKAGE_HOMEPAGE "http://www.nektar.info")
set(CPACK_DEBIAN_PACKAGE_DESCRIPTION
"@PKG_SUMMARY@@PKG_DESCRIPTION@")
set(CPACK_DEBIAN_PACKAGE_DEPENDS "@PKG_DEPENDS@")
if (INSTALL_BINS_FILES OR INSTALL_LIBS_FILES)
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
endif ()
elseif(CPACK_GENERATOR STREQUAL "RPM")
execute_process(COMMAND rpm --eval %{_arch}
OUTPUT_VARIABLE CPACK_RPM_PACKAGE_ARCHITECTURE
OUTPUT_STRIP_TRAILING_WHITESPACE)
set(ARCHITECTURE ${CPACK_RPM_PACKAGE_ARCHITECTURE})
set(CPACK_RPM_PACKAGE_SUMMARY "@PKG_SUMMARY@")
set(CPACK_RPM_PACKAGE_DESCRIPTION "@PKG_DESCRIPTION@")
set(CPACK_RPM_PACKAGE_REQUIRES "@PKG_DEPENDS@")
set(CPACK_RPM_PACKAGE_GROUP "Development/Libraries")
set(CPACK_RPM_PACKAGE_LICENSE "MIT")
set(CPACK_RPM_PACKAGE_DEBUG 0)
set(CPACK_PACKAGE_FILE_NAME
"${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-1.${CPACK_RPM_PACKAGE_ARCHITECTURE}")
elseif(CPACK_GENERATOR STREQUAL "PackageMaker")
# OS X .pkg installer -- set install location
set(CPACK_PACKAGE_DEFAULT_LOCATION "/")
set(CPACK_PACKAGING_INSTALL_PREFIX "/opt/nektar++")
set(CPACK_RESOURCE_FILE_WELCOME "@CMAKE_SOURCE_DIR@/pkg/osx-installer.html")
set(CPACK_POSTFLIGHT_SCRIPT "@CMAKE_SOURCE_DIR@/pkg/osx-postflight.sh")
# This is used as part of the identifier, so make it without spaces
set(CPACK_PACKAGE_VENDOR "imperialcollegelondon")
endif()
# Determine architecture if not detected by rpm/dpkg above
if(NOT DEFINED ARCHITECTURE)
execute_process(COMMAND uname -m
OUTPUT_VARIABLE ARCHITECTURE
OUTPUT_STRIP_TRAILING_WHITESPACE)
endif()
# Override the output filename to comply with Debian naming policy
if(NOT DEFINED CPACK_PACKAGE_FILE_NAME)
set(CPACK_PACKAGE_FILE_NAME
"${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${ARCHITECTURE}")
endif()
# 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 lovely 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 executable and copy any libraries that we depend on, so that
# things like ARPACK can be compiled using MacPorts/Homebrew and we don't have
# to bother messing around compiling them ourselves.
#
# The strategy is:
#
# - Examine the library dependencies using the get_prerequisites function from
# the GetPrerequisites CMake module (that essentially runs 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