2014-11-10 01:12:56 +00:00
# Copyright (C) 2012-2014 (see AUTHORS file for a list of contributors)
#
# This file is part of GNSS-SDR.
#
# GNSS-SDR is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# GNSS-SDR is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GNSS-SDR. If not, see <http://www.gnu.org/licenses/>.
#
2014-11-12 05:31:17 +00:00
#if(DEFINED __INCLUDED_GNSS_SDR_PACKAGE_CMAKE)
# return()
#endif()
#set( __INCLUDED_GNSS_SDR_PACKAGE_CMAKE TRUE)
2014-11-10 01:12:56 +00:00
#set the cpack generator based on the platform type
if ( CPACK_GENERATOR )
#already set by user
elseif ( APPLE )
2014-11-12 05:31:17 +00:00
set ( PACKAGE_GENERATOR "DragNDrop" )
2014-11-11 22:50:38 +00:00
set ( PACKAGE_SOURCE_GENERATOR "TGZ;ZIP" )
elseif ( UNIX )
if ( ${ LINUX_DISTRIBUTION } MATCHES "Debian" OR ${ LINUX_DISTRIBUTION } MATCHES "Ubuntu" )
set ( PACKAGE_GENERATOR "DEB" )
endif ( ${ LINUX_DISTRIBUTION } MATCHES "Debian" OR ${ LINUX_DISTRIBUTION } MATCHES "Ubuntu" )
if ( ${ LINUX_DISTRIBUTION } MATCHES "Red Hat" OR
$ { L I N U X _ D I S T R I B U T I O N } M A T C H E S " F e d o r a " )
set ( PACKAGE_GENERATOR "DEB" )
endif ( ${ LINUX_DISTRIBUTION } MATCHES "Red Hat" OR ${ LINUX_DISTRIBUTION } MATCHES "Fedora" )
set ( PACKAGE_SOURCE_GENERATOR "TGZ;ZIP" )
2014-11-10 01:12:56 +00:00
else ( )
2014-11-11 22:50:38 +00:00
set ( PACKAGE_GENERATOR "TGZ" )
set ( PACKAGE_SOURCE_GENERATOR "TGZ" )
2014-11-10 01:12:56 +00:00
endif ( )
2014-11-11 22:50:38 +00:00
# used package generators
set ( CPACK_GENERATOR "${PACKAGE_GENERATOR}" CACHE STRING "List of binary package generators (CPack)." )
set ( CPACK_SOURCE_GENERATOR "${PACKAGE_SOURCE_GENERATOR}" CACHE STRING "List of source package generators (CPack)." )
2014-11-10 01:12:56 +00:00
2014-11-12 05:31:17 +00:00
CONFIGURE_FILE ( "${CMAKE_SOURCE_DIR}/cmake/Packaging/postinst.in" "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}/scripts/postinst" @ONLY IMMEDIATE )
2014-11-12 22:05:53 +00:00
FILE ( COPY ${ CMAKE_CURRENT_BINARY_DIR } / ${ PROJECT_NAME } /scripts/postinst DESTINATION ${ CMAKE_CURRENT_BINARY_DIR } / ${ PROJECT_NAME } FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE )
2014-11-12 05:31:17 +00:00
CONFIGURE_FILE ( "${CMAKE_SOURCE_DIR}/cmake/Packaging/prerm.in" "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}/scripts/prerm" @ONLY IMMEDIATE )
2014-11-12 22:05:53 +00:00
FILE ( COPY ${ CMAKE_CURRENT_BINARY_DIR } / ${ PROJECT_NAME } /scripts/prerm DESTINATION ${ CMAKE_CURRENT_BINARY_DIR } / ${ PROJECT_NAME } FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE )
2014-11-12 05:31:17 +00:00
2014-11-10 01:12:56 +00:00
########################################################################
# Setup CPack
########################################################################
2014-11-14 01:36:29 +00:00
set ( CPACK_PACKAGE_DESCRIPTION "An Open Source GNSS Software Defined Receiver" )
set ( CPACK_PACKAGE_DESCRIPTION_SUMMARY "This is a GNSS Software Defined Receiver written in C++." )
set ( CPACK_PACKAGE_VENDOR "Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)" )
set ( CPACK_PACKAGE_NAME "gnss-sdr" )
set ( CPACK_PACKAGE_VERSION "${VERSION}" )
set ( CPACK_PACKAGE_CONTACT "Carles Fernandez-Prades <carles.fernandez@cttc.cat>" )
set ( CPACK_PACKAGE_ICON "${CMAKE_SOURCE_DIR}/docs/doxygen/images/gnss-sdr_logo_round.png" )
set ( CPACK_PACKAGE_VERSION_MAJOR "${VERSION_INFO_MAJOR_VERSION}" )
set ( CPACK_PACKAGE_VERSION_MINOR "${VERSION_INFO_API_COMPAT}" )
set ( CPACK_PACKAGE_VERSION_PATCH "${VERSION_INFO_MINOR_VERSION}" )
set ( CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/COPYING" )
set ( CPACK_RESOURCE_FILE_README "${CMAKE_SOURCE_DIR}/README.md" )
set ( CPACK_RESOURCE_FILE_WELCOME "${CMAKE_SOURCE_DIR}/README.md" )
set ( CPACK_SET_DESTDIR "OFF" )
set ( CPACK_STRIP_FILES "${CMAKE_INSTALL_PREFIX}/bin/gnss-sdr;${CMAKE_INSTALL_PREFIX}/bin/volk_gnsssdr_profile" )
2014-11-11 22:50:38 +00:00
# Debian-specific settings
2014-11-14 01:36:29 +00:00
set ( CPACK_DEBIAN_PACKAGE_SECTION "science" )
set ( CPACK_DEBIAN_PACKAGE_PRIORITY "optional" )
set ( CPACK_DEBIAN_PACKAGE_DEPENDS "libboost-dev (>= 1.45), libstdc++6 (>= 4.7), libc6 (>= 2.13), gnuradio (>= 3.7), libarmadillo-dev (>= 1:4.200.0), liblapack-dev (>= 3.4), libopenblas-dev (>= 0.1.1), gfortran (>= 1:4.7), libssl-dev (>= 1.0), libgflags-dev (>= 2.0)" )
2014-11-12 05:31:17 +00:00
set ( CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}/postinst;${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}/prerm" )
2014-11-14 01:41:35 +00:00
set ( CPACK_DEBIAN_PACKAGE_DESCRIPTION "An Open Source GNSS Software Defined Receiver written in C++. It processes raw samples up to the computation of the PVT solution, including code and phase observables. More info at http://gnss-sdr.org" )
2014-11-12 05:31:17 +00:00
2014-11-10 01:12:56 +00:00
2014-11-11 22:50:38 +00:00
# system/architecture
if ( APPLE )
set ( CPACK_PACKAGE_ARCHITECTURE darwin )
else ( APPLE )
string ( TOLOWER "${CMAKE_SYSTEM_NAME}" CPACK_SYSTEM_NAME )
if ( CMAKE_CXX_FLAGS MATCHES "-m32" )
set ( CPACK_PACKAGE_ARCHITECTURE i386 )
else ( CMAKE_CXX_FLAGS MATCHES "-m32" )
execute_process (
C O M M A N D d p k g - - p r i n t - a r c h i t e c t u r e
R E S U L T _ V A R I A B L E R V
O U T P U T _ V A R I A B L E C P A C K _ P A C K A G E _ A R C H I T E C T U R E
)
if ( RV EQUAL 0 )
string ( STRIP "${CPACK_PACKAGE_ARCHITECTURE}" CPACK_PACKAGE_ARCHITECTURE )
else ( RV EQUAL 0 )
execute_process ( COMMAND uname -m OUTPUT_VARIABLE CPACK_PACKAGE_ARCHITECTURE )
if ( CPACK_PACKAGE_ARCHITECTURE MATCHES "x86_64" )
set ( CPACK_PACKAGE_ARCHITECTURE amd64 )
endif ( CPACK_PACKAGE_ARCHITECTURE MATCHES "x86_64" )
if ( CPACK_PACKAGE_ARCHITECTURE MATCHES "i386" )
set ( CPACK_PACKAGE_ARCHITECTURE i386 )
endif ( CPACK_PACKAGE_ARCHITECTURE MATCHES "i386" )
endif ( RV EQUAL 0 )
endif ( CMAKE_CXX_FLAGS MATCHES "-m32" )
endif ( APPLE )
if ( NOT CPACK_PACKAGE_ARCHITECTURE )
# Code from https://qt.gitorious.org/qt/qtbase/source/src/corelib/global/qprocessordetection.h
set ( archdetect_c_code "
#if defined(__arm__) || defined(__TARGET_ARCH_ARM) || defined(_M_ARM) || defined(__arm64__)
#if defined(__arm64__)
#error cmake_ARCH arm64
#endif
#if defined(__arm__) || defined(__TARGET_ARCH_ARM)
#if defined(__ARM_ARCH_8__) \\
| | defined ( __ARM_ARCH_8A__ ) \ \
| | defined ( __ARM_ARCH_8R__ ) \ \
| | ( defined ( __TARGET_ARCH_ARM ) & & _ _ T A R G E T _ A R C H _ A R M - 0 > = 8 )
#error cmake_ARCH armv8
#elif defined(__ARM_ARCH_7__) \\
| | defined ( __ARM_ARCH_7A__ ) \ \
| | defined ( __ARM_ARCH_7R__ ) \ \
| | defined ( __ARM_ARCH_7M__ ) \ \
| | ( defined ( __TARGET_ARCH_ARM ) & & _ _ T A R G E T _ A R C H _ A R M - 0 > = 7 )
#error cmake_ARCH armv7
#elif defined(__ARM_ARCH_6__) \\
| | defined ( __ARM_ARCH_6J__ ) \ \
| | defined ( __ARM_ARCH_6T2__ ) \ \
| | defined ( __ARM_ARCH_6Z__ ) \ \
| | defined ( __ARM_ARCH_6K__ ) \ \
| | defined ( __ARM_ARCH_6ZK__ ) \ \
| | defined ( __ARM_ARCH_6M__ ) \ \
| | ( defined ( __TARGET_ARCH_ARM ) & & _ _ T A R G E T _ A R C H _ A R M - 0 > = 6 )
#error cmake_ARCH armv6
#elif defined(__ARM_ARCH_5TEJ__) \\
| | ( defined ( __TARGET_ARCH_ARM ) & & _ _ T A R G E T _ A R C H _ A R M - 0 > = 5 )
#error cmake_ARCH armv5
#else
#error cmake_ARCH arm
#endif
#elif defined(__i386) || defined(__i386__) || defined(_M_IX86)
#error cmake_ARCH i386
#elif defined(__x86_64) || defined(__x86_64__) || defined(__amd64) || defined(_M_X64)
#error cmake_ARCH x86_64
#elif defined(__ia64) || defined(__ia64__) || defined(_M_IA64)
#error cmake_ARCH ia64
#elif defined(__ppc__) || defined(__ppc) || defined(__powerpc__) \\
| | defined ( _ARCH_COM ) | | defined ( _ARCH_PWR ) | | defined ( _ARCH_PPC ) \ \
| | defined ( _M_MPPC ) | | defined ( _M_PPC )
#if defined(__ppc64__) || defined(__powerpc64__) || defined(__64BIT__)
#error cmake_ARCH ppc64
#else
#error cmake_ARCH ppc
#endif
#endif
#error cmake_ARCH unknown
" )
function ( target_architecture output_var )
if ( APPLE AND CMAKE_OSX_ARCHITECTURES )
# On OS X we use CMAKE_OSX_ARCHITECTURES *if* it was set
# On OS X 10.6+ the default is x86_64 if the CPU supports it, i386 otherwise.
foreach ( osx_arch ${ CMAKE_OSX_ARCHITECTURES } )
if ( "${osx_arch}" STREQUAL "i386" )
set ( osx_arch_i386 TRUE )
elseif ( "${osx_arch}" STREQUAL "x86_64" )
set ( osx_arch_x86_64 TRUE )
else ( )
message ( FATAL_ERROR "Invalid OS X arch name: ${osx_arch}" )
endif ( )
endforeach ( )
# Now add all the architectures in our normalized order
if ( osx_arch_i386 )
list ( APPEND ARCH i386 )
endif ( )
if ( osx_arch_x86_64 )
list ( APPEND ARCH x86_64 )
endif ( )
else ( )
file ( WRITE "${CMAKE_BINARY_DIR}/arch.c" "${archdetect_c_code}" )
enable_language ( C )
# Detect the architecture in a rather creative way...
# This compiles a small C program which is a series of ifdefs that selects a
# particular #error preprocessor directive whose message string contains the
# target architecture. The program will always fail to compile (both because
# file is not a valid C program, and obviously because of the presence of the
# #error preprocessor directives... but by exploiting the preprocessor in this
# way, we can detect the correct target architecture even when cross-compiling,
# since the program itself never needs to be run (only the compiler/preprocessor)
try_run (
r u n _ r e s u l t _ u n u s e d
c o m p i l e _ r e s u l t _ u n u s e d
" $ { C M A K E _ B I N A R Y _ D I R } "
" $ { C M A K E _ B I N A R Y _ D I R } / a r c h . c "
C O M P I L E _ O U T P U T _ V A R I A B L E A R C H
C M A K E _ F L A G S C M A K E _ O S X _ A R C H I T E C T U R E S = $ { C M A K E _ O S X _ A R C H I T E C T U R E S }
)
# Parse the architecture name from the compiler output
string ( REGEX MATCH "cmake_ARCH ([a-zA-Z0-9_]+)" ARCH "${ARCH}" )
# Get rid of the value marker leaving just the architecture name
string ( REPLACE "cmake_ARCH " "" ARCH "${ARCH}" )
# If we are compiling with an unknown architecture this variable should
# already be set to "unknown" but in the case that it's empty (i.e. due
# to a typo in the code), then set it to unknown
if ( NOT ARCH )
set ( ARCH unknown )
endif ( )
endif ( )
set ( ${ output_var } "${ARCH}" PARENT_SCOPE )
endfunction ( )
# Set target architectures
target_architecture ( CMAKE_TARGET_ARCHITECTURES )
endif ( NOT CPACK_PACKAGE_ARCHITECTURE )
if ( APPLE )
list ( LENGTH CMAKE_TARGET_ARCHITECTURES cmake_target_arch_len )
if ( NOT "${cmake_target_arch_len}" STREQUAL "1" )
set ( CMAKE_TARGET_ARCHITECTURE_UNIVERSAL TRUE )
set ( CMAKE_TARGET_ARCHITECTURE_CODE "universal" )
2014-11-14 00:40:43 +00:00
else ( NOT "${cmake_target_arch_len}" STREQUAL "1" )
2014-11-11 22:50:38 +00:00
set ( CMAKE_TARGET_ARCHITECTURE_UNIVERSAL FALSE )
set ( CMAKE_TARGET_ARCHITECTURE_CODE "${CMAKE_TARGET_ARCHITECTURES}" )
2014-11-14 00:40:43 +00:00
endif ( NOT "${cmake_target_arch_len}" STREQUAL "1" )
2014-11-11 22:50:38 +00:00
endif ( APPLE )
2014-11-10 01:12:56 +00:00
2014-11-11 22:50:38 +00:00
# source package settings
#set (CPACK_SOURCE_TOPLEVEL_TAG "source")
2014-11-14 00:40:43 +00:00
set ( CPACK_SOURCE_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}" )
set ( CPACK_SOURCE_IGNORE_FILES "/\\\\.git/;\\\\.gitignore;/\\\\data/*;/\\\\install/*;/\\\\thirdparty/;/\\\\docs/html/;/\\\\docs/latex;\\\\.pdf;\\\\.project$;\\\\.DS_Store;\\\\.swp$;\\\\.#;/#;\\\\.*~;cscope\\\\.*;/[Bb]uild[.+-_a-zA-Z0-9]*/" )
2014-11-10 01:12:56 +00:00
2014-11-11 22:50:38 +00:00
# default binary package settings
2014-11-14 00:40:43 +00:00
set ( CPACK_INCLUDE_TOPLEVEL_DIRECTORY TRUE )
set ( CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}_${CPACK_PACKAGE_VERSION}" )
if ( CPACK_PACKAGE_ARCHITECTURE )
set ( CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_FILE_NAME}_${CPACK_PACKAGE_ARCHITECTURE}" )
endif ( CPACK_PACKAGE_ARCHITECTURE )
2014-11-10 01:12:56 +00:00
2014-11-12 05:31:17 +00:00
if ( CPACK_GENERATOR STREQUAL "DEB" )
2014-11-13 17:57:01 +00:00
configure_file ( "${CMAKE_SOURCE_DIR}/cmake/Packaging/fixup_deb_permissions.sh.in" "${CMAKE_CURRENT_BINARY_DIR}/fixup_deb_permissions.sh" @ONLY IMMEDIATE )
2014-11-12 05:31:17 +00:00
2014-11-13 17:57:01 +00:00
configure_file ( "${CMAKE_SOURCE_DIR}/cmake/Packaging/fixup_deb_permissions.sh.in" "${CMAKE_CURRENT_BINARY_DIR}/scripts/fixup_deb_permissions.sh" @ONLY IMMEDIATE )
file ( COPY ${ CMAKE_CURRENT_BINARY_DIR } /scripts/fixup_deb_permissions.sh DESTINATION ${ CMAKE_CURRENT_BINARY_DIR } / ${ PROJECT_NAME } /
F I L E _ P E R M I S S I O N S O W N E R _ R E A D O W N E R _ W R I T E O W N E R _ E X E C U T E G R O U P _ R E A D G R O U P _ E X E C U T E W O R L D _ R E A D W O R L D _ E X E C U T E )
2014-11-12 05:31:17 +00:00
2014-11-13 19:47:10 +00:00
# Write license
file ( WRITE "${CMAKE_CURRENT_BINARY_DIR}/copyright"
2014-11-14 00:40:43 +00:00
" F o r m a t : h t t p : / / w w w . d e b i a n . o r g / d o c / p a c k a g i n g - m a n u a l s / c o p y r i g h t - f o r m a t / 1 . 0 /
U p s t r e a m - N a m e : g n s s - s d r
S o u r c e : g i t : / / g i t h u b . c o m / g n s s - s d r / g n s s - s d r
F i l e s : *
C o p y r i g h t : C o p y r i g h t 2 0 1 4 $ { C P A C K _ P A C K A G E _ C O N T A C T }
L i c e n s e : G P L - 3 +
T h i s p r o g r a m i s f r e e s o f t w a r e ; y o u c a n r e d i s t r i b u t e i t
a n d / o r m o d i f y i t u n d e r t h e t e r m s o f t h e G N U G e n e r a l P u b l i c
L i c e n s e a s p u b l i s h e d b y t h e F r e e S o f t w a r e F o u n d a t i o n ; e i t h e r
v e r s i o n 3 o f t h e L i c e n s e , or ( at your option ) a n y l a t e r
v e r s i o n .
.
T h i s p r o g r a m i s d i s t r i b u t e d i n t h e h o p e t h a t i t w i l l b e
u s e f u l , b u t W I T H O U T A N Y W A R R A N T Y ; w i t h o u t e v e n t h e i m p l i e d
w a r r a n t y o f M E R C H A N T A B I L I T Y o r F I T N E S S F O R A P A R T I C U L A R
P U R P O S E . S e e t h e G N U G e n e r a l P u b l i c L i c e n s e f o r m o r e
d e t a i l s .
.
Y o u s h o u l d h a v e r e c e i v e d a c o p y o f t h e G N U G e n e r a l P u b l i c
L i c e n s e a l o n g w i t h t h i s p a c k a g e ; i f n o t , w r i t e t o t h e F r e e
S o f t w a r e F o u n d a t i o n , I n c . , 5 1 F r a n k l i n S t , F i f t h F l o o r ,
B o s t o n , M A 0 2 1 1 0 - 1 3 0 1 U S A
.
O n D e b i a n s y s t e m s , t h e f u l l t e x t o f t h e G N U G e n e r a l P u b l i c
L i c e n s e v e r s i o n 3 c a n b e f o u n d i n t h e f i l e
` / u s r / s h a r e / c o m m o n - l i c e n s e s / G P L - 3 ' . " )
2014-11-13 19:47:10 +00:00
install ( FILES "${CMAKE_CURRENT_BINARY_DIR}/copyright"
2014-11-13 18:47:10 +00:00
D E S T I N A T I O N " s h a r e / d o c / $ { C P A C K _ P A C K A G E _ N A M E } " )
2014-11-14 01:08:31 +00:00
execute_process ( COMMAND gzip -9 -c ${ CMAKE_CURRENT_SOURCE_DIR } /cmake/Packaging/changelog
W O R K I N G _ D I R E C T O R Y $ { C M A K E _ B I N A R Y _ D I R } O U T P U T _ F I L E " $ { C M A K E _ B I N A R Y _ D I R } / c h a n g e l o g . g z " )
2014-11-14 01:36:29 +00:00
execute_process ( COMMAND gzip -9 -c ${ CMAKE_CURRENT_SOURCE_DIR } /cmake/Packaging/changelog.Debian
W O R K I N G _ D I R E C T O R Y $ { C M A K E _ B I N A R Y _ D I R } O U T P U T _ F I L E " $ { C M A K E _ B I N A R Y _ D I R } / c h a n g e l o g . D e b i a n . g z " )
2014-11-14 01:08:31 +00:00
2014-11-14 01:36:29 +00:00
install ( FILES "${CMAKE_BINARY_DIR}/changelog.gz" "${CMAKE_BINARY_DIR}/changelog.Debian.gz" DESTINATION "share/doc/${CPACK_PACKAGE_NAME}" )
2014-11-13 18:47:10 +00:00
endif ( CPACK_GENERATOR STREQUAL "DEB" )
2014-11-10 01:12:56 +00:00
2014-11-11 22:50:38 +00:00
include ( CPack )