Skip to content

Commit

Permalink
CMake: move packaging related stuff from utils.cmake to packaging.cmake
Browse files Browse the repository at this point in the history
  • Loading branch information
Xottab-DUTY committed Feb 7, 2024
1 parent 52c3e2e commit 289f78b
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 62 deletions.
84 changes: 48 additions & 36 deletions cmake/packaging.cmake
Original file line number Diff line number Diff line change
@@ -1,48 +1,60 @@
if (UNIX)
if (EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake")
set(CPACK_PACKAGE_VENDOR "OpenXRay Team")
set(CPACK_PACKAGE_CONTACT "OpenXRay <openxray@yahoo.com>")
set(CPACK_PACKAGE_DESCRIPTION ${CMAKE_PROJECT_DESCRIPTION})
set(CPACK_PACKAGE_VENDOR "OpenXRay Team")
set(CPACK_PACKAGE_CONTACT "OpenXRay <openxray@yahoo.com>")
set(CPACK_PACKAGE_DESCRIPTION ${CMAKE_PROJECT_DESCRIPTION})

set(CPACK_PACKAGE_FILE_NAME "openxray-${CMAKE_PROJECT_VERSION}-${CMAKE_SYSTEM_PROCESSOR}")
set(CPACK_PACKAGE_FILE_NAME "openxray-${CMAKE_PROJECT_VERSION}-${CMAKE_SYSTEM_PROCESSOR}")

set(CPACK_STRIP_FILES TRUE)
set(CPACK_SOURCE_IGNORE_FILES "/.gitattributes")
set(CPACK_RESOURCE_FILE_README ${PROJECT_SOURCE_DIR}/README.md)
set(CPACK_RESOURCE_FILE_LICENSE ${PROJECT_SOURCE_DIR}/License.txt)
set(CPACK_STRIP_FILES TRUE)
set(CPACK_SOURCE_IGNORE_FILES "/.gitattributes")
set(CPACK_RESOURCE_FILE_README ${PROJECT_SOURCE_DIR}/README.md)
set(CPACK_RESOURCE_FILE_LICENSE ${PROJECT_SOURCE_DIR}/License.txt)

# --- SELECT PROPER CPACK GENERATOR ---
if (DEBIAN_FOUND)
set(CPACK_GENERATOR DEB)
if (UNIX)
# Try to find specific OS files to determine type of linux distribution
find_file(FEDORA_FOUND fedora-release PATHS /etc)
find_file(REDHAT_FOUND redhat-release inittab.RH PATHS /etc)
find_file(CENTOS_FOUND centos-release PATHS /etc)
# If we found debian then we don't need to check further for ubuntu
# as it uses debian core.
find_file(DEBIAN_FOUND debian_version debconf.conf PATHS /etc)

# --------------------------------------------------
# Uninstall target
# --------------------------------------------------
# To clean system folder from libraries and binaries
# that was installed with `sudo make install`
# just run `sudo make uninstall`
if (NOT TARGET uninstall)
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
IMMEDIATE @ONLY)

add_custom_target(uninstall COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
endif()

set(CPACK_DEBIAN_FILE_NAME "DEB-DEFAULT")
# --- SELECT PROPER CPACK GENERATOR ---
if (DEBIAN_FOUND)
set(CPACK_GENERATOR DEB)

set(CPACK_DEBIAN_PACKAGE_SECTION "games")
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
set(CPACK_DEBIAN_PACKAGE_CONTROL_STRICT_PERMISSION TRUE)
endif()
set(CPACK_DEBIAN_FILE_NAME "DEB-DEFAULT")

if (FEDORA_FOUND OR REDHAT_FOUND OR CENTOS_FOUND)
set(CPACK_GENERATOR RPM)
set(CPACK_DEBIAN_PACKAGE_SECTION "games")
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
set(CPACK_DEBIAN_PACKAGE_CONTROL_STRICT_PERMISSION TRUE)
endif()

set(CPACK_RPM_FILE_NAME "RPM-DEFAULT")
if (FEDORA_FOUND OR REDHAT_FOUND OR CENTOS_FOUND)
set(CPACK_GENERATOR RPM)

set(CPACK_RPM_PACKAGE_GROUP "Amusements/Games")
# -- set(CPACK_RPM_PACKAGE_AUTOREQPROV ON)
set(CPACK_RPM_PACKAGE_AUTOREQ ON)
set(CPACK_RPM_PACKAGE_AUTOPROV YES)
set(CPACK_RPM_PACKAGE_RELEASE_DIST ON)
endif()
set(CPACK_RPM_FILE_NAME "RPM-DEFAULT")

include(CPack)
set(CPACK_RPM_PACKAGE_GROUP "Amusements/Games")
# -- set(CPACK_RPM_PACKAGE_AUTOREQPROV ON)
set(CPACK_RPM_PACKAGE_AUTOREQ ON)
set(CPACK_RPM_PACKAGE_AUTOPROV YES)
set(CPACK_RPM_PACKAGE_RELEASE_DIST ON)
endif()
endif()

# TODO: Need to be implemented in future
if (WIN32)
#set(CPACK_GENERATOR NSIS)
endif()

if (APPLE)
#set(CPACK_GENERATOR "DRAGNDROP")
include(CPack)
endif()
26 changes: 0 additions & 26 deletions cmake/utils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -31,32 +31,6 @@ else (CMAKE_SIZEOF_VOID_P EQUAL 4)
set(ARCH_TYPE x86)
endif()

# Unix system configuration
if (UNIX)
# Try to find specific OS files to determine type of linux distribution
find_file(FEDORA_FOUND fedora-release PATHS /etc)
find_file(REDHAT_FOUND redhat-release inittab.RH PATHS /etc)
find_file(CENTOS_FOUND centos-release PATHS /etc)
# If we found debian then we don't need to check further for ubuntu
# as it uses debian core.
find_file(DEBIAN_FOUND debian_version debconf.conf PATHS /etc)

# --------------------------------------------------
# Uninstall target
# --------------------------------------------------
# To clean system folder from libraries and binaries
# that was installed with `sudo make install`
# just run `sudo make uninstall`
if (NOT TARGET uninstall)
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
IMMEDIATE @ONLY)

add_custom_target(uninstall COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
endif()
endif()

function(set_git_info)
execute_process(COMMAND git rev-parse --verify HEAD
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
Expand Down

0 comments on commit 289f78b

Please sign in to comment.