Skip to content

Commit

Permalink
a
Browse files Browse the repository at this point in the history
  • Loading branch information
bha-evs committed Mar 24, 2024
1 parent 8c1f664 commit 8489481
Show file tree
Hide file tree
Showing 5 changed files with 179 additions and 0 deletions.
18 changes: 18 additions & 0 deletions cmake/cpack_archive.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
if (UNIX)
list(APPEND CPACK_GENERATOR "TGZ")
elseif(WIN32)
list(APPEND CPACK_GENERATOR "ZIP")
endif()

set(CPACK_ARCHIVE_COMPONENT_INSTALL ON)

set(CPACK_ARCHIVE_COMPONENT_INSTALL ON)
set(CPACK_ARCHIVE_RUNTIME_FILE_NAME ${CPACK_PACKAGE_NAME})
set(CPACK_ARCHIVE_DEVEL_FILE_NAME ${CPACK_PACKAGE_NAME}-devel)
set(CPACK_ARCHIVE_DEBUG_FILE_NAME ${CPACK_PACKAGE_NAME}-debug)

message("------CPACK_PACKAGE_NAME--ARCH------->" ${CPACK_PACKAGE_NAME})
message("------CPACK_ARCHIVE_RUNTIME_FILE_NAME--ARCH------->" ${CPACK_ARCHIVE_RUNTIME_FILE_NAME})
message("------CPACK_ARCHIVE_DEVEL_FILE_NAME--ARCH------->" ${CPACK_ARCHIVE_DEVEL_FILE_NAME})
message("------CPACK_ARCHIVE_DEBUG_FILE_NAME--ARCH------->" ${CPACK_ARCHIVE_DEBUG_FILE_NAME})

30 changes: 30 additions & 0 deletions cmake/cpack_deb.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
if (UNIX AND CMAKE_SYSTEM_NAME MATCHES Linux)
find_program(DEBBUILD_FOUND debuild)
if (NOT DEBBUILD_FOUND)
message(STATUS "debuild not found")
else()

list(APPEND CPACK_GENERATOR "DEB")
set(CPACK_DEBIAN_PACKAGE_RELEASE "1")
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "amd64")
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "onbings")
set(CPACK_DEBIAN_PACKAGE_SECTION "devel")
set(CPACK_DEBIAN_PACKAGE_DEPENDS "")

set(deb_releasePkgName "${CPACK_PACKAGE_NAME}.deb")
set(deb_debugPkgName "${CPACK_PACKAGE_NAME}-debug.deb")
set(deb_develPkgName "${CPACK_PACKAGE_NAME}-devel.deb")

set(CPACK_DEB_COMPONENT_INSTALL ON)
set(CPACK_DEBIAN_RUNTIME_FILE_NAME ${deb_releasePkgName})
set(CPACK_DEBIAN_DEVEL_FILE_NAME ${deb_develPkgName})
set(CPACK_DEBIAN_DEBUG_FILE_NAME ${deb_debugPkgName})

set(CPACK_DEBIAN_RUNTIME_PACKAGE_NAME ${CPACK_PACKAGE_NAME})
set(CPACK_DEBIAN_DEVEL_PACKAGE_NAME ${CPACK_PACKAGE_NAME}-devel)
set(CPACK_DEBIAN_DEBUG_PACKAGE_NAME ${CPACK_PACKAGE_NAME}-debug)

endif()
else()
message(STATUS "Bad cpack type (deb) for this os (${CMAKE_SYSTEM_NAME})")
endif()
59 changes: 59 additions & 0 deletions cmake/cpack_main.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#no need to add version cpack do it automatically: C:/bld/bofstd-win/package/bofstd-5.5.2-win64-bofstd-debug.zip generated.
#set(CPACK_PACKAGE_NAME "${PROJECT_NAME}-${PROJECT_VERSION}")
set(CPACK_PACKAGE_NAME "${PROJECT_NAME}")
message("------CPACK_PACKAGE_NAME--------->" ${CPACK_PACKAGE_NAME})
message("------PROJECT_NAME--------->" ${PROJECT_NAME})
message("------PROJECT_VERSION--------->" ${PROJECT_VERSION})
set(CPACK_PACKAGE_VENDOR "Onbings")

#set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_LIST_DIR}/...")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "The onbings general purpose C++ Multiplatform library")
set(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE")
set(CPACK_RESOURCE_FILE_README "${PROJECT_SOURCE_DIR}/README.MD")
set(CPACK_PACKAGING_INSTALL_PREFIX "")
set(CPACK_OUTPUT_FILE_PREFIX ${CMAKE_BINARY_DIR}/package)

set(CPACK_PACKAGE_VERSION_MAJOR "${PROJECT_VERSION_MAJOR}")
set(CPACK_PACKAGE_VERSION_MINOR "${PROJECT_VERSION_MINOR}")
set(CPACK_PACKAGE_VERSION_PATCH "${PROJECT_VERSION_PATCH}")

set(CPACK_SOURCE_IGNORE_FILES "${PROJECT_BINARY_DIR};/.git/;.gitignore;.svn")

set(CPACK_COMPONENTS_ALL
${PROJECT_NAME}-runtime
${PROJECT_NAME}-library
${PROJECT_NAME}-archive
${PROJECT_NAME}-headers
${PROJECT_NAME}-cmake
${PROJECT_NAME}-debug
${PROJECT_NAME}-doc
)
set(CPACK_COMPONENTS_GROUPING ONE_PER_GROUP)
#set(CPACK_COMPONENTS_GROUPING ALL_COMPONENTS_IN_ONE)

set(CPACK_COMPONENT_${PROJECT_NAME_UPPER}_RUNTIME_GROUP RUNTIME)
set(CPACK_COMPONENT_${PROJECT_NAME_UPPER}_LIBRARY_GROUP RUNTIME)
set(CPACK_COMPONENT_${PROJECT_NAME_UPPER}_ARCHIVE_GROUP DEVEL)
set(CPACK_COMPONENT_${PROJECT_NAME_UPPER}_HEADERS_GROUP DEVEL)
set(CPACK_COMPONENT_${PROJECT_NAME_UPPER}_CMAKE_GROUP DEVEL)
set(CPACK_COMPONENT_${PROJECT_NAME_UPPER}_DOC_GROUP DEVEL)
set(CPACK_COMPONENT_${PROJECT_NAME_UPPER}_DEBUG_GROUP DEBUG)

# Allow compression in //
set(CPACK_THREADS 0)

# Try to build relocatable packages
set(CPACK_PACKAGE_RELOCATABLE TRUE)

#if(DEFINED OS_DISTRO AND OS_DISTRO STREQUAL "centos")
if(MSVC)
#include(cmake/cpack_nsis.cmake)
include(cmake/cpack_archive.cmake)
else()
# include(cmake/cpack_archive.cmake)
# include(cmake/cpack_deb.cmake)
include(cmake/cpack_rpm.cmake)
endif()

include(CPack)
file(WRITE ${CPACK_OUTPUT_FILE_PREFIX}/version.txt ${PROJECT_VERSION})
14 changes: 14 additions & 0 deletions cmake/cpack_nsis.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
if (WIN32)
find_program(MAKENSIS_FOUND makensis PATHS "C:/Program Files (x86)/NSIS")
if (NOT MAKENSIS_FOUND)
message(STATUS "makensis not found, you can get it here: https://nsis.sourceforge.io")
else()
list(APPEND CPACK_GENERATOR "NSIS")
set(CPACK_NSIS_PACKAGE_NAME "${CPACK_PACKAGE_NAME}-${PROJECT_VERSION}")
set(CPACK_NSIS_CONTACT "")
set(CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL ON)

endif()
else()
message(STATUS "Bad cpack type (nsis) for this os (${CMAKE_SYSTEM_NAME})")
endif()
58 changes: 58 additions & 0 deletions cmake/cpack_rpm.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
if (UNIX AND CMAKE_SYSTEM_NAME MATCHES Linux)
find_program(RPMBUILD_FOUND rpmbuild)
if (NOT RPMBUILD_FOUND)
message(STATUS "rpmbuild not found")
else()
list(APPEND CPACK_GENERATOR "RPM")
set(CPACK_RPM_PACKAGE_NAME "${PROJECT_NAME}${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}")
set(CPACK_RPM_PACKAGE_RELEASE "${VERSION_LABEL}")
set(CPACK_RPM_PACKAGE_LICENSE "Onbings")
set(CPACK_RPM_PACAKGE_RELOCATABLE ON)
set(CPACK_RPM_PACKAGE_ARCHITECTURE "x86_64")

if (NOT DEFINED VERSION_LABEL)
set(VERSION_LABEL "alpha1" CACHE STRING "Version label : alpha1/beta1/rc1/release1" FORCE)
endif()

if (NOT DEFINED RHEL)
message(FATAL_ERROR "You must define RHEL, add -DRHEL:STRING=\"el9\" or -DRHEL:STRING=\"el7\" to cmake command line")
endif()

if (${RHEL} STREQUAL "el9")
set(OS_NAME rocky)
elseif (${RHEL} STREQUAL "el7")
set(OS_NAME centos)
endif()

set(rpm_releasePkgName "${CPACK_RPM_PACKAGE_NAME}-${PROJECT_VERSION}-${VERSION_LABEL}-${RHEL}.${OS_NAME}.evs.rpm")
set(rpm_debugPkgName "${CPACK_RPM_PACKAGE_NAME}-debug-${PROJECT_VERSION}-${VERSION_LABEL}-${RHEL}.${OS_NAME}.evs.rpm")
set(rpm_develPkgName "${CPACK_RPM_PACKAGE_NAME}-devel-${PROJECT_VERSION}-${VERSION_LABEL}.rpm")

set(CPACK_RPM_COMPONENT_INSTALL ON)

set(CPACK_RPM_RUNTIME_FILE_NAME ${rpm_releasePkgName})
set(CPACK_RPM_DEVEL_FILE_NAME ${rpm_develPkgName})
set(CPACK_RPM_DEBUG_FILE_NAME ${rpm_debugPkgName})

set(CPACK_RPM_RUNTIME_PACKAGE_NAME ${CPACK_RPM_PACKAGE_NAME})
set(CPACK_RPM_DEVEL_PACKAGE_NAME ${CPACK_RPM_PACKAGE_NAME}-devel)
set(CPACK_RPM_DEBUG_PACKAGE_NAME ${CPACK_RPM_PACKAGE_NAME}-debug)

set(CPACK_RPM_DEVEL_PACKAGE_REQUIRES ${CPACK_RPM_PACKAGE_NAME})
set(CPACK_RPM_DEBUG_PACKAGE_REQUIRES ${CPACK_RPM_PACKAGE_NAME})

set(CPACK_RPM_RUNTIME_PACKAGE_PREFIX "/opt/onbings/${CPACK_RPM_PACKAGE_NAME}")
set(CPACK_RPM_DEVEL_PACKAGE_PREFIX "/opt/onbings/${CPACK_RPM_PACKAGE_NAME}")
set(CPACK_RPM_DEBUG_PACKAGE_PREFIX "/opt/onbings/${CPACK_RPM_PACKAGE_NAME}")

# set(CPACK_RPM_DEVEL_POST_INSTALL_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/postinst")

# configure_file(
# ${CMAKE_CURRENT_LIST_DIR}/RpmPostInstallScript.in
# ${CMAKE_CURRENT_BINARY_DIR}/postinst @ONLY
# )

endif()
else()
message(STATUS "Bad cpack type (rpm) for this os (${CMAKE_SYSTEM_NAME})")
endif()

0 comments on commit 8489481

Please sign in to comment.