From f636449c8d9bcd3efc84ffcb9987b658f6d242ec Mon Sep 17 00:00:00 2001
From: "Joachim Wuttke (h)" <j.wuttke@fz-juelich.de>
Date: Wed, 8 Jul 2020 12:45:06 +0200
Subject: [PATCH] CPack: bring configuration a bit closer to standard

---
 CMakeLists.txt                     | 11 ++++++++---
 cmake/modules/BornAgainCPack.cmake | 21 ++++++++++-----------
 cmake/modules/CPackDebian.cmake    |  9 ++++-----
 3 files changed, 22 insertions(+), 19 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index cdbda5c32ae..e7b58939ff6 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -13,11 +13,16 @@ set(CONFIGURABLES_DIR ${CMAKE_SOURCE_DIR}/cmake/configurables)
 
 include(PreventInSourceBuilds)
 
-project(BornAgain)
+project(BornAgain
+    DESCRIPTION "BornAgain: simulate and fit scattering at grazing incidence."
+    HOMEPAGE_URL https://www.bornagainproject.org
+    LANGUAGES CXX)
 
 include(CTest) # equivalent to "enable_testing() ???
-add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} -LE Fullcheck) # => 'make check' is an alias for 'ctest'
-add_custom_target(fullcheck COMMAND ${CMAKE_CTEST_COMMAND}) # => 'make check' is an alias for 'ctest'
+add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} -LE Fullcheck)
+   # => 'make check' is an alias for 'ctest'
+add_custom_target(fullcheck COMMAND ${CMAKE_CTEST_COMMAND})
+   # => 'make check' is an alias for 'ctest'
 
 include(VERSION.cmake)
 
diff --git a/cmake/modules/BornAgainCPack.cmake b/cmake/modules/BornAgainCPack.cmake
index a0990aa32ed..b524f4e927f 100644
--- a/cmake/modules/BornAgainCPack.cmake
+++ b/cmake/modules/BornAgainCPack.cmake
@@ -2,15 +2,14 @@
 
 include(InstallRequiredSystemLibraries)
 
-set(BORNAGAIN_VERSION "${BornAgain_VERSION_MAJOR}.${BornAgain_VERSION_MINOR}.${BornAgain_VERSION_PATCH}")
-
-set(CPACK_PACKAGE_NAME "BornAgain")
-set(CPACK_PACKAGE_DESCRIPTION "BornAgain: simulate and fit scattering at grazing incidence.")
 set(CPACK_PACKAGE_VENDOR "Forschungszentrum Juelich GmbH")
-set(CPACK_PACKAGE_VERSION ${BORNAGAIN_VERSION})
+set(BORNAGAIN_VERSION
+    "${BORNAGAIN_VERSION_MAJOR}.${BORNAGAIN_VERSION_MINOR}.${BORNAGAIN_VERSION_PATCH}")
+
 set(CPACK_PACKAGE_VERSION_MAJOR ${BornAgain_VERSION_MAJOR})
 set(CPACK_PACKAGE_VERSION_MINOR ${BornAgain_VERSION_MINOR})
 set(CPACK_PACKAGE_VERSION_PATCH ${BornAgain_VERSION_PATCH})
+set(CPACK_PACKAGE_VERSION ${BORNAGAIN_VERSION})
 
 configure_file(COPYING LICENSE.txt COPYONLY)
 set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_BINARY_DIR}/LICENSE.txt")
@@ -18,13 +17,13 @@ set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_BINARY_DIR}/LICENSE.txt")
 # binary package setup
 set(CPACK_PACKAGE_RELOCATABLE True)
 
-if(CMAKE_BUILD_TYPE STREQUAL Release)
-    set(CPACK_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}-${BORNAGAIN_VERSION}-${BORNAGAIN_ARCHITECTURE}")
-else()
-    set(CPACK_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}-${BORNAGAIN_VERSION}-${BORNAGAIN_ARCHITECTURE}-${CMAKE_BUILD_TYPE}")
+set(CPACK_PACKAGE_FILE_NAME
+    "${CMAKE_PROJECT_NAME}-${BORNAGAIN_VERSION}-${BORNAGAIN_ARCHITECTURE}")
+if(NOT CMAKE_BUILD_TYPE STREQUAL Release)
+    string(APPEND CPACK_PACKAGE_FILE_NAME "-${CMAKE_BUILD_TYPE}")
 endif()
 
-set(CPACK_PACKAGE_INSTALL_DIRECTORY "${CMAKE_PROJECT_NAME}-${BORNAGAIN_VERSION}")
+set(CPACK_PACKAGE_INSTALL_DIRECTORY "${CMAKE_PROJECT_NAME}-${CPACK_PACKAGE_VERSION}")
 
 
 if(WIN32)
@@ -40,7 +39,7 @@ endif()
 
 # Generating the source package
 set(CPACK_SOURCE_GENERATOR "TGZ")
-set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
+set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}-${BORNAGAIN_VERSION}")
 
 message(STATUS "Installer name: ${CPACK_PACKAGE_FILE_NAME}")
 message(STATUS "Source package name: ${CPACK_SOURCE_PACKAGE_FILE_NAME}")
diff --git a/cmake/modules/CPackDebian.cmake b/cmake/modules/CPackDebian.cmake
index b2049bca7a6..6824fda0b43 100644
--- a/cmake/modules/CPackDebian.cmake
+++ b/cmake/modules/CPackDebian.cmake
@@ -2,7 +2,7 @@
 set(CPACK_GENERATOR "DEB")
 
 # parameters to build a debian package
-set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Juan M. Carmona Loaiza <j.carmona.loaiza@fz-juelich.de>")
+set(CPACK_DEBIAN_PACKAGE_MAINTAINER "<contact@bornagainproject.org>")
 
 # Architecture: (mandatory)
 IF(NOT CPACK_DEBIAN_PACKAGE_ARCHITECTURE)
@@ -20,7 +20,6 @@ IF(NOT CPACK_DEBIAN_PACKAGE_ARCHITECTURE)
 ENDIF(NOT CPACK_DEBIAN_PACKAGE_ARCHITECTURE)
 
 set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
-set(CPACK_DEBIAN_PACKAGE_NAME "${CPACK_PACKAGE_NAME}")
 set(CPACK_DEBIAN_PACKAGE_PRIORITY "optional")
 set(CPACK_DEBIAN_PACKAGE_SECTION "devel")
 set(CPACK_STRIP_FILES "TRUE")
@@ -32,10 +31,10 @@ set(CPACK_STRIP_FILES "TRUE")
 #Version-free dependencies:
 set(CPACK_DEBIAN_PACKAGE_DEPENDS "libgsl-dev(>=1.15), libboost-all-dev, libfftw3-3(>=3.3.1), python3, python3-numpy, python3-matplotlib, libqt5widgets5(>=5.4), libtiffxx5(>=4.0.2)")
 
-set(CPACK_DEBIAN_PACKAGE_DESCRIPTION    "${CPACK_PACKAGE_DESCRIPTION}")
+set(CPACK_DEBIAN_PACKAGE_DESCRIPTION ${CMAKE_PROJECT_DESCRIPTION})
 set(CPACK_DEBIAN_PACKAGE_VERSION ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}-${BornAgain_VERSION_PATCH})
-set(CPACK_PACKAGE_FILE_NAME "${CPACK_DEBIAN_PACKAGE_NAME}-${CPACK_DEBIAN_PACKAGE_VERSION}_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}")
-set(CPACK_DEBIAN_PACKAGE_CONFLICTS "${CPACK_DEBIAN_PACKAGE_NAME}(<=${BORNAGAIN_VERSION})")
+set(CPACK_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}-${CPACK_DEBIAN_PACKAGE_VERSION}_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}")
+set(CPACK_DEBIAN_PACKAGE_CONFLICTS "${CMAKE_PROJECT_NAME}(<=${BORNAGAIN_VERSION})")
 
 # set postinstall and preremove scripts for the debian package
 set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${BUILD_VAR_DIR}/postinst;${BUILD_VAR_DIR}/prerm;")
-- 
GitLab