Commit c6b362db authored by LAMBERT Jean-charles's avatar LAMBERT Jean-charles

modifs to generate package

parent 0770cd9c
......@@ -35,6 +35,9 @@ if(CCACHE_FOUND)
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
endif(CCACHE_FOUND)
# Cpack Generator detection
include(DetectCpackGenerator)
# contains the full path to the top level directory of your build tree
MESSAGE( STATUS "PROJECT_BINARY_DIR: " ${PROJECT_BINARY_DIR} )
......@@ -75,6 +78,7 @@ ENDIF (NOT NEMO_INSTALLED)
MESSAGE( STATUS "NEMOLIB : " ${NEMOLIB} )
MESSAGE( STATUS "NEMOINC : " ${NEMOINC} )
MESSAGE( STATUS "LIB_SUFFIX : " ${LIB_SUFFIX} )
# Find all the sources for the LIB
FILE(GLOB LIBSOURCES src/*.cc)
......@@ -114,9 +118,19 @@ endif()
# ----------------------------------------------------------
# Install SETUP
# ----------------------------------------------------------
SET(PREFIX_LIB "lib")
SET(PREFIX_INC "inc")
SET(PREFIX_MAN "man")
SET(PREFIX_SCR "scripts")
mark_as_advanced(CMAKE_INSTALL_PREFIX)
if (CMAKE_INSTALL_PREFIX STREQUAL "/usr")
SET(PREFIX_LIB "lib64")
SET(PREFIX_INC "include")
SET(PREFIX_MAN "share/man")
SET(PREFIX_SCR "share/uns/scripts")
endif()
IF (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
IF (NEMO_INSTALLED)
set (CMAKE_INSTALL_PREFIX "$ENV{NEMO}" CACHE PATH "" FORCE) #if NEMO exist => default install into NEMO path
......@@ -136,16 +150,16 @@ SET(CMAKE_SKIP_BUILD_RPATH FALSE)
# (but later on when installing)
SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${PREFIX_LIB}")
# add the automatically determined parts of the RPATH
# which point to directories outside the build tree to the install RPATH
SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
# the RPATH to be used when installing, but only if it's not a system directory
LIST(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib" isSystemDir)
LIST(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/${PREFIX_LIB}" isSystemDir)
IF("${isSystemDir}" STREQUAL "-1")
SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${PREFIX_LIB}")
ENDIF("${isSystemDir}" STREQUAL "-1")
......@@ -212,47 +226,136 @@ endif()
# ----------------------------------------------------------
# UNS specific includes
INSTALL(FILES ${UNSIO2_BINARY_DIR}/../src/uns.h DESTINATION inc/uns)
INSTALL(FILES ${UNSIO2_BINARY_DIR}/../src/unsdebug.h DESTINATION inc/uns)
INSTALL(FILES ${UNSIO2_BINARY_DIR}/../src/snapshotinterface.h DESTINATION inc/uns)
INSTALL(FILES ${UNSIO2_BINARY_DIR}/../src/componentrange.h DESTINATION inc/uns)
INSTALL(FILES ${UNSIO2_BINARY_DIR}/../src/ctools.h DESTINATION inc/uns)
INSTALL(FILES ${UNSIO2_BINARY_DIR}/../src/userselection.h DESTINATION inc/uns)
INSTALL(FILES ${UNSIO2_BINARY_DIR}/../src/uns.h DESTINATION ${PREFIX_INC}/uns)
INSTALL(FILES ${UNSIO2_BINARY_DIR}/../src/unsdebug.h DESTINATION ${PREFIX_INC}/uns)
INSTALL(FILES ${UNSIO2_BINARY_DIR}/../src/snapshotinterface.h DESTINATION ${PREFIX_INC}/uns)
INSTALL(FILES ${UNSIO2_BINARY_DIR}/../src/componentrange.h DESTINATION ${PREFIX_INC}/uns)
INSTALL(FILES ${UNSIO2_BINARY_DIR}/../src/ctools.h DESTINATION ${PREFIX_INC}/uns)
INSTALL(FILES ${UNSIO2_BINARY_DIR}/../src/userselection.h DESTINATION ${PREFIX_INC}/uns)
# NEMO specific includes
IF (NOT NEMO_INSTALLED)
# install nemo lib
INSTALL(FILES ${NEMOLIB}/libnemo.a DESTINATION lib)
INSTALL(FILES ${NEMOLIB}/libnemomaing77.a DESTINATION lib)
INSTALL(FILES ${NEMOLIB}/libnemo.a DESTINATION ${PREFIX_LIB})
INSTALL(FILES ${NEMOLIB}/libnemomaing77.a DESTINATION ${PREFIX_LIB})
# Find all NEMOLIGHT header files
FILE(GLOB nlight_files ${NEMOLIGHT}/src/*.h ${NEMOLIGHT}/src/inc/*.h)
FOREACH(source_header ${nlight_files})
INSTALL(FILES ${source_header} DESTINATION inc)
INSTALL(FILES ${source_header} DESTINATION ${PREFIX_INC})
ENDFOREACH()
FILE(GLOB nlight_files ${NEMOLIGHT}/src/inc/snapshot/*.{c,h})
FOREACH(source_header ${nlight_files})
INSTALL(FILES ${source_header} DESTINATION inc/snapshot)
INSTALL(FILES ${source_header} DESTINATION ${PREFIX_INC}/snapshot)
ENDFOREACH()
ENDIF()
# unsio lib
INSTALL(FILES ${UNSIO2_BINARY_DIR}/lib/libunsio.${LIBEXT} DESTINATION lib)
INSTALL(FILES ${UNSIO2_BINARY_DIR}/lib/libunsio.${LIBEXT} DESTINATION ${PREFIX_LIB})
# man
INSTALL(FILES ${UNSIO2_BINARY_DIR}/../man/man3/unsiof.3 DESTINATION man/man3)
# some binaries
# install sqlite3 database files
INSTALL(PROGRAMS ${UNSIO2_BINARY_DIR}/../scripts/perl/mains/unsio_sql3_get_info.pl DESTINATION bin)
INSTALL(PROGRAMS ${UNSIO2_BINARY_DIR}/../scripts/perl/mains/unsio_sql3_update_info.pl DESTINATION bin)
INSTALL(PROGRAMS ${UNSIO2_BINARY_DIR}/../scripts/perl/mains/unsio_sql3_update_nemorange.pl DESTINATION bin)
INSTALL(PROGRAMS ${UNSIO2_BINARY_DIR}/../scripts/perl/mains/unsio_sql3_create_db.pl DESTINATION bin)
INSTALL(FILES ${UNSIO2_BINARY_DIR}/../scripts/perl/lib/Tools/Tools.pm DESTINATION scripts/perl/lib/Tools)
INSTALL(FILES ${UNSIO2_BINARY_DIR}/../scripts/perl/lib/Tools/Sqlite3.pm DESTINATION scripts/perl/lib/Tools)
INSTALL(FILES ${UNSIO2_BINARY_DIR}/../scripts/sql/create_unsio_db.sql DESTINATION scripts/sql)
INSTALL(FILES ${UNSIO2_BINARY_DIR}/../scripts/sql/README DESTINATION scripts/sql)
INSTALL(FILES ${UNSIO2_BINARY_DIR}/../man/man3/unsiof.3 DESTINATION ${PREFIX_MAN}/man3)
if (NOT CMAKE_INSTALL_PREFIX STREQUAL "/usr")
# I man using this hack otherwise the RPM package created fails to install because an unresolve dependency on Tools::Sqlite3
# module though which comes with this install....
# install sqlite3 database files
INSTALL(FILES ${UNSIO2_BINARY_DIR}/../scripts/perl/lib/Tools/Tools.pm DESTINATION "${PREFIX_SCR}/perl/lib/Tools")
INSTALL(FILES ${UNSIO2_BINARY_DIR}/../scripts/perl/lib/Tools/Sqlite3.pm DESTINATION "${PREFIX_SCR}/perl/lib/Tools")
INSTALL(FILES ${UNSIO2_BINARY_DIR}/../scripts/sql/create_unsio_db.sql DESTINATION "${PREFIX_SCR}/sql")
INSTALL(FILES ${UNSIO2_BINARY_DIR}/../scripts/sql/README DESTINATION "${PREFIX_SCR}/sql")
# some binaries
INSTALL(PROGRAMS ${UNSIO2_BINARY_DIR}/../scripts/perl/mains/unsio_sql3_get_info.pl DESTINATION bin)
INSTALL(PROGRAMS ${UNSIO2_BINARY_DIR}/../scripts/perl/mains/unsio_sql3_update_info.pl DESTINATION bin)
INSTALL(PROGRAMS ${UNSIO2_BINARY_DIR}/../scripts/perl/mains/unsio_sql3_update_nemorange.pl DESTINATION bin)
INSTALL(PROGRAMS ${UNSIO2_BINARY_DIR}/../scripts/perl/mains/unsio_sql3_create_db.pl DESTINATION bin)
endif()
# ----------
# PACKAGING
# ----------
# VERSION
if (EXISTS "${PROJECT_SOURCE_DIR}/src/version.h") # detect version from "version.h" file
set(CURRENT_VERSION "")
file(READ "${PROJECT_SOURCE_DIR}/src/version.h" CURRENT_VERSION_H)
# UNSIO_MAJOR
string(REGEX MATCH "UNSIO_MAJOR \"([a-zA-Z0-9.-]+)\"" XXXX "${CURRENT_VERSION_H}")
set(PROJECT_VERSION_MAJOR ${CMAKE_MATCH_1})
# UNSIO_MINOR
string(REGEX MATCH "UNSIO_MINOR \"([a-zA-Z0-9.-]+)\"" XXXX "${CURRENT_VERSION_H}")
set(PROJECT_VERSION_MINOR ${CMAKE_MATCH_1})
# UNSIO_PATCH
string(REGEX MATCH "UNSIO_PATCH \"([a-zA-Z0-9.-]+)\"" XXXX "${CURRENT_VERSION_H}")
set(PROJECT_VERSION_PATCH ${CMAKE_MATCH_1})
# UNSIO_EXTRA
string(REGEX MATCH "UNSIO_EXTRA \"([_a-zA-Z0-9.-]+)\"" XXXX "${CURRENT_VERSION_H}")
set(PROJECT_VERSION_EXTRA ${CMAKE_MATCH_1})
# PROJECT_VERSION
set(PROJECT_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}${PROJECT_VERSION_EXTRA}")
message(STATUS "Project Version = " ${PROJECT_VERSION})
endif()
# CPACK infos
set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
set(CPACK_PACKAGE_NAME "unsio")
set(CPACK_PACKAGE_RELEASE 1)
set(CPACK_PACKAGE_CONTACT "Jean-Charles LAMBERT")
set(CPACK_PACKAGE_VENDOR "LAM - CeSAM")
set(CPACK_PACKAGING_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX})
set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}.${LINUX_NAME}.${CMAKE_SYSTEM_PROCESSOR}")
#set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CPACK_PACKAGE_RELEASE}.${LINUX_NAME}.${CMAKE_SYSTEM_PROCESSOR}")
# CPACK RPM specific
set(CPACK_RPM_CHANGELOG_FILE "${PROJECT_SOURCE_DIR}/ChangeLog")
set(CPACK_RPM_PACKAGE_LICENSE "CeCILL2")
set(CPACK_RPM_PACKAGE_DESCRIPTION "UNSIO - Universal Nbody Snapshot Input Output")
# CPACK debian specific
set(CPACK_DEBIAN_PACKAGE_NAME ${CPACK_PACKAGE_NAME})
set(CPACK_DEBIAN_PACKAGE_VERSION ${CPACK_PACKAGE_VERSION}-${CPACK_PACKAGE_RELEASE}.${LINUX_NAME})
IF(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64")
SET(CPACK_DEBIAN_PACKAGE_ARCHITECTURE amd64)
ELSEIF(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "i686")
SET(CPACK_DEBIAN_PACKAGE_ARCHITECTURE i386)
ENDIF(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64")
set(CPACK_DEBIAN_PACKAGE_DESCRIPTION ${CPACK_RPM_PACKAGE_DESCRIPTION})
if (APPLE)
set(CMAKE_INSTALL_PREFIX "/Applications")
set(CPACK_GENERATOR "DragNDrop")
set(CPACK_DMG_FORMAT "UDBZ")
set(CPACK_DMG_VOLUME_NAME "${PROJECT_NAME}")
set(CPACK_SYSTEM_NAME "OSX")
set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${PROJECT_VERSION}")
#set(CPACK_PACKAGE_ICON "${ICONS_DIR}/DMG.icns")
#set(CPACK_DMG_DS_STORE "${ICONS_DIR}/DMGDSStore")
#set(CPACK_DMG_BACKGROUND_IMAGE "${ICONS_DIR}/DMGBackground.png")
endif()
if (NOT WIN32)
#SET(CPACK_STRIP_FILES {CMAKE_INSTALL_PREFIX}/bin/glnemo2)
#SET(CPACK_STRIP_FILES "True")
#SET(CPACK_SET_DESTDIR On)
set(CMAKE_INSTALL_DO_STRIP TRUE)
#SET(CPACK_INSTALL_PREFIX "/usr")
#SET(CMAKE_INSTALL_PREFIX ${CPACK_INSTALL_PREFIX})
endif()
set(CMAKE_INSTALL_SYSTEM_RUNTIME_DESTINATION "${BIN_INSTALL_DIR}")
include(InstallRequiredSystemLibraries)
# This must always be last!
include(CPack)
# -*-cmake-*-
# ============================================================================
# Copyright Jean-Charles LAMBERT - 2008-2014
# e-mail: Jean-Charles.Lambert@lam.fr
# address: Dynamique des galaxies
# Centre de donneeS Astrophysique de Marseille (CeSAM)
# Laboratoire d'Astrophysique de Marseille
# Pole de l'Etoile, site de Chateau-Gombert
# 38, rue Frederic Joliot-Curie
# 13388 Marseille cedex 13 France
# CNRS U.M.R 7326
# ============================================================================
# Detect OS and architecture to select right CPACK Generator
# ============================================================================
#
# Inspired from :
# http://www.cmake.org/pipermail/cmake/2010-July/038268.html
# http://www.cmake.org/pipermail/cmake/attachments/20100722/04976a73/attachment-0001.obj
#
# define a set of string with may-be useful readable name
# this file is meant to be included in a CMakeLists.txt
# not as a standalone CMake script
set(SPECIFIC_COMPILER_NAME "")
set(SPECIFIC_SYSTEM_VERSION_NAME "")
set(SPECIFIC_SYSTEM_PREFERED_CPACK_GENERATOR "")
set(LINUX_NAME "")
set(MY_OS "")
if(UNIX)
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
set(SPECIFIC_SYSTEM_VERSION_NAME "${CMAKE_SYSTEM_NAME}")
set(SPECIFIC_SYSTEM_PREFERED_CPACK_GENERATOR "TGZ")
set(LINUX_NAME "")
set(LINUX_ISSUE "")
if(EXISTS "/etc/system-release")
file(READ "/etc/system-release" LINUX_ISSUE)
elseif (EXISTS "/etc/issue")
file(READ "/etc/issue" LINUX_ISSUE)
elseif (EXISTS "/etc/redhat-release")
file(READ "/etc/redhat-release" LINUX_ISSUE)
endif(EXISTS "/etc/system-release")
# Mageia case
if(LINUX_ISSUE MATCHES "Mageia")
set(MY_OS "Mageia")
string(REGEX MATCH "release ([0-9]+)" MAGEIA "${LINUX_ISSUE}")
set(LINUX_NAME "mga${CMAKE_MATCH_1}")
set(SPECIFIC_SYSTEM_PREFERED_CPACK_GENERATOR "RPM")
MESSAGE (STATUS "Mageia :" ${LINUX_NAME})
endif(LINUX_ISSUE MATCHES "Mageia")
# Arch Linux
if(LINUX_ISSUE MATCHES "Arch")
set(MY_OS "Arch")
set(LINUX_NAME "arch")
#set(SPECIFIC_SYSTEM_PREFERED_CPACK_GENERATOR "RPM")
MESSAGE (STATUS "Arch Linux :" ${LINUX_NAME})
endif(LINUX_ISSUE MATCHES "Arch")
# Fedora case
if(LINUX_ISSUE MATCHES "Fedora")
set(MY_OS "Fedora")
string(REGEX MATCH "release ([0-9]+)" FEDORA "${LINUX_ISSUE}")
set(LINUX_NAME "fc${CMAKE_MATCH_1}")
set(SPECIFIC_SYSTEM_PREFERED_CPACK_GENERATOR "RPM")
endif(LINUX_ISSUE MATCHES "Fedora")
# Scientific case
if(LINUX_ISSUE MATCHES "Scientific")
set(MY_OS "Scientific")
string(REGEX MATCH "release ([0-9]+)" SCIENTIFIC "${LINUX_ISSUE}")
set(LINUX_NAME "el${CMAKE_MATCH_1}")
set(SPECIFIC_SYSTEM_PREFERED_CPACK_GENERATOR "RPM")
endif(LINUX_ISSUE MATCHES "Scientific")
if(LINUX_ISSUE MATCHES "CentOS")
set(MY_OS "CentOS")
string(REGEX MATCH "release ([0-9]+)" CENTOS "${LINUX_ISSUE}")
set(LINUX_NAME "el${CMAKE_MATCH_1}")
set(SPECIFIC_SYSTEM_PREFERED_CPACK_GENERATOR "RPM")
endif(LINUX_ISSUE MATCHES "CentOS")
# Ubuntu case
if(LINUX_ISSUE MATCHES "Ubuntu")
set (CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
set(MY_OS "Ubuntu")
string(REGEX MATCH "buntu ([0-9]+\\.[0-9]+)" UBUNTU "${LINUX_ISSUE}")
set(LINUX_NAME "ubuntu${CMAKE_MATCH_1}")
set(SPECIFIC_SYSTEM_PREFERED_CPACK_GENERATOR "DEB")
endif(LINUX_ISSUE MATCHES "Ubuntu")
# Mint case
if(LINUX_ISSUE MATCHES "Mint")
set (CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
set(MY_OS "Mint")
string(REGEX MATCH "Mint ([0-9]+\\.[0-9]+)" MINT "${LINUX_ISSUE}")
set(LINUX_NAME "mint${CMAKE_MATCH_1}")
set(SPECIFIC_SYSTEM_PREFERED_CPACK_GENERATOR "DEB")
endif(LINUX_ISSUE MATCHES "Mint")
# Debian case
if(LINUX_ISSUE MATCHES "Debian")
set (CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
string(REGEX MATCH "Debian .*ux ([a-zA-Z]*/?[a-zA-Z]*) .*" DEBIAN "${LINUX_ISSUE}")
set(LINUX_NAME "debian-${CMAKE_MATCH_1}")
string(REPLACE "/" "_" LINUX_NAME ${LINUX_NAME})
set(SPECIFIC_SYSTEM_PREFERED_CPACK_GENERATOR "DEB")
endif(LINUX_ISSUE MATCHES "Debian")
# Open SuSE case
if(LINUX_ISSUE MATCHES "SUSE")
set(MY_OS "Suse")
string(REGEX MATCH "SUSE ([a-zA-Z]*/?[a-zA-Z]*) ([0-9]+\\.[0-9]+)" SUSE "${LINUX_ISSUE}")
if (NOT ${CMAKE_MATCH_2} STREQUAL "")
set(LINUX_NAME "opensuse${CMAKE_MATCH_2}")
else()
set(LINUX_NAME "opensuse${CMAKE_MATCH_1}")
endif()
string(REPLACE "/" "_" LINUX_NAME ${LINUX_NAME})
set(SPECIFIC_SYSTEM_PREFERED_CPACK_GENERATOR "RPM")
endif(LINUX_ISSUE MATCHES "SUSE")
# Mandriva case
# TODO
if(LINUX_NAME)
set(SPECIFIC_SYSTEM_VERSION_NAME "${CMAKE_SYSTEM_NAME}-${LINUX_NAME}")
endif(LINUX_NAME)
endif(CMAKE_SYSTEM_NAME MATCHES "Linux")
set(SPECIFIC_SYSTEM_VERSION_NAME "${SPECIFIC_SYSTEM_VERSION_NAME}-${CMAKE_SYSTEM_PROCESSOR}")
set(SPECIFIC_COMPILER_NAME "")
endif(UNIX)
if (NOT SPECIFIC_SYSTEM_PREFERED_CPACK_GENERATOR STREQUAL "" )
set(CPACK_GENERATOR ${SPECIFIC_SYSTEM_PREFERED_CPACK_GENERATOR} )
endif (NOT SPECIFIC_SYSTEM_PREFERED_CPACK_GENERATOR STREQUAL "" )
if (NOT MY_OS STREQUAL "" )
message(STATUS "---- Detect CPACK ----")
message(STATUS "Linux distribution :" ${MY_OS})
message(STATUS "OS version :" ${LINUX_NAME})
message(STATUS "Generator :" ${CPACK_GENERATOR})
endif (NOT MY_OS STREQUAL "" )
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